Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
szarp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Newterm
szarp
Commits
f4bd9c9a
Commit
f4bd9c9a
authored
7 years ago
by
Michał Glinka
Committed by
Aleksy Barcz
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
rb366
parent
37b30550
No related branches found
Tags
custom-develup3
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
parcook/defdmn.cc
+33
-11
33 additions, 11 deletions
parcook/defdmn.cc
parcook/defdmn.h
+3
-1
3 additions, 1 deletion
parcook/defdmn.h
with
36 additions
and
12 deletions
parcook/defdmn.cc
+
33
−
11
View file @
f4bd9c9a
...
...
@@ -158,7 +158,7 @@ void Defdmn::configure(int* argc, char** argv) {
m_cfg
.
reset
(
new
DaemonConfig
(
"defdmn"
));
configure_events
();
if
(
m_cfg
->
Load
(
argc
,
argv
,
0
,
NULL
,
0
,
m_event_base
))
throw
SzException
(
"Could not load configuration"
);
...
...
@@ -183,7 +183,7 @@ void Defdmn::configure(int* argc, char** argv) {
sz4
::
live_cache_config
*
live_config
=
new
sz4
::
live_cache_config
();
live_config
->
retention
=
1000
;
configureHubs
(
live_config
);
char
*
sub_address
=
libpar_getpar
(
"parhub"
,
"pub_conn_addr"
,
1
);
...
...
@@ -195,13 +195,14 @@ void Defdmn::configure(int* argc, char** argv) {
registerLuaFunctions
();
int
i
=
0
;
for
(
TUnit
*
unit
=
dev
->
GetFirstRadio
()
->
GetFirstUnit
();
unit
;
unit
=
unit
->
GetNext
())
{
for
(
TParam
*
p
=
unit
->
GetFirstParam
();
p
;
p
=
unit
->
GetNextParam
(
p
))
{
if
(
p
->
GetLuaScript
())
{
std
::
shared_ptr
<
DefParamBase
>
ptr
(
sz4
::
factory
<
DefParamBase
,
LuaParamBuilder
>::
op
(
p
,
p
,
p
->
GetIpcInd
()
));
std
::
shared_ptr
<
DefParamBase
>
ptr
(
sz4
::
factory
<
DefParamBase
,
LuaParamBuilder
>::
op
(
p
,
p
,
i
++
));
param_info
.
push_back
(
ptr
);
}
else
{
std
::
shared_ptr
<
DefParamBase
>
ptr
(
sz4
::
factory
<
DefParamBase
,
RPNParamBuilder
>::
op
(
p
,
p
,
p
->
GetIpcInd
()
));
std
::
shared_ptr
<
DefParamBase
>
ptr
(
sz4
::
factory
<
DefParamBase
,
RPNParamBuilder
>::
op
(
p
,
p
,
i
++
));
param_info
.
push_back
(
ptr
);
}
}
// if any param is ill-formed, stop the daemon
...
...
@@ -210,7 +211,34 @@ void Defdmn::configure(int* argc, char** argv) {
for
(
auto
&
p
:
param_info
)
p
->
subscribe_on_params
(
m_base
.
get
());
}
std
::
wstring
makeParamNameGlobal
(
std
::
wstring
name
)
{
if
(
std
::
count
(
name
.
begin
(),
name
.
end
(),
L':'
)
==
2
)
{
std
::
wstring
prefix
=
SC
::
A2S
(
libpar_getpar
(
""
,
"prefix"
,
0
));
prefix
.
erase
(
std
::
remove
(
prefix
.
begin
(),
prefix
.
end
(),
(
wchar_t
)
'/'
),
prefix
.
end
());
name
.
insert
(
0
,
prefix
+
(
wchar_t
)
':'
);
}
return
name
;
}
std
::
wstring
makeParamNameGlobal
(
const
char
*
pname
)
{
std
::
wstring
name
(
SC
::
U2S
(
(
const
unsigned
char
*
)
pname
));
return
makeParamNameGlobal
(
std
::
move
(
name
));
}
double
Defdmn
::
IPCParamValue
(
const
std
::
wstring
&
name
)
{
std
::
wstring
global_name
=
makeParamNameGlobal
(
name
);
return
getGlobalParamValue
(
global_name
);
}
double
Defdmn
::
IPCParamValue
(
const
char
*
pname
)
{
std
::
wstring
global_name
=
makeParamNameGlobal
(
pname
);
return
getGlobalParamValue
(
global_name
);
}
double
Defdmn
::
getGlobalParamValue
(
const
std
::
wstring
&
name
)
{
TParam
*
param
=
IPKContainer
::
GetObject
()
->
GetParam
(
name
);
if
(
!
param
)
return
std
::
numeric_limits
<
double
>::
min
();
...
...
@@ -243,16 +271,10 @@ float ChooseFun(float funid, float *parlst)
return
((
*
(
FunTable
[
fid
]))
(
parlst
));
}
std
::
wstring
makeParamNameGlobal
(
const
char
*
pname
)
{
std
::
wstring
name
(
SC
::
U2S
(
(
const
unsigned
char
*
)
pname
));
if
(
std
::
count
(
name
.
begin
(),
name
.
end
(),
L':'
)
==
2
)
name
.
insert
(
0
,
SC
::
A2S
(
libpar_getpar
(
""
,
"prefix"
,
0
))
+
(
wchar_t
)
':'
);
return
name
;
}
int
ipc_value
(
lua_State
*
lua
)
{
const
char
*
str
=
luaL_checkstring
(
lua
,
1
);
double
result
=
Defdmn
::
IPCParamValue
(
makeParamNameGlobal
(
str
)
)
;
double
result
=
Defdmn
::
IPCParamValue
(
str
);
lua_pushnumber
(
lua
,
result
);
...
...
This diff is collapsed.
Click to expand it.
parcook/defdmn.h
+
3
−
1
View file @
f4bd9c9a
...
...
@@ -69,12 +69,13 @@ public:
protected
:
void
configure_events
();
void
MainLoop
();
void
MainLoop
();
double
executeScript
(
DefParamBase
*
);
void
executeScripts
();
void
Calcul
(
DefParamBase
*
);
static
double
getGlobalParamValue
(
const
std
::
wstring
&
name
);
private
:
std
::
unique_ptr
<
IPCHandler
>
m_ipc
;
std
::
unique_ptr
<
DaemonConfig
>
m_cfg
;
...
...
@@ -95,6 +96,7 @@ public:
static
void
cycle_timer_callback
(
int
fd
,
short
event
,
void
*
arg
);
static
double
IPCParamValue
(
const
std
::
wstring
&
name
);
static
double
IPCParamValue
(
const
char
*
pname
);
static
double
Sz4BaseValue
(
const
std
::
wstring
&
name
,
sz4
::
nanosecond_time_t
t
,
SZARP_PROBE_TYPE
pt
);
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment