Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
c216641b
Commit
c216641b
authored
Apr 27, 2012
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trend curves, faster and larger (refs #105)
parent
03bd1666
Changes
39
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
3661 additions
and
372 deletions
+3661
-372
src/exe/rt_trend/src/rt_trend.c
src/exe/rt_trend/src/rt_trend.c
+465
-186
src/lib/co/src/co_cdh.c
src/lib/co/src/co_cdh.c
+82
-0
src/lib/co/src/co_cdh.h
src/lib/co/src/co_cdh.h
+2
-0
src/lib/co/src/co_time.c
src/lib/co/src/co_time.c
+78
-0
src/lib/co/src/co_time.h
src/lib/co/src/co_time.h
+4
-0
src/lib/rt/src/rt_gdh.c
src/lib/rt/src/rt_gdh.c
+237
-0
src/lib/rt/src/rt_gdh.h
src/lib/rt/src/rt_gdh.h
+26
-0
src/wbl/pwrb/src/pwrb_c_a_circbuffheader.wb_load
src/wbl/pwrb/src/pwrb_c_a_circbuffheader.wb_load
+98
-0
src/wbl/pwrb/src/pwrb_c_circbuff1000.wb_load
src/wbl/pwrb/src/pwrb_c_circbuff1000.wb_load
+87
-0
src/wbl/pwrb/src/pwrb_c_circbuff100k.wb_load
src/wbl/pwrb/src/pwrb_c_circbuff100k.wb_load
+87
-0
src/wbl/pwrb/src/pwrb_c_circbuff10k.wb_load
src/wbl/pwrb/src/pwrb_c_circbuff10k.wb_load
+87
-0
src/wbl/pwrb/src/pwrb_c_circbuff200k.wb_load
src/wbl/pwrb/src/pwrb_c_circbuff200k.wb_load
+87
-0
src/wbl/pwrb/src/pwrb_c_circbuff20k.wb_load
src/wbl/pwrb/src/pwrb_c_circbuff20k.wb_load
+87
-0
src/wbl/pwrb/src/pwrb_c_dstrendconf.wb_load
src/wbl/pwrb/src/pwrb_c_dstrendconf.wb_load
+1
-1
src/wbl/pwrb/src/pwrb_c_dstrendcurve.wb_load
src/wbl/pwrb/src/pwrb_c_dstrendcurve.wb_load
+273
-0
src/wbl/pwrb/src/pwrb_td_timeresolutionenum.wb_load
src/wbl/pwrb/src/pwrb_td_timeresolutionenum.wb_load
+78
-0
xtt/exe/rt_xtt/src/xtt_main.cpp
xtt/exe/rt_xtt/src/xtt_main.cpp
+4
-0
xtt/lib/ge/gtk/ge_curve_gtk.cpp
xtt/lib/ge/gtk/ge_curve_gtk.cpp
+21
-0
xtt/lib/ge/gtk/ge_curve_gtk.h
xtt/lib/ge/gtk/ge_curve_gtk.h
+3
-0
xtt/lib/ge/src/ge_curve.cpp
xtt/lib/ge/src/ge_curve.cpp
+9
-3
xtt/lib/ge/src/ge_curve.h
xtt/lib/ge/src/ge_curve.h
+4
-1
xtt/lib/glow/src/glow_growapi.cpp
xtt/lib/glow/src/glow_growapi.cpp
+2
-2
xtt/lib/glow/src/glow_growapi.h
xtt/lib/glow/src/glow_growapi.h
+1
-1
xtt/lib/glow/src/glow_growcurve.cpp
xtt/lib/glow/src/glow_growcurve.cpp
+41
-13
xtt/lib/glow/src/glow_growcurve.h
xtt/lib/glow/src/glow_growcurve.h
+1
-1
xtt/lib/glow/src/glow_growpolyline.cpp
xtt/lib/glow/src/glow_growpolyline.cpp
+28
-0
xtt/lib/glow/src/glow_growpolyline.h
xtt/lib/glow/src/glow_growpolyline.h
+2
-0
xtt/lib/xtt/gtk/xtt_tcurve_gtk.cpp
xtt/lib/xtt/gtk/xtt_tcurve_gtk.cpp
+115
-0
xtt/lib/xtt/gtk/xtt_tcurve_gtk.h
xtt/lib/xtt/gtk/xtt_tcurve_gtk.h
+71
-0
xtt/lib/xtt/gtk/xtt_trend_gtk.cpp
xtt/lib/xtt/gtk/xtt_trend_gtk.cpp
+4
-0
xtt/lib/xtt/gtk/xtt_xnav_gtk.cpp
xtt/lib/xtt/gtk/xtt_xnav_gtk.cpp
+8
-0
xtt/lib/xtt/gtk/xtt_xnav_gtk.h
xtt/lib/xtt/gtk/xtt_xnav_gtk.h
+1
-0
xtt/lib/xtt/src/xtt_c_object.cpp
xtt/lib/xtt/src/xtt_c_object.cpp
+14
-5
xtt/lib/xtt/src/xtt_tcurve.cpp
xtt/lib/xtt/src/xtt_tcurve.cpp
+887
-0
xtt/lib/xtt/src/xtt_tcurve.h
xtt/lib/xtt/src/xtt_tcurve.h
+160
-0
xtt/lib/xtt/src/xtt_trend.cpp
xtt/lib/xtt/src/xtt_trend.cpp
+406
-158
xtt/lib/xtt/src/xtt_trend.h
xtt/lib/xtt/src/xtt_trend.h
+7
-0
xtt/lib/xtt/src/xtt_xnav.h
xtt/lib/xtt/src/xtt_xnav.h
+2
-0
xtt/lib/xtt/src/xtt_xnav_command.cpp
xtt/lib/xtt/src/xtt_xnav_command.cpp
+91
-1
No files found.
src/exe/rt_trend/src/rt_trend.c
View file @
c216641b
...
...
@@ -74,31 +74,57 @@
#define If_Error_Log(a, b) if ((a & 1) != 1) Log_Error(a, b)
#define If_Error_Log_Exit(a, b) if ((a & 1) != 1) Log_Error_Exit(a, b)
typedef
struct
s_LstNode
sLstNode
;
/* Node for an entry. */
struct
s_LstNode
{
sLstNode
*
Next
;
pwr_sClass_DsTrend
*
DsTrend
;
/* Pointer to DsTrend object */
pwr_tSubid
DsTrendSubId
;
/* SubId for DsTrend object */
};
static
sLstNode
*
LstHead
=
NULL
;
static
pwr_tStatus
InitTrendList
();
static
void
CloseTrendList
();
typedef
struct
s_ListEntry
{
struct
s_ListEntry
*
next
;
pwr_sClass_DsTrend
*
o
;
/* Pointer to DsTrend object */
pwr_tSubid
o_subid
;
/* SubId for DsTrend object */
}
trend_sListEntry
;
typedef
struct
s_ListEntryTC
{
struct
s_ListEntryTC
*
next
;
pwr_sClass_DsTrendCurve
*
o
;
/* Pointer to DsTrendCurve object */
pwr_tSubid
o_subid
;
/* SubId for DsTrendCurve object */
void
*
datap
[
10
];
pwr_tSubid
data_subid
[
10
];
unsigned
int
data_size
[
10
];
pwr_sClass_CircBuffHeader
*
buffheadp
[
10
];
void
*
buffp
[
10
];
pwr_tSubid
buff_subid
[
10
];
unsigned
int
buff_size
[
10
];
pwr_sClass_CircBuffHeader
*
timeheadp
;
void
*
timebuffp
;
pwr_tSubid
timebuff_subid
;
unsigned
int
timebuff_size
;
unsigned
int
time_size
;
unsigned
int
multiple
;
unsigned
int
multiple_cnt
;
int
first_scan
;
}
trend_sListEntryTC
;
typedef
struct
{
pwr_tUInt32
scantime
;
pwr_tFloat32
scantime_tc
;
unsigned
int
dstrend_multiple
;
unsigned
int
dstrend_multiple_cnt
;
trend_sListEntry
*
o_list
;
trend_sListEntryTC
*
o_list_tc
;
}
trend_sCtx
,
*
trend_tCtx
;
static
pwr_tStatus
InitTrendList
(
trend_tCtx
ctx
);
static
void
CloseTrendList
(
trend_tCtx
ctx
);
static
pwr_tBoolean
IsValidType
(
pwr_eTix
Type
);
static
void
StoreData
();
static
void
StoreData
(
trend_tCtx
ctx
);
static
int
IsDisabled
(
pwr_tAttrRef
*
aaref
);
int
main
(
int
argc
,
char
**
argv
)
{
pwr_tStatus
sts
;
pwr_tObjid
ObjId
;
pwr_sClass_DsTrendConf
*
TConfP
;
pwr_tBoolean
InitOK
;
pwr_tInt32
ScanTime
=
1
;
pwr_tTime
CurrentTime
,
LastScan
,
NextScan
;
pwr_tDeltaTime
ScanDeltaTime
,
WaitTime
;
qcom_sQid
qini
;
...
...
@@ -108,6 +134,7 @@ int main (int argc, char **argv)
qcom_sQid
qid
=
qcom_cNQid
;
qcom_sGet
get
;
int
swap
=
0
;
trend_tCtx
ctx
;
errh_Init
(
"pwr_trend"
,
errh_eAnix_trend
);
errh_SetStatus
(
PWR__SRVSTARTUP
);
...
...
@@ -133,32 +160,38 @@ int main (int argc, char **argv)
exit
(
-
1
);
}
ctx
=
(
trend_tCtx
)
calloc
(
1
,
sizeof
(
trend_sCtx
));
/* Wait until local nethandler has started */
while
(
EVEN
(
gdh_NethandlerRunning
()))
sleep
(
1
);
/* Fetch ScanTime
(seconds) and initate ScanRate (1/10 second )
*/
/* Fetch ScanTime */
sts
=
gdh_GetClassList
(
pwr_cClass_DsTrendConf
,
&
ObjId
);
if
(
EVEN
(
sts
))
{
errh_Info
(
"Couldn't get the DsTrendConf object. Used ScanTime = 1 s"
);
ScanTime
=
1
;
}
else
{
ctx
->
scantime
=
1
;
ctx
->
scantime_tc
=
1
.
0
;
}
else
{
gdh_ObjidToPointer
(
ObjId
,
(
pwr_tAddress
*
)
&
TConfP
);
ScanTime
=
TConfP
->
ScanTime
;
if
(
ScanTime
>
3600
)
ScanTime
=
3600
;
else
if
(
ScanTime
<
1
)
ScanTime
=
1
;
ctx
->
scantime
=
TConfP
->
ScanTime
;
if
(
ctx
->
scantime
>
3600
)
ctx
->
scantime
=
3600
;
else
if
(
ctx
->
scantime
<
1
)
ctx
->
scantime
=
1
;
ctx
->
scantime_tc
=
TConfP
->
ScanTime
;
if
(
ctx
->
scantime_tc
>
3600
)
ctx
->
scantime_tc
=
3600
;
}
ctx
->
dstrend_multiple
=
(
int
)
(
ctx
->
scantime
/
ctx
->
scantime_tc
+
0
.
5
);
aproc_RegisterObject
(
ObjId
);
sts
=
InitTrendList
(
ScanTime
,
&
LstHead
);
if
(
ODD
(
sts
))
{
InitOK
=
TRUE
;
}
else
{
InitOK
=
FALSE
;
InitOK
=
FALSE
;
sts
=
InitTrendList
(
ctx
);
if
(
EVEN
(
sts
))
{
/* This should be removed when we can wait for init messages. */
errh_SetStatus
(
0
);
errh_Info
(
"No DsTrend objects configured"
);
...
...
@@ -168,10 +201,9 @@ int main (int argc, char **argv)
/* If even sts, just wait for init message */
time_GetTimeMonotonic
(
&
LastScan
);
ScanDeltaTime
.
tv_sec
=
ScanTime
;
ScanDeltaTime
.
tv_nsec
=
0
;
time_FloatToD
(
&
ScanDeltaTime
,
ctx
->
scantime_tc
);
aproc_TimeStamp
(
ScanT
ime
,
5
.
0
);
aproc_TimeStamp
(
ctx
->
scant
ime
,
5
.
0
);
errh_SetStatus
(
PWR__SRUN
);
for
(;;)
{
...
...
@@ -187,7 +219,7 @@ int main (int argc, char **argv)
qcom_Get
(
&
sts
,
&
qid
,
&
get
,
tmo
);
if
(
sts
==
QCOM__TMO
||
sts
==
QCOM__QEMPTY
)
{
if
(
!
swap
)
StoreData
(
LstHead
);
StoreData
(
ctx
);
}
else
{
ini_mEvent
new_event
;
...
...
@@ -197,11 +229,11 @@ int main (int argc, char **argv)
if
(
new_event
.
b
.
oldPlcStop
&&
!
swap
)
{
swap
=
1
;
errh_SetStatus
(
PWR__SRVRESTART
);
CloseTrendList
(
&
LstHead
);
CloseTrendList
(
ctx
);
}
else
if
(
new_event
.
b
.
swapDone
&&
swap
)
{
swap
=
0
;
sts
=
InitTrendList
(
ScanTime
,
&
LstHead
);
sts
=
InitTrendList
(
ctx
);
errh_SetStatus
(
PWR__SRUN
);
errh_Info
(
"Warm restart completed"
);
}
...
...
@@ -211,150 +243,311 @@ int main (int argc, char **argv)
}
}
else
if
(
!
swap
)
StoreData
(
LstHead
);
StoreData
(
ctx
);
LastScan
=
NextScan
;
aproc_TimeStamp
(
ScanT
ime
,
5
.
0
);
aproc_TimeStamp
(
ctx
->
scant
ime
,
5
.
0
);
}
return
1
;
}
/* Set up subscriptions for every local DsTrend object and
initialize the DsTrend objects. */
static
void
CloseTrendList
(
sLstNode
**
LstHead
)
static
void
CloseTrendList
(
trend_tCtx
ctx
)
{
sLstNode
*
LstNode
,
*
TmpNode
;
trend_sListEntry
*
ep
,
*
tmp
;
/* Free old list */
LstNode
=
*
LstHead
;
while
(
LstNode
!=
NULL
)
{
TmpNode
=
LstNode
;
gdh_UnrefObjectInfo
(
LstNode
->
DsTrend
->
DataSubId
);
gdh_UnrefObjectInfo
(
LstNode
->
DsTrendSubI
d
);
LstNode
=
TmpNode
->
N
ext
;
free
(
TmpNode
);
ep
=
ctx
->
o_list
;
while
(
ep
!=
NULL
)
{
tmp
=
ep
;
gdh_UnrefObjectInfo
(
ep
->
o
->
DataSubId
);
gdh_UnrefObjectInfo
(
ep
->
o_subi
d
);
ep
=
tmp
->
n
ext
;
free
(
tmp
);
}
*
LstHead
=
NULL
;
ctx
->
o_list
=
NULL
;
}
static
pwr_tStatus
InitTrendList
(
pwr_tInt32
ScanTime
,
sLstNode
**
LstHead
)
static
pwr_tStatus
InitTrendList
(
trend_tCtx
ctx
)
{
sLstNode
*
LstNode
;
pwr_tStatus
sts
;
pwr_tUInt32
Dummy
;
pwr_tTypeId
Type
;
int
Tix
;
pwr_tAttrRef
Aref
;
pwr_tAttrRef
OAref
;
pwr_tAName
Name
;
pwr_sClass_DsTrend
*
Trend
;
pwr_tUInt32
dummy
;
pwr_tTypeId
type
;
int
tix
;
pwr_tAttrRef
aref
;
pwr_tAttrRef
oaref
;
pwr_tAName
name
;
pwr_tDisableAttr
disabled
;
sts
=
gdh_GetClassListAttrRef
(
pwr_cClass_DsTrend
,
&
Aref
);
if
(
EVEN
(
sts
))
return
DS__NOOBJECT
;
/* Init DsTrend objects */
/* Scan through typelist and insert valid objects in list and initiate */
/* the DsTrend objects. */
/* Scan through typelist and insert valid objects in list and initiate
the DsTrend objects. */
for
(
sts
=
gdh_GetClassListAttrRef
(
pwr_cClass_DsTrend
,
&
aref
);
ODD
(
sts
);
sts
=
gdh_GetNextAttrRef
(
pwr_cClass_DsTrend
,
&
aref
,
&
aref
)
)
{
trend_sListEntry
*
ep
;
pwr_sClass_DsTrend
*
o
;
for
(;
ODD
(
sts
)
;
sts
=
gdh_GetNextAttrRef
(
pwr_cClass_DsTrend
,
&
Aref
,
&
Aref
)
)
{
sts
=
gdh_AttrrefToName
(
&
Aref
,
Name
,
sizeof
(
Name
),
cdh_mNName
);
sts
=
gdh_AttrrefToName
(
&
aref
,
name
,
sizeof
(
name
),
cdh_mNName
);
if
(
EVEN
(
sts
))
continue
;
/* Check if parent object is disabled */
sts
=
gdh_AttrArefToObjectAref
(
&
Aref
,
&
OA
ref
);
sts
=
gdh_AttrArefToObjectAref
(
&
aref
,
&
oa
ref
);
if
(
ODD
(
sts
))
{
sts
=
gdh_ArefDisabled
(
&
OA
ref
,
&
disabled
);
sts
=
gdh_ArefDisabled
(
&
oa
ref
,
&
disabled
);
if
(
ODD
(
sts
)
&&
disabled
)
continue
;
}
LstNode
=
calloc
(
1
,
sizeof
(
*
LstNode
));
if
(
LstNode
==
NULL
)
{
ep
=
calloc
(
1
,
sizeof
(
*
ep
));
if
(
ep
==
NULL
)
{
errh_CErrLog
(
DS__ERRALLOC
,
NULL
);
errh_SetStatus
(
PWR__SRVTERM
);
exit
(
DS__ERRALLOC
);
}
sts
=
gdh_RefObjectInfo
(
Name
,
(
pwr_tAddress
*
)
&
LstNode
->
DsTrend
,
&
LstNode
->
DsTrendSubId
,
sizeof
(
*
LstNode
->
DsTrend
));
sts
=
gdh_RefObjectInfo
(
name
,
(
pwr_tAddress
*
)
&
ep
->
o
,
&
ep
->
o_subid
,
sizeof
(
*
ep
->
o
));
if
(
EVEN
(
sts
))
{
errh_Error
(
"Couldn't get subscription for '%s'
\n
%m"
,
N
ame
,
sts
);
free
(
LstNode
);
errh_Error
(
"Couldn't get subscription for '%s'
\n
%m"
,
n
ame
,
sts
);
free
(
ep
);
continue
;
}
Trend
=
LstNode
->
DsTrend
;
o
=
ep
->
o
;
/* Initiate DsTrend object, sampled attribute must be on local node */
sts
=
gdh_DLRefObjectInfoAttrref
((
pwr_sAttrRef
*
)
&
Trend
->
DataName
,
(
pwr_tAddress
*
)
&
Trend
->
DataPointer
,
&
Trend
->
DataSubId
);
sts
=
gdh_DLRefObjectInfoAttrref
((
pwr_sAttrRef
*
)
&
o
->
DataName
,
(
pwr_tAddress
*
)
&
o
->
DataPointer
,
&
o
->
DataSubId
);
if
(
EVEN
(
sts
))
{
if
(
sts
==
GDH__RTDBNULL
&&
IsDisabled
(
&
Trend
->
DataName
))
if
(
sts
==
GDH__RTDBNULL
&&
IsDisabled
(
&
o
->
DataName
))
continue
;
errh_Error
(
"Couldn't get direct link to %s's attribute DataName
\n
%m"
,
N
ame
,
sts
);
gdh_UnrefObjectInfo
(
LstNode
->
DsTrendSubI
d
);
free
(
LstNode
);
errh_Error
(
"Couldn't get direct link to %s's attribute DataName
\n
%m"
,
n
ame
,
sts
);
gdh_UnrefObjectInfo
(
ep
->
o_subi
d
);
free
(
ep
);
continue
;
}
sts
=
gdh_GetAttributeCharAttrref
((
pwr_sAttrRef
*
)
&
Trend
->
DataName
,
&
Type
,
&
Dummy
,
&
Dummy
,
&
D
ummy
);
sts
=
gdh_GetAttributeCharAttrref
((
pwr_sAttrRef
*
)
&
o
->
DataName
,
&
type
,
&
dummy
,
&
dummy
,
&
d
ummy
);
if
(
EVEN
(
sts
))
{
errh_Error
(
"Couldn't get datatype for %s's attribute DataName
\n
%m"
,
N
ame
,
sts
);
gdh_UnrefObjectInfo
(
LstNode
->
DsTrendSubI
d
);
free
(
LstNode
);
errh_Error
(
"Couldn't get datatype for %s's attribute DataName
\n
%m"
,
n
ame
,
sts
);
gdh_UnrefObjectInfo
(
ep
->
o_subi
d
);
free
(
ep
);
continue
;
}
Tix
=
cdh_TypeIdToIndex
(
T
ype
);
tix
=
cdh_TypeIdToIndex
(
t
ype
);
if
(
!
IsValidType
(
T
ix
))
{
errh_Error
(
"No valid datatype for %s's attribute DataName
\n
%m"
,
N
ame
,
DS__ERRTYPE
);
gdh_UnrefObjectInfo
(
LstNode
->
DsTrendSubI
d
);
free
(
LstNode
);
if
(
!
IsValidType
(
t
ix
))
{
errh_Error
(
"No valid datatype for %s's attribute DataName
\n
%m"
,
n
ame
,
DS__ERRTYPE
);
gdh_UnrefObjectInfo
(
ep
->
o_subi
d
);
free
(
ep
);
continue
;
}
Trend
->
DataType
=
T
ix
;
if
(
Trend
->
Multiple
==
0
)
Trend
->
Multiple
=
1
;
Trend
->
NoOfSample
=
(
Trend
->
StorageTime
*
ScanTime
)
/
Trend
->
Multiple
;
o
->
DataType
=
t
ix
;
if
(
o
->
Multiple
==
0
)
o
->
Multiple
=
1
;
o
->
NoOfSample
=
(
o
->
StorageTime
*
ctx
->
scantime
)
/
o
->
Multiple
;
if
(
Trend
->
NoOfSample
>
Trend
->
NoOfBufElement
)
Trend
->
NoOfSample
=
Trend
->
NoOfBufElement
;
if
(
o
->
NoOfSample
>
o
->
NoOfBufElement
)
o
->
NoOfSample
=
o
->
NoOfBufElement
;
Trend
->
ScanTime
=
ScanT
ime
;
o
->
ScanTime
=
ctx
->
scant
ime
;
LstNode
->
Next
=
*
LstHead
;
*
LstHead
=
LstNode
;
ep
->
next
=
ctx
->
o_list
;
ctx
->
o_list
=
ep
;
}
if
(
*
LstHead
==
NULL
)
/* Init DsTrendCurve objects */
/* Scan through typelist and insert valid objects in list and initiate
the DsTrend objects. */
for
(
sts
=
gdh_GetClassListAttrRef
(
pwr_cClass_DsTrendCurve
,
&
aref
);
ODD
(
sts
);
sts
=
gdh_GetNextAttrRef
(
pwr_cClass_DsTrendCurve
,
&
aref
,
&
aref
)
)
{
trend_sListEntryTC
*
ep
;
pwr_sClass_DsTrendCurve
*
o
;
int
i
;
int
found
;
sts
=
gdh_AttrrefToName
(
&
aref
,
name
,
sizeof
(
name
),
cdh_mNName
);
if
(
EVEN
(
sts
))
continue
;
/* Check if parent object is disabled */
sts
=
gdh_AttrArefToObjectAref
(
&
aref
,
&
oaref
);
if
(
ODD
(
sts
))
{
sts
=
gdh_ArefDisabled
(
&
oaref
,
&
disabled
);
if
(
ODD
(
sts
)
&&
disabled
)
continue
;
}
ep
=
calloc
(
1
,
sizeof
(
*
ep
));
if
(
ep
==
NULL
)
{
errh_CErrLog
(
DS__ERRALLOC
,
NULL
);
errh_SetStatus
(
PWR__SRVTERM
);
exit
(
DS__ERRALLOC
);
}
ep
->
first_scan
=
1
;
sts
=
gdh_RefObjectInfo
(
name
,
(
pwr_tAddress
*
)
&
ep
->
o
,
&
ep
->
o_subid
,
sizeof
(
*
ep
->
o
));
if
(
EVEN
(
sts
))
{
errh_Error
(
"Couldn't get subscription for '%s'
\n
%m"
,
name
,
sts
);
free
(
ep
);
continue
;
}
o
=
ep
->
o
;
if
(
o
->
Function
&
1
)
{
/* Data stored by user */
gdh_UnrefObjectInfo
(
ep
->
o_subid
);
free
(
ep
);
continue
;
}
ep
->
multiple
=
(
int
)
(
o
->
ScanTime
/
ctx
->
scantime_tc
+
0
.
5
);
o
->
NoOfSample
=
(
int
)
(
o
->
StorageTime
/
ctx
->
scantime_tc
*
ep
->
multiple
+
0
.
5
);
/* Initiate DsTrendCuve object, sampled attribute must be on local node */
found
=
0
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
cdh_ObjidIsNull
(
o
->
Attribute
[
i
].
Objid
))
continue
;
/* Link to attribute */
sts
=
gdh_DLRefObjectInfoAttrref
((
pwr_sAttrRef
*
)
&
o
->
Attribute
[
i
],
(
pwr_tAddress
*
)
&
ep
->
datap
[
i
],
&
ep
->
data_subid
[
i
]);
if
(
EVEN
(
sts
))
{
if
(
sts
==
GDH__RTDBNULL
&&
IsDisabled
(
&
o
->
Attribute
[
i
]))
continue
;
errh_Error
(
"Couldn't get direct link to %s's attribute %d, %m"
,
name
,
i
+
1
,
sts
);
ep
->
datap
[
i
]
=
0
;
continue
;
}
sts
=
gdh_GetAttributeCharAttrref
((
pwr_sAttrRef
*
)
&
o
->
Attribute
[
i
],
&
type
,
&
dummy
,
&
dummy
,
&
dummy
);
if
(
EVEN
(
sts
))
{
errh_Error
(
"Couldn't get datatype for %s's attribute DataName
\n
%m"
,
name
,
sts
);
gdh_UnrefObjectInfo
(
ep
->
data_subid
[
i
]);
ep
->
datap
[
i
]
=
0
;
continue
;
}
tix
=
cdh_TypeIdToIndex
(
type
);
ep
->
data_size
[
i
]
=
cdh_TypeToSize
(
type
);
if
(
!
IsValidType
(
tix
))
{
errh_Error
(
"No valid datatype for %s's attribute DataName
\n
%m"
,
name
,
DS__ERRTYPE
);
gdh_UnrefObjectInfo
(
ep
->
data_subid
[
i
]);
ep
->
datap
[
i
]
=
0
;
continue
;
}
o
->
AttributeType
[
i
]
=
type
;
/* Link to buffer */
sts
=
gdh_DLRefObjectInfoAttrref
((
pwr_sAttrRef
*
)
&
o
->
Buffers
[
i
],
(
pwr_tAddress
*
)
&
ep
->
buffheadp
[
i
],
&
ep
->
buff_subid
[
i
]);
if
(
EVEN
(
sts
))
{
errh_Error
(
"Couldn't get direct link to %s's buffer %d, %m"
,
name
,
i
+
1
,
sts
);
gdh_UnrefObjectInfo
(
ep
->
data_subid
[
i
]);
ep
->
datap
[
i
]
=
0
;
continue
;
}
ep
->
buffp
[
i
]
=
(
char
*
)
ep
->
buffheadp
[
i
]
+
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
/* Get buffer size */
sts
=
gdh_GetAttributeCharAttrref
(
&
o
->
Buffers
[
i
],
0
,
&
ep
->
buff_size
[
i
],
0
,
0
);
if
(
EVEN
(
sts
))
return
sts
;
ep
->
buff_size
[
i
]
-=
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
found
=
1
;
}
if
(
!
found
)
{
errh_Error
(
"No valid attributes for %s"
,
name
);
gdh_UnrefObjectInfo
(
ep
->
o_subid
);
free
(
ep
);
continue
;
}
/* Link to time buffer */
if
(
cdh_ObjidIsNotNull
(
o
->
TimeBuffer
.
Objid
))
{
sts
=
gdh_DLRefObjectInfoAttrref
((
pwr_sAttrRef
*
)
&
o
->
TimeBuffer
,
(
pwr_tAddress
*
)
&
ep
->
timeheadp
,
&
ep
->
timebuff_subid
);
if
(
EVEN
(
sts
))
{
errh_Error
(
"Couldn't get direct link to %s's time buffer, %m"
,
name
,
sts
);
ep
->
timeheadp
=
0
;
ep
->
timebuffp
=
0
;
}
else
ep
->
timebuffp
=
(
char
*
)
ep
->
timeheadp
+
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
if
(
o
->
TimeResolution
==
pwr_eTimeResolutionEnum_Nanosecond
)
ep
->
time_size
=
8
;
else
ep
->
time_size
=
4
;
/* Get buffer size */
sts
=
gdh_GetAttributeCharAttrref
(
&
o
->
TimeBuffer
,
0
,
&
ep
->
timebuff_size
,
0
,
0
);
if
(
EVEN
(
sts
))
return
sts
;
ep
->
timebuff_size
-=
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
}
/* Calculate number of samples */
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
!
ep
->
datap
[
i
])
continue
;
if
(
o
->
NoOfSample
>
ep
->
buff_size
[
i
]
/
ep
->
data_size
[
i
])
o
->
NoOfSample
=
ep
->
buff_size
[
i
]
/
ep
->
data_size
[
i
];
}
if
(
ep
->
timebuffp
)
{
if
(
o
->
NoOfSample
>
ep
->
timebuff_size
/
ep
->
time_size
)
o
->
NoOfSample
=
ep
->
timebuff_size
/
ep
->
time_size
;
}
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
!
ep
->
datap
[
i
])
continue
;
ep
->
buffheadp
[
i
]
->
Size
=
o
->
NoOfSample
;
ep
->
buffheadp
[
i
]
->
ElementSize
=
ep
->
data_size
[
i
];
}
if
(
ep
->
timebuffp
)
{
ep
->
timeheadp
->
Size
=
o
->
NoOfSample
;
ep
->
timeheadp
->
ElementSize
=
ep
->
time_size
;
}
ep
->
next
=
ctx
->
o_list_tc
;
ctx
->
o_list_tc
=
ep
;
}
if
(
ctx
->
o_list
==
NULL
&&
ctx
->
o_list_tc
==
NULL
)
return
DS__NOOBJECT
;
else
return
DS__SUCCESS
;
}
static
pwr_tBoolean
IsValidType
(
pwr_eTix
Type
)
static
pwr_tBoolean
IsValidType
(
pwr_eTix
type
)
{
pwr_tBoolean
V
alid
=
TRUE
;
pwr_tBoolean
v
alid
=
TRUE
;
switch
(
T
ype
)
{
switch
(
t
ype
)
{
case
pwr_eTix_Boolean
:
case
pwr_eTix_Float32
:
case
pwr_eTix_Float64
:
...
...
@@ -366,90 +559,176 @@ IsValidType (
case
pwr_eTix_UInt32
:
break
;
default:
V
alid
=
FALSE
;
v
alid
=
FALSE
;
break
;
}
return
V
alid
;
return
v
alid
;
}
/* Stor data for all DsTrend objects in list. */
static
void
StoreData
(
sLstNode
*
LstHead
)
/* Store data for all DsTrend objects in list. */
static
void
StoreData
(
trend_tCtx
ctx
)
{
sLstNode
*
LstNode
;
pwr_tFloat32
*
BuffP
;
pwr_sClass_DsTrend
*
Trend
;
/* Scan the TrendList */
for
(
LstNode
=
LstHead
;
LstNode
!=
NULL
;
LstNode
=
LstNode
->
Next
)
{
Trend
=
LstNode
->
DsTrend
;
/* If position equal first position in buffer */
if
(
Trend
->
NextWriteIndex
[
Trend
->
WriteBuffer
]
==
0
)
{
Trend
->
BufferStatus
[
Trend
->
WriteBuffer
]
=
1
;
time_GetTime
(
&
Trend
->
BufferTime
[
Trend
->
WriteBuffer
]);
}
if
(
Trend
->
NextMultiple
==
0
)
{
/* Store data in buffer */
BuffP
=
&
Trend
->
DataBuffer
[
Trend
->
NextWriteIndex
[
Trend
->
WriteBuffer
]
+
(
Trend
->
WriteBuffer
*
Trend
->
NoOfBufElement
)
];
switch
(
Trend
->
DataType
)
{
case
pwr_eTix_Boolean
:
*
BuffP
=
*
(
pwr_tBoolean
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_Float32
:
*
BuffP
=
*
(
pwr_tFloat32
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_Float64
:
*
BuffP
=
*
(
pwr_tFloat64
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_Int8
:
*
BuffP
=
*
(
pwr_tInt8
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_Int16
:
*
BuffP
=
*
(
pwr_tInt16
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_Int32
:
*
BuffP
=
*
(
pwr_tInt32
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_UInt8
:
*
BuffP
=
*
(
pwr_tUInt8
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_UInt16
:
*
BuffP
=
*
(
pwr_tUInt16
*
)
Trend
->
DataPointer
;
break
;
case
pwr_eTix_UInt32
:
*
BuffP
=
*
(
pwr_tUInt32
*
)
Trend
->
DataPointer
;
break
;
default
:
*
BuffP
=
0
.
0
/* Prevent invalid float */
;
break
;
}
Trend
->
NextWriteIndex
[
Trend
->
WriteBuffer
]
++
;
Trend
->
NextMultiple
=
Trend
->
Multiple
;
if
(
ctx
->
dstrend_multiple_cnt
==
0
)
{
trend_sListEntry
*
ep
;
pwr_tFloat32
*
BuffP
;
pwr_sClass_DsTrend
*
o
;
/* Scan the DsTrendList */
for
(
ep
=
ctx
->
o_list
;
ep
!=
NULL
;
ep
=
ep
->
next
)
{
o
=
ep
->
o
;
/* If position equal first position in buffer */
if
(
o
->
NextWriteIndex
[
o
->
WriteBuffer
]
==
0
)
{
o
->
BufferStatus
[
o
->
WriteBuffer
]
=
1
;
time_GetTime
(
&
o
->
BufferTime
[
o
->
WriteBuffer
]);
}
if
(
o
->
NextMultiple
==
0
)
{
/* Store data in buffer */
BuffP
=
&
o
->
DataBuffer
[
o
->
NextWriteIndex
[
o
->
WriteBuffer
]
+
(
o
->
WriteBuffer
*
o
->
NoOfBufElement
)];
switch
(
o
->
DataType
)
{
case
pwr_eTix_Boolean
:
*
BuffP
=
*
(
pwr_tBoolean
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_Float32
:
*
BuffP
=
*
(
pwr_tFloat32
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_Float64
:
*
BuffP
=
*
(
pwr_tFloat64
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_Int8
:
*
BuffP
=
*
(
pwr_tInt8
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_Int16
:
*
BuffP
=
*
(
pwr_tInt16
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_Int32
:
*
BuffP
=
*
(
pwr_tInt32
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_UInt8
:
*
BuffP
=
*
(
pwr_tUInt8
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_UInt16
:
*
BuffP
=
*
(
pwr_tUInt16
*
)
o
->
DataPointer
;
break
;
case
pwr_eTix_UInt32
:
*
BuffP
=
*
(
pwr_tUInt32
*
)
o
->
DataPointer
;
break
;
default
:
*
BuffP
=
0
.
0
/* Prevent invalid float */
;
break
;
}
o
->
NextWriteIndex
[
o
->
WriteBuffer
]
++
;
o
->
NextMultiple
=
o
->
Multiple
;
/* If buffert full then mark next buffer*/
if
(
o
->
NextWriteIndex
[
o
->
WriteBuffer
]
>=
o
->
NoOfSample
)
{
o
->
BufferStatus
[
o
->
WriteBuffer
]
=
0
;
/* sts = read */
o
->
NextWriteIndex
[
o
->
WriteBuffer
]
=
0
;
/* First position */
o
->
WriteBuffer
=
1
-
o
->
WriteBuffer
;
/* Change buffer */
}
}
o
->
NextMultiple
--
;
}
}
if
(
ctx
->
dstrend_multiple_cnt
>=
ctx
->
dstrend_multiple
-
1
)
ctx
->
dstrend_multiple_cnt
=
0
;
else
ctx
->
dstrend_multiple_cnt
++
;
/* Scan the DsTrendCurveList */
if
(
ctx
->
o_list_tc
)
{
trend_sListEntryTC
*
ep
;
void
*
BuffP
;
pwr_sClass_DsTrendCurve
*
o
;
int
i
;
unsigned
int
current_index
;
unsigned
int
first_index
;
pwr_tTime
time
;
int
first_sample
;
for
(
ep
=
ctx
->
o_list_tc
;
ep
!=
NULL
;
ep
=
ep
->
next
)
{
o
=
ep
->
o
;
if
(
ep
->
multiple_cnt
==
0
)
{
first_sample
=
0
;
if
(
ep
->
first_scan
)
{
if
(
ep
->
buffheadp
[
0
])
{
if
(
ep
->
buffheadp
[
0
]
->
LastIndex
==
0
&&
ep
->
buffheadp
[
0
]
->
FirstIndex
==
0
)
{
current_index
=
0
;
first_sample
=
1
;
}
else
current_index
=
ep
->
buffheadp
[
0
]
->
LastIndex
+
1
;
}
else
first_sample
=
1
;
ep
->
first_scan
=
0
;
}
else
{
current_index
=
o
->
LastIndex
+
1
;
first_index
=
o
->
FirstIndex
;
}
if
(
current_index
>=
o
->
NoOfSample
)
current_index
=
0
;
/* If buffert full then mark next buffer*/
if
(
current_index
==
first_index
&&
!
first_sample
)
{
first_index
++
;
if
(
first_index
>=
o
->
NoOfSample
)
first_index
=
0
;
}
/* Store data in buffer */
if
(
ep
->
timebuffp
)
{
time_GetTime
(
&
time
);
BuffP
=
(
char
*
)
ep
->
timebuffp
+
current_index
*
ep
->
time_size
;
if
(
ep
->
time_size
==
8
)
{
unsigned
int
tv_sec
=
(
unsigned
int
)
time
.
tv_sec
;
unsigned
int
tv_nsec
=
(
unsigned
int
)
time
.
tv_nsec
;
memcpy
(
BuffP
,
&
tv_sec
,
4
);
memcpy
(
BuffP
+
4
,
&
tv_nsec
,
4
);
}
else
{
unsigned
int
tv_sec
=
(
unsigned
int
)
time
.
tv_sec
;
memcpy
(
BuffP
,
&
tv_sec
,
4
);
}
ep
->
timeheadp
->
LastIndex
=
current_index
;
ep
->
timeheadp
->
FirstIndex
=
first_index
;
}
if
(
Trend
->
NextWriteIndex
[
Trend
->
WriteBuffer
]
>=
Trend
->
NoOfSample
)
{
Trend
->
BufferStatus
[
Trend
->
WriteBuffer
]
=
0
;
/* sts = read */
Trend
->
NextWriteIndex
[
Trend
->
WriteBuffer
]
=
0
;
/* First position */
Trend
->
WriteBuffer
=
1
-
Trend
->
WriteBuffer
;
/* Change buffer */
}
}
Trend
->
NextMultiple
--
;
for
(
i
=
0
;
i
<
10
;
i
++
)
{
if
(
ep
->
datap
[
i
])
{
BuffP
=
(
char
*
)
ep
->
buffp
[
i
]
+
current_index
*
ep
->
data_size
[
i
];
memcpy
(
BuffP
,
ep
->
datap
[
i
],
ep
->
data_size
[
i
]);
ep
->
buffheadp
[
i
]
->
LastIndex
=
current_index
;
ep
->
buffheadp
[
i
]
->
FirstIndex
=
first_index
;
}
}
o
->
LastIndex
=
current_index
;
o
->
FirstIndex
=
first_index
;
first_sample
=
0
;
}
if
(
ep
->
multiple_cnt
>=
ep
->
multiple
-
1
)
ep
->
multiple_cnt
=
0
;
else
ep
->
multiple_cnt
++
;
}
}
}
...
...
src/lib/co/src/co_cdh.c
View file @
c216641b
...
...
@@ -2856,6 +2856,88 @@ int cdh_TypeToMaxStrSize( pwr_eType type, int attr_size, int attr_elements)
return
size
;
}
int
cdh_TypeToSize
(
pwr_eType
type
)
{
int
size
;
switch
(
type
)
{
case
pwr_eType_Boolean
:
size
=
sizeof
(
pwr_tBoolean
);
break
;
case
pwr_eType_Enum
:
size
=
sizeof
(
pwr_tEnum
);
break
;
case
pwr_eType_Mask
:
size
=
sizeof
(
pwr_tMask
);
break
;
case
pwr_eType_Status
:
case
pwr_eType_NetStatus
:
size
=
sizeof
(
pwr_tStatus
);
break
;
case
pwr_eType_Int64
:
case
pwr_eType_UInt64
:
size
=
sizeof
(
pwr_tInt64
);
break
;
case
pwr_eType_Int32
:
case
pwr_eType_UInt32
:
size
=
sizeof
(
pwr_tInt32
);
break
;
case
pwr_eType_Int16
:
case
pwr_eType_UInt16
:
size
=
sizeof
(
pwr_tInt16
);
break
;
case
pwr_eType_Int8
:
case
pwr_eType_UInt8
:
size
=
sizeof
(
pwr_tInt8
);
break
;
case
pwr_eType_Char
:
size
=
sizeof
(
pwr_tChar
);
break
;
case
pwr_eType_Float32
:
size
=
sizeof
(
pwr_tFloat32
);
break
;
case
pwr_eType_Float64
:
size
=
sizeof
(
pwr_tFloat64
);
break
;
case
pwr_eType_Time
:
size
=
sizeof
(
pwr_tTime
);
break
;
case
pwr_eType_DeltaTime
:
size
=
sizeof
(
pwr_tDeltaTime
);
break
;
case
pwr_eType_AttrRef
:
size
=
sizeof
(
pwr_tAttrRef
);
break
;
case
pwr_eType_TypeId
:
size
=
sizeof
(
pwr_tTypeId
);
break
;
case
pwr_eType_ClassId
:
size
=
sizeof
(
pwr_tClassId
);
break
;
case
pwr_eType_ObjectIx
:
size
=
sizeof
(
pwr_tObjectIx
);
break
;
case
pwr_eType_RefId
:
size
=
sizeof
(
pwr_tRefId
);
break
;
case
pwr_eType_CastId
:
size
=
sizeof
(
pwr_tCastId
);
break
;
case
pwr_eType_DisableAttr
:
size
=
sizeof
(
pwr_tDisableAttr
);
break
;
case
pwr_eType_Objid
:
size
=
sizeof
(
pwr_tObjid
);
break
;
case
pwr_eType_VolumeId
:
size
=
sizeof
(
pwr_tVolumeId
);
break
;
default:
size
=
0
;
}
return
size
;
}
//! Convert string to valid object name.
/*!
Invalid characters in the string are replaced by '_'. If the first char is invalid
...
...
src/lib/co/src/co_cdh.h
View file @
c216641b
...
...
@@ -1060,6 +1060,8 @@ void cdh_SuppressSuperAll( char *out, char *in);
int
cdh_TypeToMaxStrSize
(
pwr_eType
type
,
int
attr_size
,
int
attr_elements
);
int
cdh_TypeToSize
(
pwr_eType
type
);
char
*
cdh_StringToObjectName
(
char
*
t
,
const
char
*
s
);
pwr_tStatus
cdh_NextObjectName
(
char
*
t
,
const
char
*
s
);
...
...
src/lib/co/src/co_time.c
View file @
c216641b
...
...
@@ -1308,6 +1308,20 @@ void time_Period( time_ePeriod period, pwr_tTime *from, pwr_tTime *to, pwr_tTime
pwr_tTime
current
;
switch
(
period
)
{
case
time_ePeriod_OneSecond
:
if
(
!
center
)
{
time_Period
(
time_ePeriod_LastSecond
,
from
,
to
,
center
,
daybreak
);
return
;
}
time_PeriodSec
(
from
,
to
,
center
,
1
);
break
;
case
time_ePeriod_10Seconds
:
if
(
!
center
)
{
time_Period
(
time_ePeriod_10Seconds
,
from
,
to
,
center
,
daybreak
);
return
;
}
time_PeriodSec
(
from
,
to
,
center
,
10
);
break
;
case
time_ePeriod_OneMinute
:
if
(
!
center
)
{
time_Period
(
time_ePeriod_LastMinute
,
from
,
to
,
center
,
daybreak
);
...
...
@@ -1371,6 +1385,16 @@ void time_Period( time_ePeriod period, pwr_tTime *from, pwr_tTime *to, pwr_tTime
*
to
=
current
;
}
break
;
case
time_ePeriod_LastSecond
:
sts
=
time_GetTime
(
to
);
from
->
tv_sec
=
to
->
tv_sec
-
1
;
from
->
tv_nsec
=
to
->
tv_nsec
;
break
;
case
time_ePeriod_Last10Seconds
:
sts
=
time_GetTime
(
to
);
from
->
tv_sec
=
to
->
tv_sec
-
10
;
from
->
tv_nsec
=
to
->
tv_nsec
;
break
;
case
time_ePeriod_LastMinute
:
sts
=
time_GetTime
(
to
);
from
->
tv_sec
=
to
->
tv_sec
-
60
;
...
...
@@ -1479,6 +1503,24 @@ void time_PreviousPeriod( time_ePeriod period, pwr_tTime *prev_from, pwr_tTime *
{
switch
(
period
)
{
case
time_ePeriod_OneSecond
:
case
time_ePeriod_LastSecond
:
*
to
=
*
from
=
*
prev_from
;
from
->
tv_sec
-=
1
;
if
(
from
->
tv_sec
<
0
)
{
from
->
tv_sec
=
0
;
to
->
tv_sec
=
1
;
}
break
;
case
time_ePeriod_10Seconds
:
case
time_ePeriod_Last10Seconds
:
*
to
=
*
from
=
*
prev_from
;
from
->
tv_sec
-=
10
;
if
(
from
->
tv_sec
<
0
)
{
from
->
tv_sec
=
0
;
to
->
tv_sec
=
10
;
}
break
;
case
time_ePeriod_OneMinute
:
case
time_ePeriod_LastMinute
:
*
to
=
*
from
=
*
prev_from
;
...
...
@@ -1574,6 +1616,26 @@ void time_NextPeriod( time_ePeriod period, pwr_tTime *prev_from, pwr_tTime *prev
sts
=
time_GetTime
(
&
current
);
switch
(
period
)
{
case
time_ePeriod_OneSecond
:
case
time_ePeriod_LastSecond
:
*
to
=
*
from
=
*
prev_to
;
to
->
tv_sec
+=
1
;
if
(
time_Acomp
(
&
current
,
to
)
!=
1
)
{
*
to
=
current
;
from
->
tv_sec
=
current
.
tv_sec
-
1
;
from
->
tv_nsec
=
current
.
tv_nsec
;
}
break
;
case
time_ePeriod_10Seconds
:
case
time_ePeriod_Last10Seconds
:
*
to
=
*
from
=
*
prev_to
;
to
->
tv_sec
+=
10
;
if
(
time_Acomp
(
&
current
,
to
)
!=
1
)
{
*
to
=
current
;
from
->
tv_sec
=
current
.
tv_sec
-
10
;
from
->
tv_nsec
=
current
.
tv_nsec
;
}
break
;
case
time_ePeriod_OneMinute
:
case
time_ePeriod_LastMinute
:
*
to
=
*
from
=
*
prev_to
;
...
...
@@ -1671,6 +1733,14 @@ int time_PeriodZoomIn( time_ePeriod *period)
{
int
changed
=
1
;
switch
(
*
period
)
{
case
time_ePeriod_Last10Seconds
:
case
time_ePeriod_10Seconds
:
*
period
=
time_ePeriod_OneSecond
;
break
;
case
time_ePeriod_LastMinute
:
case
time_ePeriod_OneMinute
:
*
period
=
time_ePeriod_10Seconds
;
break
;
case
time_ePeriod_Last10Minutes
:
case
time_ePeriod_10Minutes
:
*
period
=
time_ePeriod_OneMinute
;
...
...
@@ -1712,6 +1782,14 @@ int time_PeriodZoomOut( time_ePeriod *period)
int
changed
=
1
;
switch
(
*
period
)
{
case
time_ePeriod_OneSecond
:
case
time_ePeriod_LastSecond
:
*
period
=
time_ePeriod_10Seconds
;
break
;
case
time_ePeriod_Last10Seconds
:
case
time_ePeriod_10Seconds
:
*
period
=
time_ePeriod_OneMinute
;
break
;
case
time_ePeriod_OneMinute
:
case
time_ePeriod_LastMinute
:
*
period
=
time_ePeriod_10Minutes
;
...
...
src/lib/co/src/co_time.h
View file @
c216641b
...
...
@@ -95,6 +95,8 @@ typedef enum {
typedef
enum
{
time_ePeriod_
,
time_ePeriod_UserDefined
,
time_ePeriod_OneSecond
,
time_ePeriod_10Seconds
,
time_ePeriod_OneMinute
,
time_ePeriod_10Minutes
,
time_ePeriod_OneHour
,
...
...
@@ -102,6 +104,8 @@ typedef enum {
time_ePeriod_OneWeek
,
time_ePeriod_OneMonth
,
time_ePeriod_OneYear
,
time_ePeriod_LastSecond
,
time_ePeriod_Last10Seconds
,
time_ePeriod_LastMinute
,
time_ePeriod_Last10Minutes
,
time_ePeriod_LastHour
,
...
...
src/lib/rt/src/rt_gdh.c
View file @
c216641b
...
...
@@ -72,6 +72,7 @@
#include "rt_subc.h"
#include "rt_sanc.h"
#include "rt_dl.h"
#include "pwr_baseclasses.h"
#if defined(OS_ELN)
/* For ELN and Lynx , the 'gdh_Lock' code also takes out a mutex lock
...
...
@@ -5049,3 +5050,239 @@ pwr_tStatus gdh_GetNextSubClass( pwr_tCid cid, pwr_tCid psubcid, pwr_tCid *subci
return
GDH__NOSUCHCLASS
;
}
pwr_tStatus
gdh_GetCircBuffInfo
(
gdh_sCircBuffInfo
*
info
,
int
infosize
)
{
pwr_tStatus
sts
=
GDH__SUCCESS
;
mvol_sAttribute
attribute
;
mvol_sAttribute
*
ap
;
pwr_sClass_CircBuffHeader
*
hp
;
char
*
datap
;
int
split
=
0
;
int
start_idx
;
int
first_index
,
last_index
;
int
samples
;
int
j
;
memset
(
&
attribute
,
0
,
sizeof
(
attribute
));
gdh_Lock
;
for
(
j
=
0
;
j
<
infosize
;
j
++
)
{
while
(
1
)
{
ap
=
vol_ArefToAttribute
(
&
sts
,
&
attribute
,
&
info
[
j
].
circ_aref
,
gdb_mLo_global
,
vol_mTrans_all
);
if
(
ap
==
NULL
||
ap
->
op
==
NULL
)
break
;
touchObject
(
ap
->
op
);
samples
=
info
[
j
].
samples
;
hp
=
vol_AttributeToAddress
(
&
sts
,
ap
);
if
(
hp
!=
NULL
)
{
if
(
hp
->
FirstIndex
==
hp
->
LastIndex
)
return
0
;
if
(
info
[
j
].
resolution
<=
1
)
{
if
(
samples
>
hp
->
Size
)
samples
=
hp
->
Size
;
datap
=
(
char
*
)
hp
+
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
first_index
=
hp
->
FirstIndex
;
last_index
=
hp
->
LastIndex
;
start_idx
=
last_index
-
samples
;
if
(
first_index
<
last_index
)
{
if
(
first_index
>
start_idx
)
start_idx
=
first_index
;
}
else
{
if
(
start_idx
<
0
)
{
split
=
1
;
start_idx
=
hp
->
Size
+
start_idx
;
if
(
start_idx
<
first_index
)
start_idx
=
first_index
;
}
}
if
(
split
)
{
memcpy
(
info
[
j
].
bufp
,
datap
+
start_idx
*
hp
->
ElementSize
,
(
hp
->
Size
-
start_idx
)
*
hp
->
ElementSize
);
memcpy
(
info
[
j
].
bufp
+
(
hp
->
Size
-
start_idx
)
*
hp
->
ElementSize
,
datap
,
last_index
*
hp
->
ElementSize
);
info
[
j
].
size
=
hp
->
Size
-
start_idx
+
last_index
;
}
else
{
memcpy
(
info
[
j
].
bufp
,
datap
+
start_idx
*
hp
->
ElementSize
,
(
last_index
-
start_idx
)
*
hp
->
ElementSize
);
info
[
j
].
size
=
last_index
-
start_idx
;
}
info
[
j
].
last_idx
=
last_index
;
info
[
j
].
first_idx
=
first_index
;
info
[
j
].
offset
=
0
;
}
else
{
/* Resolution > 0 */
int
elements
;
char
*
dp
,
*
bp
;
int
i
;
int
idx
,
tst_first_idx
;
if
(
samples
>
hp
->
Size
/
info
[
j
].
resolution
)
samples
=
hp
->
Size
/
info
[
j
].
resolution
;
datap
=
(
char
*
)
hp
+
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
first_index
=
hp
->
FirstIndex
;
last_index
=
hp
->
LastIndex
;
start_idx
=
last_index
-
(
samples
-
1
)
*
info
[
j
].
resolution
;
tst_first_idx
=
first_index
;
if
(
first_index
>
last_index
)
tst_first_idx
-=
hp
->
Size
;
if
(
start_idx
<
tst_first_idx
)
start_idx
+=
(
tst_first_idx
-
start_idx
)
/
info
[
j
].
resolution
*
info
[
j
].
resolution
;
elements
=
(
last_index
-
start_idx
)
/
info
[
j
].
resolution
+
1
;
info
[
j
].
size
=
elements
;
info
[
j
].
offset
=
info
[
j
].
resolution
;
if
(
start_idx
<
0
)
start_idx
+=
hp
->
Size
;
bp
=
info
[
j
].
bufp
;
idx
=
start_idx
;
for
(
i
=
0
;
i
<
elements
;
i
++
)
{
dp
=
datap
+
idx
*
hp
->
ElementSize
;
memcpy
(
bp
,
dp
,
hp
->
ElementSize
);
// printf( "sp1: %d\n", idx);
bp
+=
hp
->
ElementSize
;
idx
+=
info
[
j
].
resolution
;
if
(
idx
>=
hp
->
Size
)
idx
-=
hp
->
Size
;
}
info
[
j
].
last_idx
=
last_index
;
info
[
j
].
first_idx
=
first_index
;
}
sts
=
GDH__SUCCESS
;
}
else
sts
=
0
;
break
;
}
gdh_Unlock
;
}
return
sts
;
}
pwr_tStatus
gdh_UpdateCircBuffInfo
(
gdh_sCircBuffInfo
*
info
,
int
infosize
)
{
pwr_tStatus
sts
=
GDH__SUCCESS
;
mvol_sAttribute
attribute
;
mvol_sAttribute
*
ap
;
pwr_sClass_CircBuffHeader
*
hp
;
char
*
datap
;
int
split
=
0
;
int
start_idx
;
int
first_index
,
last_index
;
int
j
;
memset
(
&
attribute
,
0
,
sizeof
(
attribute
));
for
(
j
=
0
;
j
<
infosize
;
j
++
)
{
gdh_Lock
;
while
(
1
)
{
ap
=
vol_ArefToAttribute
(
&
sts
,
&
attribute
,
&
info
[
j
].
circ_aref
,
gdb_mLo_global
,
vol_mTrans_all
);
if
(
ap
==
NULL
||
ap
->
op
==
NULL
)
break
;
touchObject
(
ap
->
op
);
hp
=
vol_AttributeToAddress
(
&
sts
,
ap
);
if
(
hp
!=
NULL
)
{
if
(
hp
->
FirstIndex
==
hp
->
LastIndex
)
{
info
[
j
].
size
=
0
;
break
;
}
if
(
info
[
j
].
resolution
<=
1
)
{
datap
=
(
char
*
)
hp
+
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
first_index
=
info
[
j
].
last_idx
;
last_index
=
hp
->
LastIndex
;
start_idx
=
last_index
-
info
[
j
].
samples
;
if
(
first_index
<
last_index
)
{
if
(
first_index
>
start_idx
)
start_idx
=
first_index
;
}
else
{
if
(
start_idx
<
0
)
{
split
=
1
;
start_idx
=
hp
->
Size
+
start_idx
;
if
(
start_idx
<
first_index
)
start_idx
=
first_index
;
}
}
if
(
split
)
{
memcpy
(
info
[
j
].
bufp
,
datap
+
start_idx
*
hp
->
ElementSize
,
(
hp
->
Size
-
start_idx
)
*
hp
->
ElementSize
);
memcpy
(
info
[
j
].
bufp
+
(
hp
->
Size
-
start_idx
)
*
hp
->
ElementSize
,
datap
,
last_index
*
hp
->
ElementSize
);
info
[
j
].
size
=
hp
->
Size
-
start_idx
+
last_index
;
}
else
{
memcpy
(
info
[
j
].
bufp
,
datap
+
start_idx
*
hp
->
ElementSize
,
(
last_index
-
start_idx
)
*
hp
->
ElementSize
);
info
[
j
].
size
=
last_index
-
start_idx
;
}
info
[
j
].
last_idx
=
last_index
;
info
[
j
].
first_idx
=
first_index
;
info
[
j
].
offset
=
0
;
}
else
{
/* Resolution > 1 */
int
elements
;
char
*
dp
;
int
i
;
int
tst_idx
;
datap
=
(
char
*
)
hp
+
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
first_index
=
hp
->
FirstIndex
;
last_index
=
hp
->
LastIndex
;
tst_idx
=
last_index
;
if
(
tst_idx
<
info
[
j
].
last_idx
)
tst_idx
+=
hp
->
Size
;
start_idx
=
info
[
j
].
last_idx
+
info
[
j
].
offset
;
if
(
start_idx
>
tst_idx
)
{
info
[
j
].
size
=
0
;
break
;
}
elements
=
(
tst_idx
-
start_idx
)
/
info
[
j
].
resolution
+
1
;
info
[
j
].
offset
=
info
[
j
].
resolution
-
(
tst_idx
-
start_idx
-
(
elements
-
1
)
*
info
[
j
].
resolution
);
if
(
start_idx
>=
hp
->
Size
)
start_idx
-=
hp
->
Size
;
if
(
elements
>
info
[
j
].
samples
)
elements
=
info
[
j
].
samples
;
info
[
j
].
size
=
elements
;
for
(
i
=
0
;
i
<
elements
;
i
++
)
{
dp
=
datap
+
start_idx
*
hp
->
ElementSize
;
memcpy
(
info
[
j
].
bufp
+
i
*
hp
->
ElementSize
,
dp
,
hp
->
ElementSize
);
// printf( "%d idx: %d %5.2f el:%d off:%d lidx: prev %d curr %d\n", i, start_idx, *(float *)dp, elements, info[j].offset, info[j].last_idx, last_index);
start_idx
+=
info
[
j
].
resolution
;
if
(
start_idx
>=
hp
->
Size
)
start_idx
-=
hp
->
Size
;
}
info
[
j
].
last_idx
=
last_index
;
info
[
j
].
first_idx
=
first_index
;
}
sts
=
GDH__SUCCESS
;
}
else
sts
=
0
;
break
;
}
gdh_Unlock
;
}
return
sts
;
}
src/lib/rt/src/rt_gdh.h
View file @
c216641b
...
...
@@ -170,6 +170,20 @@ typedef struct {
}
gdh_sBitDef
;
/**
* Circular buffer argument structure
*/
typedef
struct
{
pwr_sAttrRef
circ_aref
;
/**< Attribute reference to circular buffer object */
unsigned
int
resolution
;
/**< Resolution of return data */
unsigned
int
samples
;
/**< number of data values */
void
*
bufp
;
/**< Data buffer that receives the requested information */
unsigned
int
bufsize
;
/**< The size in bytes of the data buffer */
unsigned
int
size
;
/**< Number of returned values */
unsigned
int
first_idx
;
/**< First index, this has to be saved to the next call */
unsigned
int
last_idx
;
/**< Last index, this has to be saved to the next call */
unsigned
int
offset
;
/**< Index offset to use in the next call */
}
gdh_sCircBuffInfo
;
/* GDH entrypoints (as function prototypes). */
...
...
@@ -801,6 +815,18 @@ gdh_SetObjectReadOnly(
pwr_tOid
oid
);
pwr_tStatus
gdh_GetCircBuffInfo
(
gdh_sCircBuffInfo
*
info
,
int
infosize
);
pwr_tStatus
gdh_UpdateCircBuffInfo
(
gdh_sCircBuffInfo
*
info
,
int
infosize
);
/* Undocumented functions. For internal use only. */
pwr_tStatus
...
...
src/wbl/pwrb/src/pwrb_c_a_circbuffheader.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_a_circbuffheader.wb_load -- Defines the class CircBuffHead.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Header for circular buffer
! Header for circular buffer.
!
! This class is used as a header for a circular buffer object.
!*/
Object CircBuffHeader $ClassDef 594
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CircBuffHeader"
EndBody
!/**
! Index of the oldest elements.
!*/
Object FirstIndex $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
!/**
! Index of the last inserted element.
!*/
Object LastIndex $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_NOEDIT
EndBody
EndObject
!/**
! Maximum number of elements in the buffer.
!*/
Object Size $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Element size in bytes.
!*/
Object ElementSize $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_c_circbuff1000.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_circbuff1000.wb_load -- Defines the class CircBuff1000.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Circular buffer with buffer size 1000 byte
! Circular buffer with buffer size 1000 byte.
!*/
Object CircBuff1000 $ClassDef 595
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CircBuff1000"
EndBody
!/**
! Buffer header.
!*/
Object Head $Attribute 1
Body SysBody
Attr TypeRef = "pwrb:Class-CircBuffHeader"
Attr Flags |= PWR_MASK_CLASS
EndBody
EndObject
!/**
! Data buffer.
!*/
Object Data $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Elements = 250
EndBody
EndObject
EndObject
Object Template CircBuff1000
Body RtBody
Attr Head.Size = 250
Attr Head.ElementSize = 4
EndBody
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_c_circbuff100k.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_circbuff100k.wb_load -- Defines the class CircBuff100k.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Circular buffer with buffer size 100kB
! Circular buffer with buffer size 100kB.
!*/
Object CircBuff100k $ClassDef 598
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CircBuff100k"
EndBody
!/**
! Buffer header.
!*/
Object Head $Attribute 1
Body SysBody
Attr TypeRef = "pwrb:Class-CircBuffHeader"
Attr Flags |= PWR_MASK_CLASS
EndBody
EndObject
!/**
! Data buffer.
!*/
Object Data $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Elements = 25000
EndBody
EndObject
EndObject
Object Template CircBuff100k
Body RtBody
Attr Head.Size = 25000
Attr Head.ElementSize = 4
EndBody
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_c_circbuff10k.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_circbuff10k.wb_load -- Defines the class CircBuff10k.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Circular buffer with buffer size 10kB
! Circular buffer with buffer size 10kB.
!*/
Object CircBuff10k $ClassDef 596
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CircBuff10k"
EndBody
!/**
! Buffer header.
!*/
Object Head $Attribute 1
Body SysBody
Attr TypeRef = "pwrb:Class-CircBuffHeader"
Attr Flags |= PWR_MASK_CLASS
EndBody
EndObject
!/**
! Data buffer.
!*/
Object Data $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Elements = 2500
EndBody
EndObject
EndObject
Object Template CircBuff10k
Body RtBody
Attr Head.Size = 2500
Attr Head.ElementSize = 4
EndBody
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_c_circbuff200k.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_circbuff10k.wb_load -- Defines the class CircBuff10k.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Circular buffer with buffer size 200kB
! Circular buffer with buffer size 200kB.
!*/
Object CircBuff200k $ClassDef 599
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CircBuff200k"
EndBody
!/**
! Buffer header.
!*/
Object Head $Attribute 1
Body SysBody
Attr TypeRef = "pwrb:Class-CircBuffHeader"
Attr Flags |= PWR_MASK_CLASS
EndBody
EndObject
!/**
! Data buffer.
!*/
Object Data $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Elements = 50000
EndBody
EndObject
EndObject
Object Template CircBuff200k
Body RtBody
Attr Head.Size = 50000
Attr Head.ElementSize = 4
EndBody
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_c_circbuff20k.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_circbuff10k.wb_load -- Defines the class CircBuff10k.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Circular buffer with buffer size 20kB
! Circular buffer with buffer size 20kB.
!*/
Object CircBuff20k $ClassDef 597
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "CircBuff20k"
EndBody
!/**
! Buffer header.
!*/
Object Head $Attribute 1
Body SysBody
Attr TypeRef = "pwrb:Class-CircBuffHeader"
Attr Flags |= PWR_MASK_CLASS
EndBody
EndObject
!/**
! Data buffer.
!*/
Object Data $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Elements = 5000
EndBody
EndObject
EndObject
Object Template CircBuff20k
Body RtBody
Attr Head.Size = 5000
Attr Head.ElementSize = 4
EndBody
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_c_dstrendconf.wb_load
View file @
c216641b
...
...
@@ -81,7 +81,7 @@ SObject pwrb:Class
!*/
Object ScanTime $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$
UIn
t32"
Attr TypeRef = "pwrs:Type-$
Floa
t32"
EndBody
EndObject
EndObject
...
...
src/wbl/pwrb/src/pwrb_c_dstrendcurve.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_c_dstrendcurve.wb_load -- Defines the class DsTrendCurve.
!
SObject pwrb:Class
!/**
! @Version 1.0
! Stores data for a fast graph à la storage oscilloscope.
!
! In one DsFastCurve object, up to 10 attributes can be specified.
! The storage of the attributes will be trigger by the same event,
! stored with the same frequency, and the curves will be plotted
! in the same fastcurve window.
!
! The names of the attributes is specified the the Attribute array.
! For every attribute, a storage area object also has to be specified.
! An attribute may be referred to by several different DsTrendCurve
! objects, for example to store at different frequencies.
!
! The sampling rate is specified the the ScanTime attribute.
! The sampling will start when a trigger event is detected. In some
! cases, when data before the trigger event is valid, the sampling will
! go on even before the trigger event.
!
! @b Storage arrays
! Storage arrays has to be supplied by the user, one array for the time axis data, and
! one for each configured attribute. For example, Buff1440, Buff4096 or Buff32k objects
! can be used for the data storage. These will store up to 360, 1024 resp. 8192 points of
! pwr_tFloat32 attributes.
!
! @b Data types
! The datatypes that can be stored is
! - pwr_tFloat32, pwr_tFloat64
! - pwr_tInt32, pwr_tUInt32, pwr_tInt16, pwr_tUInt16, pwr_tInt8, pwr_tUInt8
!
! The time is stored as pwr_tFloat32.
!
! @b Server
! DsTrendCurve objects is handled by the fast server rt_trend.
! The base frequency for the fast server process is configured in
! the DsTrendConf object.
!
! @b Se also
! @classlink Buff1440 ssab_buff1440.html
! @classlink Buff4096 ssab_buff4096.html
! @classlink Buff32k ssab_buff32k.html
! @classlink DsFastConf pwrb_dsfastconf.html
!*/
Object DsTrendCurve $ClassDef 593
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "DsTrendCurve"
EndBody
!/**
! Optional text.
!*/
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Title of the trend window.
!*/
Object Title $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! @Summary Trend function.
! Bitmask for trend function.
! - UserStorage 1 Data inserted by user.
!*/
Object Function $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Mask"
Attr Flags |= PWR_MASK_BACKUP
EndBody
EndObject
!/**
! Scantime in seconds. Multiple of the base scantime configured in DsTrendConf object.
!*/
Object ScanTime $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
Attr Flags |= PWR_MASK_BACKUP
EndBody
EndObject
!/**
! Stores measurants data types. It has to be of any of
! the types pwr_tBoolean, pwr_tFloat32, pwr_tFloat64,
! pwr_tInt8, pwr_tInt16, pwr_tInt32, pwr_tUInt8,
! pwr_tUInt16, or pwr_tUInt32.
!*/
Object AttributeType $Attribute 5
Body SysBody
Attr TypeRef = "pwrs:Type-$TypeId"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_ARRAY
Attr Elements = 10
EndBody
EndObject
!/**
! The complete name of analog sampled attributes, for
! example PROC1-TEMP1.ActualValue. The attributes have to
! be represented by local objects.
!*/
Object Attribute $Attribute 6
Body SysBody
Attr TypeRef = "pwrs:Type-$AttrRef"
Attr Flags |= PWR_MASK_ARRAY
Attr Elements = 10
EndBody
EndObject
!/**
! @Summary Data buffers. Array attributes that contains the data of the curves.
! Data buffers. Array attributes that contains the data of the curves.
! Objects for the databuffers has to be configured by the user. The extent of the
! buffer attributes should equal or exceed the storeage size, i.e. the size of the
! sampled attribute's type multiplied by NoOfPoints.
!*/
Object Buffers $Attribute 7
Body SysBody
Attr TypeRef = "pwrs:Type-$AttrRef"
Attr Flags |= PWR_MASK_ARRAY
Attr Elements = 10
EndBody
EndObject
!/**
! @Summary Time buffer. An array attribute that contain the time axis data for the curves.
! Time buffer. An array attribute that contain the time axis data for the curves.
! The object for the time buffer has to be configured by the user. The extent of the
! buffer attributes should equal or exceed the storeage size for the time data.
!*/
Object TimeBuffer $Attribute 8
Body SysBody
Attr TypeRef = "pwrs:Type-$AttrRef"
EndBody
EndObject
!/**
! Resolution of time scale, seconds or nanoseconds.
! Seconds will require 4 bytes per point, and nanoseconds 8 bytes per point.
!*/
Object TimeResolution $Attribute 16
Body SysBody
Attr TypeRef = "pwrb:Type-TimeResolutionEnum"
EndBody
EndObject
!/**
! Length, in seconds, of the storage. If the time
! exceeds what is possible to store in DataBuffer, the
! storage is stopped when DataBuffer has been filled.
!*/
Object StorageTime $Attribute 9
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Length, in seconds, of the storage that is displayed
! in the trend window.
!*/
Object DisplayTime $Attribute 13
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Length, in seconds, of the storage that is displayed
! in the trend window.
!*/
Object DisplayResolution $Attribute 14
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Time between updates of the curve display in seconds.
!*/
Object DisplayUpdateTime $Attribute 15
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Number of samples.
!*/
Object NoOfSample $Attribute 10
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Specifies the first element in the data buffer with valid data.
!*/
Object FirstIndex $Attribute 11
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Specifies the last element in the data buffer with valid data.
!*/
Object LastIndex $Attribute 12
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
EndObject
Object Template DsTrendCurve
Body RtBody
Attr ScanTime = 1
Attr StorageTime = 200
Attr DisplayTime = 200
Attr DisplayResolution = 1
Attr DisplayUpdateTime = 1
EndBody
EndObject
EndObject
EndSObject
src/wbl/pwrb/src/pwrb_td_timeresolutionenum.wb_load
0 → 100644
View file @
c216641b
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2012 SSAB EMEA AB.
!
! This file is part of Proview.
!
! This program is free software; you can redistribute it and/or
! modify it under the terms of the GNU General Public License as
! published by the Free Software Foundation, either version 2 of
! the License, or (at your option) any later version.
!
! This program is distributed in the hope that it will be useful
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with Proview. If not, see <http://www.gnu.org/licenses/>
!
! Linking Proview statically or dynamically with other modules is
! making a combined work based on Proview. Thus, the terms and
! conditions of the GNU General Public License cover the whole
! combination.
!
! In addition, as a special exception, the copyright holders of
! Proview give you permission to, from the build function in the
! Proview Configurator, combine Proview with modules generated by the
! Proview PLC Editor to a PLC program, regardless of the license
! terms of these modules. You may copy and distribute the resulting
! combined work under the terms of your choice, provided that every
! copy of the combined work is accompanied by a complete copy of
! the source code of Proview (the version used to produce the
! combined work), being distributed under the terms of the GNU
! General Public License plus this exception.
!
! pwrb_td_timeresolutionenum.wb_load -- Defines the enum type TimeResolution
!
SObject pwrb:Type
!/**
! @Version 1.0
! @Group Types
! Enumeration for time resolution
!*/
Object TimeResolutionEnum $TypeDef 64
Body SysBody
Attr TypeRef = "pwrs:Type-$Enum"
Attr PgmName = "TimeResolutionEnum"
EndBody
!/**
! Second.
!*/
Object Second $Value
Body SysBody
Attr PgmName = "Second"
Attr Text = "Second"
Attr Value = 0
EndBody
EndObject
!/**
! Nanosecond.
!*/
Object Nanosecond $Value
Body SysBody
Attr PgmName = "Nanosecond"
Attr Text = "Nanosecond"
Attr Value = 1
EndBody
EndObject
EndObject
EndSObject
xtt/exe/rt_xtt/src/xtt_main.cpp
View file @
c216641b
...
...
@@ -369,11 +369,13 @@ void Xtt::activate_opengraph()
if
(
cdh_tidIsCid
(
classid
))
{
switch
(
classid
)
{
case
pwr_cClass_DsTrend
:
case
pwr_cClass_DsTrendCurve
:
// Open trend
sprintf
(
cmd
,
"open trend /name=%s /title=
\"
%s
\"
"
,
vname
,
name
);
xnav
->
command
(
cmd
);
return
;
case
pwr_cClass_DsFast
:
case
pwr_cClass_DsFastCurve
:
// Open fast
sprintf
(
cmd
,
"open fast /name=%s /title=
\"
%s
\"
"
,
vname
,
name
);
xnav
->
command
(
cmd
);
...
...
@@ -398,11 +400,13 @@ void Xtt::activate_opengraph()
switch
(
classid
)
{
case
pwr_cClass_DsTrend
:
case
pwr_cClass_DsTrendCurve
:
// Open trend
sprintf
(
cmd
,
"open trend /name=%s /title=
\"
%s
\"
"
,
vname
,
name
);
xnav
->
command
(
cmd
);
return
;
case
pwr_cClass_DsFast
:
case
pwr_cClass_DsFastCurve
:
// Open fast
sprintf
(
cmd
,
"open fast /name=%s /title=
\"
%s
\"
"
,
vname
,
name
);
xnav
->
command
(
cmd
);
...
...
xtt/lib/ge/gtk/ge_curve_gtk.cpp
View file @
c216641b
...
...
@@ -73,6 +73,8 @@ typedef struct {
}
ge_sTimeComboText
;
ge_sTimeComboText
curve_timecombo_text
[]
=
{
{
"One Second"
,
time_ePeriod_OneSecond
},
{
"10 Seconds"
,
time_ePeriod_10Seconds
},
{
"One Minute"
,
time_ePeriod_OneMinute
},
{
"10 Minutes"
,
time_ePeriod_10Minutes
},
{
"One Hour"
,
time_ePeriod_OneHour
},
...
...
@@ -308,6 +310,13 @@ void GeCurveGtk::activate_xlimits( GtkWidget *w, gpointer data)
curve
->
open_minmax
(
0
);
}
void
GeCurveGtk
::
activate_snapshot
(
GtkWidget
*
w
,
gpointer
data
)
{
GeCurve
*
curve
=
(
GeCurve
*
)
data
;
curve
->
activate_snapshot
();
}
void
GeCurveGtk
::
activate_export
(
GtkWidget
*
w
,
gpointer
data
)
{
GeCurve
*
curve
=
(
GeCurve
*
)
data
;
...
...
@@ -447,6 +456,11 @@ void GeCurveGtk::enable_export()
g_object_set
(
menu_export
,
"visible"
,
TRUE
,
NULL
);
}
void
GeCurveGtk
::
enable_snapshot
()
{
g_object_set
(
menu_snapshot
,
"visible"
,
TRUE
,
NULL
);
}
void
GeCurveGtk
::
pop
()
{
gtk_window_present
(
GTK_WINDOW
(
toplevel
));
...
...
@@ -674,6 +688,11 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
menu_export
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Export"
));
g_signal_connect
(
menu_export
,
"activate"
,
G_CALLBACK
(
activate_export
),
this
);
menu_snapshot
=
gtk_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Snapshot"
));
g_signal_connect
(
menu_snapshot
,
"activate"
,
G_CALLBACK
(
activate_snapshot
),
this
);
gtk_widget_add_accelerator
(
menu_snapshot
,
"activate"
,
accel_g
,
'n'
,
GdkModifierType
(
GDK_CONTROL_MASK
),
GTK_ACCEL_VISIBLE
);
GtkWidget
*
file_close
=
gtk_image_menu_item_new_with_mnemonic
(
CoWowGtk
::
translate_utf8
(
"_Close"
));
gtk_image_menu_item_set_image
(
GTK_IMAGE_MENU_ITEM
(
file_close
),
gtk_image_new_from_stock
(
"gtk-close"
,
GTK_ICON_SIZE_MENU
));
...
...
@@ -684,6 +703,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
GtkMenu
*
file_menu
=
(
GtkMenu
*
)
g_object_new
(
GTK_TYPE_MENU
,
NULL
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_refresh
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_print
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
menu_snapshot
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
menu_export
);
gtk_menu_shell_append
(
GTK_MENU_SHELL
(
file_menu
),
file_close
);
...
...
@@ -962,6 +982,7 @@ GeCurveGtk::GeCurveGtk( void *gc_parent_ctx,
gtk_paned_set_position
(
GTK_PANED
(
vpaned1
),
names_height
);
gtk_paned_set_position
(
GTK_PANED
(
vpaned2
),
window_height
-
names_height
-
nav_height
-
50
);
g_object_set
(
sea_timebox
,
"visible"
,
FALSE
,
NULL
);
g_object_set
(
menu_snapshot
,
"visible"
,
FALSE
,
NULL
);
g_object_set
(
menu_export
,
"visible"
,
FALSE
,
NULL
);
wow
=
new
CoWowGtk
(
toplevel
);
...
...
xtt/lib/ge/gtk/ge_curve_gtk.h
View file @
c216641b
...
...
@@ -64,6 +64,7 @@ class GeCurveGtk : public GeCurve {
GtkWidget
*
minmax_widget
;
GtkWidget
*
minmax_textmin_widget
;
GtkWidget
*
minmax_textmax_widget
;
GtkWidget
*
menu_snapshot
;
GtkWidget
*
menu_export
;
GtkWidget
*
export_widget
;
GtkWidget
*
export_attrcombo_widget
;
...
...
@@ -89,6 +90,7 @@ class GeCurveGtk : public GeCurve {
void
set_inputfocus
();
void
enable_timebox
();
void
enable_export
();
void
enable_snapshot
();
void
set_times
(
pwr_tTime
*
from
,
pwr_tTime
*
to
);
void
set_times_sensitivity
(
int
sensitive
);
pwr_tStatus
get_times
(
pwr_tTime
*
from
,
pwr_tTime
*
to
);
...
...
@@ -100,6 +102,7 @@ class GeCurveGtk : public GeCurve {
static
void
activate_exit
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_configure
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_print
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_snapshot
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_export
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoomin
(
GtkWidget
*
w
,
gpointer
data
);
static
void
activate_zoomout
(
GtkWidget
*
w
,
gpointer
data
);
...
...
xtt/lib/ge/src/ge_curve.cpp
View file @
c216641b
...
...
@@ -80,6 +80,12 @@ void GeCurve::activate_configure()
configure_axes
();
}
void
GeCurve
::
activate_snapshot
()
{
if
(
snapshot_cb
)
(
snapshot_cb
)(
parent_ctx
);
}
void
GeCurve
::
activate_export
()
{
double
ll_x
,
ll_y
,
ur_x
,
ur_y
;
...
...
@@ -1168,7 +1174,7 @@ void GeCurve::redraw()
grow_Redraw
(
growcurve_ctx
);
}
void
GeCurve
::
points_added
()
void
GeCurve
::
points_added
(
unsigned
int
no_of_points
)
{
int
i
,
idx
;
glow_sCurveData
gcd
;
...
...
@@ -1217,7 +1223,7 @@ void GeCurve::points_added()
gcd
.
rows
[
0
]
=
max_index
-
min_index
+
1
;
gcd
.
x_reverse
=
cd
->
x_reverse
;
grow_CurveAddPoints
(
curve_object
,
&
gcd
);
grow_CurveAddPoints
(
curve_object
,
&
gcd
,
no_of_points
);
// Simulate cursormotion and slidermoved event to update markvalues
glow_sEvent
e
;
...
...
@@ -1372,7 +1378,7 @@ GeCurve::GeCurve( void *gc_parent_ctx,
border_bright
(
glow_eDrawType_Color22
),
cd
(
0
),
axis_window_width
(
0
),
auto_refresh
(
1
),
axis_displayed
(
1
),
minmax_idx
(
0
),
close_cb
(
0
),
help_cb
(
0
),
increase_period_cb
(
0
),
decrease_period_cb
(
0
),
reload_cb
(
0
),
prev_period_cb
(
0
),
next_period_cb
(
0
),
add_cb
(
0
),
remove_cb
(
0
),
export_cb
(
0
),
prev_period_cb
(
0
),
next_period_cb
(
0
),
add_cb
(
0
),
remove_cb
(
0
),
export_cb
(
0
),
snapshot_cb
(
0
),
initial_right_position
(
pos_right
),
last_cursor_x
(
0
),
last_mark1_x
(
0
),
last_mark2_x
(
0
),
deferred_configure_axes
(
0
),
center_from_window
(
0
)
{
...
...
xtt/lib/ge/src/ge_curve.h
View file @
c216641b
...
...
@@ -170,6 +170,7 @@ class GeCurve {
void
(
*
add_cb
)(
void
*
);
void
(
*
remove_cb
)(
void
*
);
int
(
*
export_cb
)(
void
*
,
pwr_tTime
*
,
pwr_tTime
*
,
int
,
int
,
char
*
);
void
(
*
snapshot_cb
)(
void
*
);
int
initial_right_position
;
char
title
[
300
];
double
last_cursor_x
;
...
...
@@ -189,6 +190,7 @@ class GeCurve {
virtual
void
open_export
(
pwr_tTime
*
from
,
pwr_tTime
*
to
,
int
rows
,
char
*
filename
)
{}
virtual
void
axis_set_width
(
int
width
)
{}
virtual
void
enable_timebox
()
{}
virtual
void
enable_snapshot
()
{}
virtual
void
enable_export
()
{}
virtual
void
set_times
(
pwr_tTime
*
from
,
pwr_tTime
*
to
)
{}
virtual
void
set_times_sensitivity
(
int
sensitive
)
{}
...
...
@@ -201,7 +203,7 @@ class GeCurve {
int
configure_curves
();
int
configure_axes
();
int
config_names
();
void
points_added
();
void
points_added
(
unsigned
int
no_of_points
);
void
set_title
(
char
*
str
);
void
set_time
(
pwr_tTime
time
);
void
print
(
char
*
filename
);
...
...
@@ -209,6 +211,7 @@ class GeCurve {
void
measure_window
(
double
*
ll_x
,
double
*
ll_y
,
double
*
ur_x
,
double
*
ur_y
);
void
activate_exit
();
void
activate_configure
();
void
activate_snapshot
();
void
activate_export
();
void
activate_print
();
void
activate_background
();
...
...
xtt/lib/glow/src/glow_growapi.cpp
View file @
c216641b
...
...
@@ -4786,9 +4786,9 @@ void grow_CurveConfigure( grow_tObject object, glow_sCurveData *data)
((
GrowCurve
*
)
object
)
->
configure_curves
(
data
);
}
void
grow_CurveAddPoints
(
grow_tObject
object
,
glow_sCurveData
*
data
)
void
grow_CurveAddPoints
(
grow_tObject
object
,
glow_sCurveData
*
data
,
unsigned
int
no_of_points
)
{
((
GrowCurve
*
)
object
)
->
add_points
(
data
);
((
GrowCurve
*
)
object
)
->
add_points
(
data
,
no_of_points
);
}
int
grow_GetObjectGroup
(
grow_tCtx
ctx
,
grow_tObject
object
,
...
...
xtt/lib/glow/src/glow_growapi.h
View file @
c216641b
...
...
@@ -2677,7 +2677,7 @@ extern "C" {
Add the new value first in all the curves, and shift the other values one step forward.
*/
void
grow_CurveAddPoints
(
grow_tObject
object
,
glow_sCurveData
*
data
);
void
grow_CurveAddPoints
(
grow_tObject
object
,
glow_sCurveData
*
data
,
unsigned
int
no_of_points
);
//! Get the group the specified object is a member of.
/*!
...
...
xtt/lib/glow/src/glow_growcurve.cpp
View file @
c216641b
...
...
@@ -289,26 +289,54 @@ void GrowCurve::configure_curves( glow_sCurveData *data)
}
void
GrowCurve
::
add_points
(
glow_sCurveData
*
data
)
void
GrowCurve
::
add_points
(
glow_sCurveData
*
data
,
unsigned
int
no_of_points
)
{
if
(
data
->
type
==
glow_eCurveDataType_CommonX
)
{
int
idx
;
double
y_value
;
// Remove old curves
ctx
->
nodraw
++
;
for
(
idx
=
0
;
idx
<
curve_cnt
;
idx
++
)
{
y_value
=
ur
.
y
-
(
data
->
y_data
[
idx
][
0
]
-
y_min_value
[
idx
])
/
(
y_max_value
[
idx
]
-
y_min_value
[
idx
])
*
(
ur
.
y
-
ll
.
y
)
;
if
(
no_of_points
==
1
)
{
double
y_value
;
int
idx
;
y_value
=
max
(
ll
.
y
,
min
(
y_value
,
ur
.
y
));
for
(
idx
=
0
;
idx
<
curve_cnt
;
idx
++
)
{
y_value
=
ur
.
y
-
(
data
->
y_data
[
idx
][
0
]
-
y_min_value
[
idx
])
/
(
y_max_value
[
idx
]
-
y_min_value
[
idx
])
*
(
ur
.
y
-
ll
.
y
);
if
(
!
fill
)
erase
(
&
ctx
->
mw
);
if
(
!
fill_curve
)
curve
[
idx
]
->
add_and_shift_y_value
(
y_value
);
else
curve
[
idx
]
->
add_and_shift_y_value_filled
(
y_value
);
y_value
=
max
(
ll
.
y
,
min
(
y_value
,
ur
.
y
));
if
(
!
fill
)
erase
(
&
ctx
->
mw
);
if
(
!
fill_curve
)
curve
[
idx
]
->
add_and_shift_y_value
(
y_value
);
else
curve
[
idx
]
->
add_and_shift_y_value_filled
(
y_value
);
}
}
else
{
double
*
y_values
;
int
i
,
idx
;
for
(
idx
=
0
;
idx
<
curve_cnt
;
idx
++
)
{
y_values
=
(
double
*
)
calloc
(
1
,
no_of_points
*
sizeof
(
double
));
for
(
i
=
0
;
i
<
(
int
)
no_of_points
;
i
++
)
{
y_values
[
i
]
=
ur
.
y
-
(
data
->
y_data
[
idx
][
i
]
-
y_min_value
[
idx
])
/
(
y_max_value
[
idx
]
-
y_min_value
[
idx
])
*
(
ur
.
y
-
ll
.
y
);
y_values
[
i
]
=
max
(
ll
.
y
,
min
(
y_values
[
i
],
ur
.
y
));
}
if
(
!
fill
)
erase
(
&
ctx
->
mw
);
if
(
!
fill_curve
)
curve
[
idx
]
->
add_and_shift_y_values
(
y_values
,
no_of_points
);
else
curve
[
idx
]
->
add_and_shift_y_values_filled
(
y_values
,
no_of_points
);
free
(
(
char
*
)
y_values
);
}
}
ctx
->
nodraw
--
;
...
...
xtt/lib/glow/src/glow_growcurve.h
View file @
c216641b
...
...
@@ -96,7 +96,7 @@ class GrowCurve : public GrowTrend {
Add the new value first in all the curves, and shift the other values one step forward.
*/
void
add_points
(
glow_sCurveData
*
data
);
void
add_points
(
glow_sCurveData
*
data
,
unsigned
int
no_of_points
);
};
...
...
xtt/lib/glow/src/glow_growpolyline.cpp
View file @
c216641b
...
...
@@ -1396,6 +1396,20 @@ void GrowPolyLine::add_and_shift_y_value( double value)
nav_zoom
();
}
void
GrowPolyLine
::
add_and_shift_y_values
(
double
*
values
,
unsigned
int
no_of_values
)
{
if
(
!
no_of_values
)
return
;
for
(
unsigned
int
i
=
a_points
.
size
()
-
1
;
i
>=
no_of_values
;
i
--
)
((
GlowPoint
*
)
a_points
[
i
])
->
y
=
((
GlowPoint
*
)
a_points
[
i
-
no_of_values
])
->
y
;
for
(
unsigned
int
i
=
0
;
i
<
no_of_values
;
i
++
)
((
GlowPoint
*
)
a_points
[
i
])
->
y
=
*
(
values
+
i
);
zoom
();
nav_zoom
();
}
void
GrowPolyLine
::
add_and_shift_y_value_filled
(
double
value
)
{
for
(
int
i
=
a_points
.
size
()
-
2
;
i
>
1
;
i
--
)
...
...
@@ -1407,6 +1421,20 @@ void GrowPolyLine::add_and_shift_y_value_filled( double value)
nav_zoom
();
}
void
GrowPolyLine
::
add_and_shift_y_values_filled
(
double
*
values
,
unsigned
int
no_of_values
)
{
if
(
!
no_of_values
)
return
;
for
(
unsigned
int
i
=
a_points
.
size
()
-
2
;
i
>=
no_of_values
+
1
;
i
--
)
((
GlowPoint
*
)
a_points
[
i
])
->
y
=
((
GlowPoint
*
)
a_points
[
i
-
no_of_values
])
->
y
;
for
(
unsigned
int
i
=
0
;
i
<
no_of_values
;
i
++
)
((
GlowPoint
*
)
a_points
[
i
+
1
])
->
y
=
*
(
values
+
i
);
zoom
();
nav_zoom
();
}
void
GrowPolyLine
::
align
(
double
x
,
double
y
,
glow_eAlignDirection
direction
)
{
double
dx
,
dy
;
...
...
xtt/lib/glow/src/glow_growpolyline.h
View file @
c216641b
...
...
@@ -539,6 +539,7 @@ class GrowPolyLine : public GlowPolyLine {
is inserted in the first point. The x-value are kept intact.
*/
void
add_and_shift_y_value
(
double
value
);
void
add_and_shift_y_values
(
double
*
values
,
unsigned
int
no_of_values
);
//! Add a new y-value for the first point for a filled curve, and shift the y-values one step forward.
/*!
...
...
@@ -548,6 +549,7 @@ class GrowPolyLine : public GlowPolyLine {
is inserted in the first point. The x-value are kept intact.
*/
void
add_and_shift_y_value_filled
(
double
value
);
void
add_and_shift_y_values_filled
(
double
*
values
,
unsigned
int
no_of_values
);
void
get_ctx
(
void
**
c
)
{
*
c
=
(
void
*
)
ctx
;};
//!< Should be replace by get_ctx() !!
...
...
xtt/lib/xtt/gtk/xtt_tcurve_gtk.cpp
0 → 100644
View file @
c216641b
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <gtk/gtk.h>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "cow_wow_gtk.h"
#include "rt_xnav_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "xtt_tcurve_gtk.h"
#include "ge_curve_gtk.h"
XttTCurveGtk
::
XttTCurveGtk
(
void
*
parent_ctx
,
GtkWidget
*
parent_wid
,
const
char
*
name
,
GtkWidget
**
w
,
pwr_tAttrRef
*
xn_arefv
,
int
*
sts
)
:
XttTCurve
(
parent_ctx
,
name
,
xn_arefv
,
sts
),
parent_widget
(
parent_wid
)
{
char
title
[
250
];
strncpy
(
title
,
name
,
sizeof
(
title
));
if
(
EVEN
(
*
sts
))
// Error from XttTCurve
return
;
*
sts
=
XNAV__SUCCESS
;
curve
=
new
GeCurveGtk
(
this
,
parent_widget
,
title
,
NULL
,
gcd
,
1
);
curve
->
close_cb
=
tcurve_close_cb
;
curve
->
help_cb
=
tcurve_help_cb
;
curve
->
increase_period_cb
=
tcurve_increase_period_cb
;
curve
->
decrease_period_cb
=
tcurve_decrease_period_cb
;
curve
->
reload_cb
=
tcurve_reload_cb
;
curve
->
prev_period_cb
=
tcurve_prev_period_cb
;
curve
->
next_period_cb
=
tcurve_next_period_cb
;
curve
->
add_cb
=
tcurve_add_cb
;
curve
->
remove_cb
=
tcurve_remove_cb
;
curve
->
export_cb
=
tcurve_export_cb
;
curve
->
enable_timebox
();
curve
->
enable_export
();
wow
=
new
CoWowGtk
(
parent_widget
);
timerid
=
wow
->
timer_new
();
timerid
->
add
(
1000
,
tcurve_scan
,
this
);
}
XttTCurveGtk
::~
XttTCurveGtk
()
{
timerid
->
remove
();
delete
curve
;
}
xtt/lib/xtt/gtk/xtt_tcurve_gtk.h
0 → 100644
View file @
c216641b
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef xtt_tcurve_gtk_h
#define xtt_tcurve_gtk_h
/* xtt_tcurve_gtk.h -- TCurve curves */
#ifndef xtt_tcurve_h
# include "xtt_tcurve.h"
#endif
class
XttTCurveGtk
:
public
XttTCurve
{
public:
GtkWidget
*
parent_widget
;
//!< Parent widget.
XttTCurveGtk
(
void
*
xn_parent_ctx
,
GtkWidget
*
xn_parent_wid
,
const
char
*
xn_name
,
GtkWidget
**
w
,
pwr_tAttrRef
*
xn_arefv
,
int
*
sts
);
~
XttTCurveGtk
();
};
#endif
xtt/lib/xtt/gtk/xtt_trend_gtk.cpp
View file @
c216641b
...
...
@@ -76,6 +76,10 @@ XttTrendGtk::XttTrendGtk( void *parent_ctx,
curve
=
new
GeCurveGtk
(
this
,
parent_widget
,
name
,
NULL
,
gcd
,
1
);
curve
->
close_cb
=
trend_close_cb
;
curve
->
help_cb
=
trend_help_cb
;
curve
->
snapshot_cb
=
trend_snapshot_cb
;
if
(
trend_tid
==
pwr_cClass_DsTrendCurve
)
curve
->
enable_snapshot
();
wow
=
new
CoWowGtk
(
parent_widget
);
timerid
=
wow
->
timer_new
();
...
...
xtt/lib/xtt/gtk/xtt_xnav_gtk.cpp
View file @
c216641b
...
...
@@ -79,6 +79,7 @@ typedef void *Widget;
#include "xtt_block_gtk.h"
#include "xtt_trend_gtk.h"
#include "xtt_sevhist_gtk.h"
#include "xtt_tcurve_gtk.h"
#include "xtt_fast_gtk.h"
#include "xtt_xattone_gtk.h"
#include "xtt_clog_gtk.h"
...
...
@@ -256,6 +257,13 @@ XttSevHist *XNavGtk::xttsevhist_new( char *name, pwr_tOid *oidv, pwr_tOName *ana
return
new
XttSevHistGtk
(
this
,
parent_wid
,
name
,
&
w
,
oidv
,
anamev
,
onamev
,
sevhistobjectv
,
scctx
,
sts
);
}
XttTCurve
*
XNavGtk
::
xtttcurve_new
(
char
*
name
,
pwr_tAttrRef
*
arefv
,
pwr_tStatus
*
sts
)
{
GtkWidget
*
w
;
return
new
XttTCurveGtk
(
this
,
parent_wid
,
name
,
&
w
,
arefv
,
sts
);
}
XttFast
*
XNavGtk
::
xttfast_new
(
char
*
name
,
pwr_tAttrRef
*
objar
,
pwr_tStatus
*
sts
)
{
GtkWidget
*
w
;
...
...
xtt/lib/xtt/gtk/xtt_xnav_gtk.h
View file @
c216641b
...
...
@@ -80,6 +80,7 @@ class XNavGtk : public XNav {
XttSevHist
*
xttsevhist_new
(
char
*
name
,
pwr_tOid
*
oidv
,
pwr_tOName
*
anamev
,
pwr_tOName
*
onamev
,
bool
*
sevhistobjectv
,
sevcli_tCtx
scctx
,
pwr_tStatus
*
sts
);
XttTCurve
*
xtttcurve_new
(
char
*
name
,
pwr_tAttrRef
*
arefv
,
pwr_tStatus
*
sts
);
XttFast
*
xttfast_new
(
char
*
name
,
pwr_tAttrRef
*
objar
,
pwr_tStatus
*
sts
);
XAttOne
*
xattone_new
(
pwr_tAttrRef
*
objar
,
char
*
title
,
unsigned
int
priv
,
pwr_tStatus
*
sts
);
...
...
xtt/lib/xtt/src/xtt_c_object.cpp
View file @
c216641b
...
...
@@ -295,7 +295,9 @@ static pwr_tStatus OpenTrend( xmenu_sMenuCall *ip)
sts
=
gdh_GetAttrRefTid
(
objar
,
&
classid
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_PlotGroup
)
{
if
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_DsTrendCurve
||
classid
==
pwr_cClass_PlotGroup
)
{
sts
=
gdh_AttrrefToName
(
&
ip
->
Pointed
,
name
,
sizeof
(
name
),
cdh_mName_volumeStrict
);
if
(
EVEN
(
sts
))
return
sts
;
...
...
@@ -317,7 +319,9 @@ static pwr_tStatus OpenTrend( xmenu_sMenuCall *ip)
// Default XttGraph found
sts
=
gdh_GetAttrRefTid
(
&
deftrend
,
&
classid
);
if
(
ODD
(
sts
)
&&
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_PlotGroup
))
{
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_DsTrendCurve
||
classid
==
pwr_cClass_PlotGroup
))
{
sts
=
gdh_AttrrefToName
(
&
deftrend
,
name
,
sizeof
(
name
),
cdh_mName_volumeStrict
);
...
...
@@ -340,7 +344,8 @@ static pwr_tStatus OpenTrend( xmenu_sMenuCall *ip)
sts
=
gdh_GetObjectClass
(
child
,
&
classid
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
classid
==
pwr_cClass_DsTrend
)
{
if
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_DsTrendCurve
)
{
found
=
1
;
break
;
}
...
...
@@ -380,6 +385,7 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
switch
(
cid
)
{
case
pwr_cClass_DsTrend
:
case
pwr_cClass_DsTrendCurve
:
return
XNAV__SUCCESS
;
case
pwr_cClass_PlotGroup
:
{
sts
=
gdh_AttrrefToName
(
objar
,
name
,
sizeof
(
name
),
...
...
@@ -409,7 +415,9 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
// Default XttGraph found
sts
=
gdh_GetAttrRefTid
(
&
deftrend
,
&
classid
);
if
(
ODD
(
sts
)
&&
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_PlotGroup
))
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_DsTrendCurve
||
classid
==
pwr_cClass_PlotGroup
))
return
XNAV__SUCCESS
;
}
...
...
@@ -425,7 +433,8 @@ static pwr_tStatus OpenTrendFilter( xmenu_sMenuCall *ip)
sts
=
gdh_GetObjectClass
(
child
,
&
classid
);
if
(
EVEN
(
sts
))
return
sts
;
if
(
classid
==
pwr_cClass_DsTrend
)
if
(
classid
==
pwr_cClass_DsTrend
||
classid
==
pwr_cClass_DsTrendCurve
)
return
XNAV__SUCCESS
;
sts
=
gdh_GetNextSibling
(
child
,
&
child
);
...
...
xtt/lib/xtt/src/xtt_tcurve.cpp
0 → 100644
View file @
c216641b
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include "flow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "pwr.h"
#include "pwr_baseclasses.h"
#include "rt_gdh.h"
#include "rt_gdh_msg.h"
#include "co_cdh.h"
#include "co_time.h"
#include "co_dcli.h"
#include "cow_wow.h"
#include "rt_sev_msg.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_curvectx.h"
#include "glow_curveapi.h"
#include "xtt_xnav.h"
#include "xtt_tcurve.h"
#include "ge_curve.h"
XttTCurve
::
XttTCurve
(
void
*
parent_ctx
,
const
char
*
name
,
pwr_tAttrRef
*
xn_arefv
,
int
*
sts
)
:
xnav
(
parent_ctx
),
gcd
(
0
),
curve
(
0
),
rows
(
0
),
vsize
(
0
),
timerid
(
0
),
close_cb
(
0
),
help_cb
(
0
),
get_select_cb
(
0
),
first_scan
(
1
),
time_low_old
(
0
),
time_high_old
(
0
)
{
pwr_tTime
from
,
to
;
memset
(
&
tc
,
0
,
sizeof
(
tc
));
if
(
xn_arefv
==
0
||
xn_arefv
[
0
].
Objid
.
vid
==
0
)
{
aref_cnt
=
0
;
gcd
=
new
GeCurveData
(
curve_eDataType_DsTrend
);
return
;
}
// Count number of curves
for
(
aref_cnt
=
0
;
xn_arefv
[
aref_cnt
].
Objid
.
vid
!=
0
;
aref_cnt
++
)
;
if
(
aref_cnt
>
XTT_TCURVE_MAX
)
aref_cnt
=
XTT_TCURVE_MAX
;
memcpy
(
arefv
,
xn_arefv
,
aref_cnt
*
sizeof
(
arefv
[
0
]));
time_Period
(
time_ePeriod_OneMinute
,
&
from
,
&
to
,
0
,
0
);
if
(
aref_cnt
==
1
)
{
get_data
(
sts
,
from
,
to
);
if
(
EVEN
(
*
sts
))
return
;
}
else
{
get_multidata
(
sts
,
from
,
to
);
if
(
EVEN
(
*
sts
))
return
;
}
cdh_StrncpyCutOff
(
title
,
name
,
sizeof
(
title
),
1
);
}
XttTCurve
::~
XttTCurve
()
{
}
int
XttTCurve
::
get_data
(
pwr_tStatus
*
sts
,
pwr_tTime
from
,
pwr_tTime
to
)
{
pwr_tDeltaTime
trange
;
int
from_idx
,
to_idx
;
pwr_tDeltaTime
diff
;
pwr_tFloat32
timerange
;
int
interval
;
load_data
(
sts
,
&
arefv
[
0
]);
if
(
EVEN
(
*
sts
))
return
0
;
// Calculate interval
if
(
time_Acomp
(
&
from
,
&
tc
.
last_time
)
>
0
||
time_Acomp
(
&
to
,
&
tc
.
first_time
)
<
0
)
// No samples in this interval
return
0
;
time_Adiff
(
&
diff
,
&
tc
.
last_time
,
&
tc
.
first_time
);
timerange
=
time_DToFloat
(
0
,
&
diff
);
if
(
time_Acomp
(
&
from
,
&
tc
.
first_time
)
<
0
)
{
from
=
tc
.
first_time
;
from_idx
=
0
;
}
else
{
time_Adiff
(
&
diff
,
&
from
,
&
tc
.
first_time
);
from_idx
=
time_DToFloat
(
0
,
&
diff
)
*
tc
.
timebuf_samples
/
timerange
;
}
if
(
time_Acomp
(
&
to
,
&
tc
.
last_time
)
>=
0
)
to_idx
=
tc
.
timebuf_samples
;
else
{
time_Adiff
(
&
diff
,
&
tc
.
last_time
,
&
to
);
to_idx
=
tc
.
timebuf_samples
-
time_DToFloat
(
0
,
&
diff
)
*
tc
.
timebuf_samples
/
timerange
;
}
interval
=
(
to_idx
-
from_idx
)
/
1000
+
1
;
rows
=
(
to_idx
-
from_idx
)
/
interval
;
if
(
from_idx
+
rows
*
interval
>
tc
.
timebuf_samples
)
rows
=
(
tc
.
timebuf_samples
-
from_idx
)
/
interval
;
// Create data for time axis
gcd
=
new
GeCurveData
(
curve_eDataType_DsTrend
);
gcd
->
x_data
[
0
]
=
(
double
*
)
calloc
(
1
,
8
*
rows
);
if
(
tc
.
timeelement_size
==
4
)
{
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
gcd
->
x_data
[
0
][
i
]
=
(
double
)
(
*
((
unsigned
int
*
)
tc
.
tbuf
+
from_idx
+
i
*
interval
));
}
else
{
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
gcd
->
x_data
[
0
][
i
]
=
(
double
)(
*
((
unsigned
int
*
)
tc
.
tbuf
+
2
*
from_idx
+
2
*
i
*
interval
))
+
(
double
)
1e-9
*
(
*
((
unsigned
int
*
)
tc
.
tbuf
+
2
*
from_idx
+
2
*
i
*
interval
+
1
));
}
strcpy
(
gcd
->
x_name
,
"Time"
);
gcd
->
x_axis_type
[
0
]
=
curve_eAxis_x
;
strcpy
(
gcd
->
x_format
[
0
],
"%10t"
);
for
(
int
j
=
0
;
j
<
tc
.
bufcnt
;
j
++
)
{
strncpy
(
gcd
->
y_name
[
j
],
tc
.
name
[
j
],
sizeof
(
gcd
->
y_name
[
0
]));
gcd
->
rows
[
j
]
=
rows
;
gcd
->
y_data
[
j
]
=
(
double
*
)
calloc
(
1
,
8
*
rows
);
for
(
int
i
=
0
;
i
<
rows
;
i
++
)
{
if
(
i
>=
tc
.
buf_samples
[
j
])
break
;
switch
(
tc
.
type
[
j
])
{
case
pwr_eType_Int64
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_Int32
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_Int16
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_Int8
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_UInt64
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tUInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_UInt32
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tUInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_UInt16
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tUInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_UInt8
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tUInt32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_Float32
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tFloat32
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_Float64
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tFloat64
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
case
pwr_eType_Boolean
:
gcd
->
y_data
[
j
][
i
]
=
*
((
pwr_tBoolean
*
)
tc
.
vbuf
[
j
]
+
from_idx
+
i
*
interval
);
break
;
default:
*
sts
=
SEV__CURVETYPE
;
return
0
;
}
}
}
gcd
->
y_axis_type
[
0
]
=
curve_eAxis_y
;
gcd
->
cols
=
tc
.
bufcnt
;
gcd
->
get_borders
();
gcd
->
get_default_axis
();
if
(
to
.
tv_sec
!=
0
&&
from
.
tv_sec
!=
0
)
{
time_Adiff
(
&
trange
,
&
to
,
&
from
);
if
(
time_DToFloat
(
0
,
&
trange
)
<
600
)
strcpy
(
gcd
->
x_format
[
0
],
"%10t"
);
else
strcpy
(
gcd
->
x_format
[
0
],
"%11t"
);
}
else
strcpy
(
gcd
->
x_format
[
0
],
"%11t"
);
gcd
->
select_color
(
0
);
if
(
curve
)
{
curve
->
set_curvedata
(
gcd
);
// This will free the old gcd
curve
->
configure_curves
();
curve
->
configure_axes
();
curve
->
redraw
();
}
*
sts
=
SEV__SUCCESS
;
return
1
;
}
int
XttTCurve
::
get_multidata
(
pwr_tStatus
*
sts
,
pwr_tTime
from
,
pwr_tTime
to
)
{
#if 0
pwr_tTime *tbuf;
void *vbuf;
pwr_tDeltaTime trange;
int curve_cnt = 0;
// Create data for time axis
gcd = new GeCurveData( curve_eDataType_MultiTrend);
strcpy( gcd->x_name, "Time");
for ( int k = 0; k < aref_cnt; k++) {
if ( curve_cnt >= CURVE_MAX_COLS) {
printf("To many columns for curve class max: %d\n", CURVE_MAX_COLS);
break;
}
// TCurveObject object
int numAttributes;
get_selected_data( sts, from, to, 1000, &tbuf, &vbuf);
if ( EVEN(*sts))
return 0;
if ( rows == 0)
continue;
gcd->x_data[curve_cnt] = (double *) calloc( 1, 8 * rows);
for ( int i = 0; i < rows; i++)
gcd->x_data[curve_cnt][i] = (double)tbuf[i].tv_sec + (double)1e-9 * tbuf[i].tv_nsec;
strcpy( gcd->x_name, "Time");
gcd->x_axis_type[curve_cnt] = curve_eAxis_x;
strcpy( gcd->x_format[0], "%10t");
//todo linesize br vi kunna f frn sevcli_get_objectitemdata
int linesize = 0;
for ( int i = 0; i < numAttributes; i++) {
linesize += histattrbuf[i].size;
}
void *dataptr = vbuf;
int tmp = 0;
for ( int i = 0; i < numAttributes; i++) {
gcd->x_data[curve_cnt] = (double *) calloc( 1, 8 * rows);
for ( int j = 0; j < rows; j++)
gcd->x_data[curve_cnt][j] = (double)tbuf[j].tv_sec + (double)1e-9 * tbuf[j].tv_nsec;
strcpy( gcd->x_name, "Time");
gcd->x_axis_type[curve_cnt] = curve_eAxis_x;
strcpy( gcd->x_format[curve_cnt], "%10t");
switch ( histattrbuf[i].type ) {
case pwr_eType_Int64:
case pwr_eType_Int32:
case pwr_eType_Int16:
case pwr_eType_Int8:
case pwr_eType_UInt64:
case pwr_eType_UInt32:
case pwr_eType_UInt16:
case pwr_eType_UInt8:
case pwr_eType_Float32:
case pwr_eType_Float64:
case pwr_eType_Boolean:
break;
default:
tmp += histattrbuf[i].size;
continue;
}
if ( curve_cnt >= CURVE_MAX_COLS) {
printf("To many columns for curve class max:%d\n", CURVE_MAX_COLS);
break;
}
strcpy( gcd->y_name[curve_cnt], "todo");
gcd->y_data[curve_cnt] = (double *) calloc( 1, 8 * rows);
gcd->y_axis_type[curve_cnt] = curve_eAxis_y;
dataptr = (char *)vbuf + tmp;
for ( int j = 0; j < rows; j++) {
dataptr = ((char *)vbuf)+ j * linesize + tmp;
switch ( histattrbuf[i].type ) {
case pwr_eType_Int64:
gcd->y_data[curve_cnt][j] = *(pwr_tInt64 *)dataptr;
break;
case pwr_eType_Int32:
gcd->y_data[curve_cnt][j] = *(pwr_tInt32 *)dataptr;
break;
case pwr_eType_Int16:
gcd->y_data[curve_cnt][j] = *(pwr_tInt16 *)dataptr;
break;
case pwr_eType_Int8:
gcd->y_data[curve_cnt][j] = *(pwr_tInt8 *)dataptr;
break;
case pwr_eType_UInt64:
gcd->y_data[curve_cnt][j] = *(pwr_tUInt64 *)dataptr;
break;
case pwr_eType_UInt32:
gcd->y_data[curve_cnt][j] = *(pwr_tUInt32 *)dataptr;
break;
case pwr_eType_UInt16:
gcd->y_data[curve_cnt][j] = *(pwr_tUInt16 *)dataptr;
break;
case pwr_eType_UInt8:
gcd->y_data[curve_cnt][j] = *(pwr_tUInt8 *)dataptr;
break;
case pwr_eType_Float32:
gcd->y_data[curve_cnt][j] = *(pwr_tFloat32 *)dataptr;
break;
case pwr_eType_Float64:
gcd->y_data[curve_cnt][j] = *(pwr_tFloat64 *)dataptr;
break;
case pwr_eType_Boolean:
gcd->y_data[curve_cnt][j] = *(pwr_tBoolean *)dataptr;
break;
default:
*sts = SEV__CURVETYPE;
return 0;
}
}
tmp += histattrbuf[i].size;
gcd->y_axis_type[curve_cnt] = curve_eAxis_y;
gcd->rows[curve_cnt] = rows;
curve_cnt++;
}
free( tbuf);
free( vbuf);
free( histattrbuf);
}
}
if( curve_cnt == 0 ) {
delete gcd;
*sts = SEV__NODATATIME;
return 0;
}
gcd->cols = curve_cnt;
gcd->get_borders();
gcd->get_default_axis();
if ( to.tv_sec != 0 && from.tv_sec != 0) {
time_Adiff( &trange, &to, &from);
if ( time_DToFloat( 0, &trange) < 600)
strcpy( gcd->x_format[0], "%10t");
else
strcpy( gcd->x_format[0], "%11t");
}
else
strcpy( gcd->x_format[0], "%11t");
gcd->select_color( 0);
if ( curve) {
curve->set_curvedata( gcd); // This will free the old gcd
curve->configure_curves();
curve->configure_axes();
curve->redraw();
}
*sts = SEV__SUCCESS;
#endif
return
1
;
}
void
XttTCurve
::
curve_add
(
pwr_tAttrRef
aref
)
{
if
(
aref_cnt
==
XTT_TCURVE_MAX
)
return
;
if
(
gcd
->
type
!=
curve_eDataType_MultiTrend
)
{
// Convert to multidata
for
(
int
i
=
1
;
i
<
gcd
->
cols
;
i
++
)
{
gcd
->
rows
[
i
]
=
gcd
->
rows
[
0
];
gcd
->
x_data
[
i
]
=
(
double
*
)
calloc
(
1
,
8
*
gcd
->
rows
[
i
]);
memcpy
(
gcd
->
x_data
[
i
],
gcd
->
x_data
[
0
],
8
*
gcd
->
rows
[
i
]);
gcd
->
x_axis_type
[
i
]
=
curve_eAxis_x
;
strcpy
(
gcd
->
x_format
[
i
],
"%10t"
);
}
gcd
->
type
=
curve_eDataType_MultiTrend
;
}
arefv
[
aref_cnt
]
=
aref
;
aref_cnt
++
;
int
curve_cnt
=
gcd
->
cols
;
rows
=
0
;
gcd
->
x_data
[
curve_cnt
]
=
(
double
*
)
calloc
(
1
,
8
*
rows
);
gcd
->
x_axis_type
[
curve_cnt
]
=
curve_eAxis_x
;
strcpy
(
gcd
->
x_format
[
curve_cnt
],
"%10t"
);
strcpy
(
gcd
->
y_name
[
curve_cnt
],
""
);
gcd
->
y_data
[
curve_cnt
]
=
(
double
*
)
calloc
(
1
,
8
*
rows
);
gcd
->
cols
++
;
gcd
->
select_color
(
0
);
curve
->
config_names
();
}
void
XttTCurve
::
pop
()
{
curve
->
pop
();
}
void
XttTCurve
::
tcurve_close_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
if
(
tcurve
->
close_cb
)
(
tcurve
->
close_cb
)(
tcurve
->
xnav
,
tcurve
);
else
delete
tcurve
;
}
void
XttTCurve
::
tcurve_decrease_period_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
time_ePeriod
period
;
pwr_tStatus
sts
;
int
changed
;
sts
=
tcurve
->
curve
->
get_period
(
&
period
);
changed
=
time_PeriodZoomIn
(
&
period
);
if
(
changed
)
tcurve
->
curve
->
set_period
(
period
,
0
);
}
void
XttTCurve
::
tcurve_increase_period_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
time_ePeriod
period
;
pwr_tStatus
sts
;
int
changed
;
sts
=
tcurve
->
curve
->
get_period
(
&
period
);
changed
=
time_PeriodZoomOut
(
&
period
);
if
(
changed
)
tcurve
->
curve
->
set_period
(
period
,
0
);
}
void
XttTCurve
::
tcurve_reload_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
pwr_tTime
t_low
,
t_high
;
pwr_tStatus
sts
;
sts
=
tcurve
->
curve
->
get_times
(
&
t_low
,
&
t_high
);
if
(
EVEN
(
sts
))
{
tcurve
->
wow
->
DisplayError
(
"Time"
,
"Time syntax error"
);
return
;
}
if
(
time_Acomp
(
&
t_high
,
&
t_low
)
!=
1
)
{
tcurve
->
wow
->
DisplayError
(
"Time"
,
"Start time later than end time"
);
return
;
}
if
(
t_low
.
tv_sec
<
0
)
t_low
.
tv_sec
=
0
;
if
(
tcurve
->
aref_cnt
==
1
)
tcurve
->
get_data
(
&
sts
,
t_low
,
t_high
);
else
tcurve
->
get_multidata
(
&
sts
,
t_low
,
t_high
);
tcurve
->
time_low_old
=
0
;
tcurve
->
time_high_old
=
0
;
tcurve
->
curve
->
set_center_from_window
(
1
);
}
void
XttTCurve
::
tcurve_prev_period_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
pwr_tTime
from
,
to
,
prev_from
,
prev_to
;
pwr_tStatus
sts
;
time_ePeriod
period
;
sts
=
tcurve
->
curve
->
get_times
(
&
prev_from
,
&
prev_to
);
if
(
EVEN
(
sts
))
{
tcurve
->
wow
->
DisplayError
(
"Time"
,
"Time syntax error"
);
return
;
}
sts
=
tcurve
->
curve
->
get_period
(
&
period
);
if
(
time_Acomp
(
&
prev_to
,
&
prev_from
)
!=
1
)
{
tcurve
->
wow
->
DisplayError
(
"Time"
,
"Start time later than end time"
);
return
;
}
time_PreviousPeriod
(
period
,
&
prev_from
,
&
prev_to
,
&
from
,
&
to
);
tcurve
->
curve
->
set_times
(
&
from
,
&
to
);
int
change_period
=
1
;
switch
(
period
)
{
case
time_ePeriod_LastMinute
:
period
=
time_ePeriod_OneMinute
;
break
;
case
time_ePeriod_Last10Minutes
:
period
=
time_ePeriod_10Minutes
;
break
;
case
time_ePeriod_LastHour
:
period
=
time_ePeriod_OneHour
;
break
;
case
time_ePeriod_Today
:
period
=
time_ePeriod_Yesterday
;
break
;
case
time_ePeriod_Yesterday
:
period
=
time_ePeriod_OneDay
;
break
;
case
time_ePeriod_ThisWeek
:
period
=
time_ePeriod_LastWeek
;
break
;
case
time_ePeriod_LastWeek
:
period
=
time_ePeriod_OneWeek
;
break
;
case
time_ePeriod_ThisMonth
:
period
=
time_ePeriod_LastMonth
;
break
;
case
time_ePeriod_LastMonth
:
period
=
time_ePeriod_OneMonth
;
break
;
case
time_ePeriod_ThisYear
:
period
=
time_ePeriod_OneYear
;
break
;
default:
change_period
=
0
;
}
if
(
change_period
)
tcurve
->
curve
->
set_period
(
period
,
1
);
}
void
XttTCurve
::
tcurve_next_period_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
pwr_tTime
from
,
to
,
prev_from
,
prev_to
;
pwr_tStatus
sts
;
time_ePeriod
period
;
sts
=
tcurve
->
curve
->
get_times
(
&
prev_from
,
&
prev_to
);
if
(
EVEN
(
sts
))
{
tcurve
->
wow
->
DisplayError
(
"Time"
,
"Time syntax error"
);
return
;
}
sts
=
tcurve
->
curve
->
get_period
(
&
period
);
if
(
time_Acomp
(
&
prev_to
,
&
prev_from
)
!=
1
)
{
tcurve
->
wow
->
DisplayError
(
"Time"
,
"Start time later than end time"
);
return
;
}
time_NextPeriod
(
period
,
&
prev_from
,
&
prev_to
,
&
from
,
&
to
);
tcurve
->
curve
->
set_times
(
&
from
,
&
to
);
}
void
XttTCurve
::
tcurve_add_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
pwr_tOid
oid
;
pwr_tOName
aname
,
oname
;
int
sts
;
if
(
!
tcurve
->
get_select_cb
)
return
;
sts
=
tcurve
->
get_select_cb
(
tcurve
->
xnav
,
&
oid
,
aname
,
oname
);
if
(
EVEN
(
sts
))
return
;
pwr_tAttrRef
aref
=
cdh_ObjidToAref
(
oid
);
tcurve
->
curve_add
(
aref
);
}
void
XttTCurve
::
tcurve_remove_cb
(
void
*
ctx
)
{
// Do do
}
int
XttTCurve
::
tcurve_export_cb
(
void
*
ctx
,
pwr_tTime
*
from
,
pwr_tTime
*
to
,
int
rows
,
int
idx
,
char
*
filename
)
{
#if 0
XttTCurve *tcurve = (XttTCurve *) ctx;
pwr_tFileName fname;
pwr_tTime *tbuf;
void *vbuf;
pwr_eType vtype;
unsigned int vsize;
pwr_tStatus sts;
int rrows;
char timestr[40];
FILE *fp;
dcli_translate_filename( fname, filename);
sevcli_get_itemdata( &sts, tcurve->scctx, tcurve->oidv[idx], tcurve->anamev[idx], *from, *to,
rows, &tbuf, &vbuf, &rrows, &vtype, &vsize);
if ( EVEN(sts))
return sts;
if( rrows == 0 ) {
return SEV__NODATATIME;
}
fp = fopen( fname, "w");
if ( !fp)
return SEV__EXPORTFILE;
for ( int i = 0; i < rrows; i++) {
time_AtoAscii( &tbuf[i], time_eFormat_DateAndTime, timestr, sizeof(timestr));
fprintf( fp, "%s, ", timestr);
switch ( vtype) {
case pwr_eType_Int32:
case pwr_eType_Int64:
case pwr_eType_Int16:
case pwr_eType_Int8:
fprintf( fp, "%d", ((pwr_tInt32 *)vbuf)[i]);
break;
case pwr_eType_UInt64:
case pwr_eType_UInt32:
case pwr_eType_UInt16:
case pwr_eType_UInt8:
fprintf( fp, "%u", ((pwr_tUInt32 *)vbuf)[i]);
break;
case pwr_eType_Float32:
fprintf( fp, "%g", ((pwr_tFloat32 *)vbuf)[i]);
break;
case pwr_eType_Float64:
fprintf( fp, "%g", ((pwr_tFloat64 *)vbuf)[i]);
break;
case pwr_eType_Boolean:
fprintf( fp, "%d", ((pwr_tBoolean *)vbuf)[i]);
break;
default:
sts = SEV__CURVETYPE;
}
fprintf( fp, "\n");
}
free( tbuf);
free( vbuf);
fclose( fp);
printf( "Exported %d rows to file \"%s\" (%d)\n", rrows, fname, idx);
if ( EVEN(sts))
return sts;
#endif
return
SEV__SUCCESS
;
}
void
XttTCurve
::
tcurve_help_cb
(
void
*
ctx
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
ctx
;
if
(
tcurve
->
help_cb
)
(
tcurve
->
help_cb
)(
tcurve
->
xnav
,
"opg_trendbuffer"
);
}
void
XttTCurve
::
tcurve_scan
(
void
*
data
)
{
XttTCurve
*
tcurve
=
(
XttTCurve
*
)
data
;
if
(
tcurve
->
timerid
)
tcurve
->
timerid
->
add
(
1000
,
tcurve_scan
,
tcurve
);
}
int
XttTCurve
::
load_data
(
pwr_tStatus
*
sts
,
pwr_tAttrRef
*
aref
)
{
pwr_tTid
tid
;
if
(
tc
.
vbuf
[
0
]
==
0
)
{
// Fetch buffer data
*
sts
=
gdh_GetAttrRefTid
(
aref
,
&
tid
);
if
(
EVEN
(
*
sts
))
return
0
;
switch
(
tid
)
{
case
pwr_cClass_DsTrendCurve
:
{
pwr_sClass_DsTrendCurve
trend
;
pwr_sClass_CircBuffHeader
head
;
pwr_tAttrRef
head_aref
;
int
idx
;
int
first_idx
;
int
last_idx
;
int
size
;
char
*
tb
;
char
*
vb
[
10
];
int
header_size
=
pwr_AlignLW
(
sizeof
(
pwr_sClass_CircBuffHeader
));
*
sts
=
gdh_GetObjectInfoAttrref
(
aref
,
&
trend
,
sizeof
(
trend
));
if
(
EVEN
(
*
sts
))
return
0
;
idx
=
0
;
for
(
int
j
=
0
;
j
<
10
;
j
++
)
{
if
(
cdh_ObjidIsNull
(
trend
.
Buffers
[
j
].
Objid
))
continue
;
*
sts
=
gdh_AttrrefToName
(
&
trend
.
Attribute
[
j
],
tc
.
name
[
idx
],
sizeof
(
tc
.
name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
0
;
tc
.
buf_aref
[
idx
]
=
trend
.
Buffers
[
j
];
tc
.
time_resolution
=
trend
.
TimeResolution
;
*
sts
=
gdh_ArefANameToAref
(
&
tc
.
buf_aref
[
idx
],
"Head"
,
&
head_aref
);
if
(
EVEN
(
*
sts
))
continue
;
*
sts
=
gdh_GetObjectInfoAttrref
(
&
head_aref
,
&
head
,
sizeof
(
head
));
if
(
EVEN
(
*
sts
))
return
0
;
tc
.
buf_size
[
idx
]
=
head
.
Size
;
tc
.
element_size
[
idx
]
=
head
.
ElementSize
;
tc
.
type
[
idx
]
=
(
pwr_eType
)
trend
.
AttributeType
[
j
];
tc
.
buf_bsize
[
idx
]
=
tc
.
buf_size
[
idx
]
*
head
.
ElementSize
+
header_size
;
vb
[
idx
]
=
(
char
*
)
calloc
(
1
,
tc
.
buf_bsize
[
idx
]);
idx
++
;
}
tc
.
bufcnt
=
idx
;
if
(
idx
==
0
)
return
0
;
// Time buffer
if
(
cdh_ObjidIsNull
(
trend
.
TimeBuffer
.
Objid
))
return
0
;
tc
.
timebuf_aref
=
trend
.
TimeBuffer
;
*
sts
=
gdh_ArefANameToAref
(
&
tc
.
timebuf_aref
,
"Head"
,
&
head_aref
);
if
(
EVEN
(
*
sts
))
return
0
;
*
sts
=
gdh_GetObjectInfoAttrref
(
&
head_aref
,
&
head
,
sizeof
(
head
));
if
(
EVEN
(
*
sts
))
return
0
;
tc
.
timebuf_size
=
head
.
Size
;
tc
.
timeelement_size
=
head
.
ElementSize
;
tc
.
timebuf_bsize
=
tc
.
timebuf_size
*
head
.
ElementSize
+
header_size
;
tb
=
(
char
*
)
calloc
(
1
,
tc
.
timebuf_bsize
);
// Get buffer data
for
(
int
j
=
0
;
j
<
tc
.
bufcnt
;
j
++
)
{
*
sts
=
gdh_GetObjectInfoAttrref
(
&
tc
.
buf_aref
[
j
],
vb
[
j
],
tc
.
buf_bsize
[
j
]);
if
(
EVEN
(
*
sts
))
return
0
;
}
*
sts
=
gdh_GetObjectInfoAttrref
(
&
tc
.
timebuf_aref
,
tb
,
tc
.
timebuf_bsize
);
if
(
EVEN
(
*
sts
))
return
0
;
// TODO, Check size and first/last index
last_idx
=
((
pwr_sClass_CircBuffHeader
*
)
tb
)
->
LastIndex
;
first_idx
=
((
pwr_sClass_CircBuffHeader
*
)
tb
)
->
FirstIndex
;
tc
.
first_time
.
tv_sec
=
*
(
unsigned
int
*
)
(
tb
+
header_size
+
tc
.
timeelement_size
*
first_idx
);
tc
.
last_time
.
tv_sec
=
*
(
unsigned
int
*
)
(
tb
+
header_size
+
tc
.
timeelement_size
*
last_idx
);
if
(
tc
.
timeelement_size
==
8
)
{
tc
.
first_time
.
tv_nsec
=
*
(
unsigned
int
*
)
(
tb
+
header_size
+
tc
.
timeelement_size
*
first_idx
+
4
);
tc
.
last_time
.
tv_nsec
=
*
(
unsigned
int
*
)
(
tb
+
header_size
+
tc
.
timeelement_size
*
last_idx
+
4
);
}
else
{
tc
.
first_time
.
tv_nsec
=
0
;
tc
.
last_time
.
tv_nsec
=
0
;
}
if
(
first_idx
==
last_idx
)
return
0
;
if
(
first_idx
<
last_idx
)
{
size
=
last_idx
-
first_idx
+
1
;
tc
.
tbuf
=
(
char
*
)
calloc
(
size
,
tc
.
timeelement_size
);
memcpy
(
tc
.
tbuf
,
tb
+
header_size
+
tc
.
timeelement_size
*
first_idx
,
size
*
tc
.
timeelement_size
);
}
else
{
size
=
last_idx
+
1
+
(
tc
.
timebuf_size
-
first_idx
);
tc
.
tbuf
=
(
char
*
)
calloc
(
size
,
tc
.
timeelement_size
);
memcpy
(
tc
.
tbuf
,
tb
+
header_size
+
tc
.
timeelement_size
*
first_idx
,
(
tc
.
timebuf_size
-
first_idx
)
*
tc
.
timeelement_size
);
memcpy
(
tc
.
tbuf
+
(
tc
.
timebuf_size
-
first_idx
)
*
tc
.
timeelement_size
,
tb
+
header_size
,
first_idx
*
tc
.
timeelement_size
);
}
tc
.
timebuf_samples
=
size
;
for
(
int
j
=
0
;
j
<
tc
.
bufcnt
;
j
++
)
{
last_idx
=
((
pwr_sClass_CircBuffHeader
*
)
vb
[
j
])
->
LastIndex
;
first_idx
=
((
pwr_sClass_CircBuffHeader
*
)
vb
[
j
])
->
FirstIndex
;
if
(
first_idx
==
last_idx
)
return
0
;
if
(
first_idx
<
last_idx
)
{
size
=
last_idx
-
first_idx
+
1
;
tc
.
vbuf
[
j
]
=
(
char
*
)
calloc
(
size
,
tc
.
element_size
[
j
]);
memcpy
(
tc
.
vbuf
[
j
],
vb
[
j
]
+
header_size
+
tc
.
element_size
[
j
]
*
first_idx
,
size
*
tc
.
element_size
[
j
]);
}
else
{
size
=
last_idx
+
1
+
(
tc
.
buf_size
[
j
]
-
first_idx
);
tc
.
vbuf
[
j
]
=
(
char
*
)
calloc
(
size
,
tc
.
element_size
[
j
]);
memcpy
(
tc
.
vbuf
[
j
],
vb
[
j
]
+
header_size
+
tc
.
element_size
[
j
]
*
first_idx
,
(
tc
.
buf_size
[
j
]
-
first_idx
)
*
tc
.
element_size
[
j
]);
memcpy
(
tc
.
vbuf
[
j
]
+
(
tc
.
buf_size
[
j
]
-
first_idx
)
*
tc
.
element_size
[
j
],
vb
[
j
]
+
header_size
,
first_idx
*
tc
.
element_size
[
j
]);
}
tc
.
buf_samples
[
j
]
=
size
;
}
free
(
tb
);
for
(
int
j
=
0
;
j
<
tc
.
bufcnt
;
j
++
)
free
(
vb
[
j
]);
break
;
}
default:
return
0
;
}
}
return
1
;
}
xtt/lib/xtt/src/xtt_tcurve.h
0 → 100644
View file @
c216641b
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2012 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#ifndef xtt_tcurve_h
#define xtt_tcurve_h
/* xtt_tcurve.h -- Tcurve curves */
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef ge_curve_h
# include "ge_curve.h"
#endif
#ifndef rt_sevcli_h
# include "rt_sevcli.h"
#endif
/*! \file xtt_tcurve.h
\brief Contains the XttTCurve class. */
/*! \addtogroup Xtt */
/*@{*/
#define XTT_TCURVE_MAX 20
class
CoWow
;
class
CoWowTimer
;
typedef
struct
{
pwr_tAName
name
[
10
];
pwr_tAttrRef
buf_aref
[
10
];
pwr_tAttrRef
timebuf_aref
;
int
element_size
[
10
];
pwr_eType
type
[
10
];
int
buf_size
[
10
];
int
buf_bsize
[
10
];
int
buf_samples
[
10
];
char
*
vbuf
[
10
];
int
bufcnt
;
int
timeelement_size
;
int
timebuf_size
;
int
timebuf_bsize
;
int
timebuf_samples
;
int
time_resolution
;
pwr_tTime
first_time
;
pwr_tTime
last_time
;
char
*
tbuf
;
}
tcurve_sTc
;
//! Window that displays tcurve curve in a TCurve object.
/*!
A TCurveCurve references a data array for the time axis, and up to 10 data arrays
with stored data. These arrays are displayed in the XttTCurve window. The measurement
of these curves are triggered manually, on a digital signal, or on a level of one of
the attributes. When the measurement is completed this is signaled with the New attribute
in the TCurveCurve object. The XttTCurve window then has to read the new data and
reconfigure the curves. XttTCurve uses the GeCurve class to display the curves.
*/
class
XttTCurve
{
public:
void
*
xnav
;
//!< Pointer to parent XNav.
GeCurveData
*
gcd
;
//!< Curve data for GeCurve object.
GeCurve
*
curve
;
//!< Curve window.
int
rows
;
//!< Max number of points in curves.
pwr_eType
vtype
;
unsigned
int
vsize
;
CoWowTimer
*
timerid
;
//!< Time id for scan.
void
(
*
close_cb
)(
void
*
,
XttTCurve
*
);
//!< Close callback to parent.
void
(
*
help_cb
)(
void
*
,
const
char
*
);
//!< Open help window.
int
(
*
get_select_cb
)(
void
*
,
pwr_tOid
*
,
char
*
,
char
*
);
//!< Get selected TCurve object.
bool
first_scan
;
//!< Indicates that this is the first scan.
char
title
[
250
];
//!< Window title
pwr_tAttrRef
arefv
[
XTT_TCURVE_MAX
];
int
aref_cnt
;
CoWow
*
wow
;
long
int
time_low_old
;
long
int
time_high_old
;
tcurve_sTc
tc
;
//! Constructor
XttTCurve
(
void
*
xn_parent_ctx
,
const
char
*
xn_name
,
pwr_tAttrRef
*
xn_arefv
,
int
*
sts
);
//! Destructor
virtual
~
XttTCurve
();
//! Pop tcurve window.
void
pop
();
int
get_data
(
pwr_tStatus
*
sts
,
pwr_tTime
from
,
pwr_tTime
to
);
int
get_multidata
(
pwr_tStatus
*
sts
,
pwr_tTime
from
,
pwr_tTime
to
);
void
curve_add
(
pwr_tAttrRef
aref
);
int
load_data
(
pwr_tStatus
*
sts
,
pwr_tAttrRef
*
aref
);
static
void
tcurve_close_cb
(
void
*
ctx
);
static
void
tcurve_increase_period_cb
(
void
*
ctx
);
static
void
tcurve_decrease_period_cb
(
void
*
ctx
);
static
void
tcurve_reload_cb
(
void
*
ctx
);
static
void
tcurve_prev_period_cb
(
void
*
ctx
);
static
void
tcurve_next_period_cb
(
void
*
ctx
);
static
void
tcurve_add_cb
(
void
*
ctx
);
static
void
tcurve_remove_cb
(
void
*
ctx
);
static
int
tcurve_export_cb
(
void
*
ctx
,
pwr_tTime
*
from
,
pwr_tTime
*
to
,
int
rows
,
int
idx
,
char
*
filename
);
static
void
tcurve_help_cb
(
void
*
ctx
);
static
void
tcurve_scan
(
void
*
data
);
};
/*@}*/
#endif
xtt/lib/xtt/src/xtt_trend.cpp
View file @
c216641b
...
...
@@ -66,24 +66,25 @@ XttTrend::XttTrend( void *parent_ctx,
pwr_sAttrRef
*
trend_list
,
pwr_sAttrRef
*
plotgroup
,
int
*
sts
)
:
xnav
(
parent_ctx
),
trend_cnt
(
0
),
close_cb
(
0
),
help
_cb
(
0
)
xnav
(
parent_ctx
),
trend_cnt
(
0
),
update_time
(
1000
),
close_cb
(
0
),
help_cb
(
0
),
command
_cb
(
0
)
{
pwr_sAttrRef
*
aref_list
;
pwr_sAttrRef
*
aref_p
;
pwr_sAttrRef
plot_trends
[
XTT_TREND_MAX
];
pwr_sClass_PlotGroup
plot
;
pwr_tAName
trend_name
[
XTT_TREND_MAX
];
pwr_tAName
object_name
[
XTT_TREND_MAX
];
pwr_sClass_DsTrend
tp
[
XTT_TREND_MAX
];
pwr_tAName
plot_name
;
int
i
,
j
,
k
;
int
start_idx
;
int
time
;
pwr_tTid
tid
;
int
trend_buff_size
=
(
int
)
sizeof
(
trend_p
[
0
]
->
DataBuffer
)
/
sizeof
(
trend_p
[
0
]
->
DataBuffer
[
0
]);
*
sts
=
XNAV__SUCCESS
;
memset
(
cb_info
,
0
,
sizeof
(
cb_info
));
if
(
trend_list
)
{
// List of trend objects as input
...
...
@@ -107,122 +108,130 @@ XttTrend::XttTrend( void *parent_ctx,
aref_list
=
plot_trends
;
}
// Get current status of the trend objects
i
=
0
;
aref_p
=
aref_list
;
while
(
cdh_ObjidIsNotNull
(
aref_p
->
Objid
))
{
*
sts
=
gdh_AttrrefToName
(
aref_p
,
trend_name
[
i
],
sizeof
(
trend_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
*
sts
=
gdh_GetObjectInfo
(
trend_name
[
i
],
&
tp
[
i
],
sizeof
(
tp
[
0
]));
for
(
aref_p
=
aref_list
;
cdh_ObjidIsNotNull
(
aref_p
->
Objid
);
aref_p
++
)
{
*
sts
=
gdh_GetAttrRefTid
(
aref_p
,
&
tid
);
if
(
EVEN
(
*
sts
))
return
;
*
sts
=
gdh_AttrrefToName
(
&
tp
[
i
].
DataName
,
object_name
[
i
],
sizeof
(
object_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
i
++
;
aref_p
++
;
trend_tid
=
tid
;
}
trend_cnt
=
i
;
if
(
trend_cnt
==
0
)
{
*
sts
=
XNAV__TRENDCONFIG
;
return
;
}
// Calculate number of points
max_time
=
0
;
min_interval
=
100000
;
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
time
=
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
*
tp
[
i
].
NoOfBuffers
*
tp
[
i
].
NoOfSample
;
if
(
time
>
max_time
)
max_time
=
time
;
if
(
(
int
)
(
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
)
<
min_interval
)
{
min_interval
=
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
;
min_interval_idx
=
i
;
if
(
trend_tid
==
pwr_cClass_DsTrend
)
{
// Get current status of the trend objects
i
=
0
;
aref_p
=
aref_list
;
while
(
cdh_ObjidIsNotNull
(
aref_p
->
Objid
))
{
*
sts
=
gdh_AttrrefToName
(
aref_p
,
trend_name
[
i
],
sizeof
(
trend_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
*
sts
=
gdh_GetObjectInfo
(
trend_name
[
i
],
&
tp
[
i
],
sizeof
(
tp
[
0
]));
if
(
EVEN
(
*
sts
))
return
;
*
sts
=
gdh_AttrrefToName
(
&
tp
[
i
].
DataName
,
object_name
[
i
],
sizeof
(
object_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
i
++
;
aref_p
++
;
}
}
if
(
min_interval
==
0
)
{
*
sts
=
XNAV__TRENDCONFIG
;
return
;
}
trend_cnt
=
i
;
max_points
=
max_time
/
min_interval
;
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
interval
[
i
]
=
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
/
min_interval
;
}
// Create data for time axis
gcd
=
new
GeCurveData
(
curve_eDataType_DsTrend
);
gcd
->
x_data
[
0
]
=
(
double
*
)
malloc
(
8
*
max_points
);
strcpy
(
gcd
->
x_name
,
"Time"
);
for
(
j
=
0
;
j
<
max_points
;
j
++
)
{
gcd
->
x_data
[
0
][
j
]
=
double
(
j
*
min_interval
);
}
gcd
->
x_axis_type
[
0
]
=
curve_eAxis_x
;
if
(
trend_cnt
==
0
)
{
*
sts
=
XNAV__TRENDCONFIG
;
return
;
}
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
gcd
->
y_data
[
i
]
=
(
double
*
)
calloc
(
1
,
8
*
max_points
);
// Calculate number of points
max_time
=
0
;
min_interval
=
100000
;
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
time
=
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
*
tp
[
i
].
NoOfBuffers
*
tp
[
i
].
NoOfSample
;
if
(
time
>
max_time
)
max_time
=
time
;
if
(
(
int
)
(
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
)
<
min_interval
)
{
min_interval
=
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
;
min_interval_idx
=
i
;
}
}
int
write_buffer
=
(
int
)
tp
[
i
].
WriteBuffer
;
start_idx
=
write_buffer
*
trend_buff_size
/
2
+
int
(
tp
[
i
].
NextWriteIndex
[
write_buffer
]);
if
(
start_idx
==
0
)
{
start_idx
=
tp
[
i
].
NoOfSample
-
1
+
trend_buff_size
/
2
;
write_buffer
=
1
;
if
(
min_interval
==
0
)
{
*
sts
=
XNAV__TRENDCONFIG
;
return
;
}
else
if
(
start_idx
==
trend_buff_size
/
2
)
{
start_idx
=
tp
[
i
].
NoOfSample
-
1
;
write_buffer
=
0
;
max_points
=
max_time
/
min_interval
;
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
interval
[
i
]
=
tp
[
i
].
Multiple
*
tp
[
i
].
ScanTime
/
min_interval
;
}
else
start_idx
--
;
int
idx
=
0
;
for
(
j
=
start_idx
;
j
>=
write_buffer
*
trend_buff_size
/
2
;
j
--
)
{
for
(
k
=
0
;
k
<
interval
[
i
];
k
++
)
{
gcd
->
y_data
[
i
][
idx
]
=
tp
[
i
].
DataBuffer
[
j
];
idx
++
;
}
// Create data for time axis
gcd
=
new
GeCurveData
(
curve_eDataType_DsTrend
);
gcd
->
x_data
[
0
]
=
(
double
*
)
malloc
(
8
*
max_points
);
strcpy
(
gcd
->
x_name
,
"Time"
);
for
(
j
=
0
;
j
<
max_points
;
j
++
)
{
gcd
->
x_data
[
0
][
j
]
=
double
(
j
*
min_interval
);
}
for
(
j
=
tp
[
i
].
NoOfSample
-
1
+
(
!
write_buffer
)
*
trend_buff_size
/
2
;
j
>=
(
!
write_buffer
)
*
trend_buff_size
/
2
;
j
--
)
{
for
(
k
=
0
;
k
<
interval
[
i
];
k
++
)
{
gcd
->
y_data
[
i
][
idx
]
=
tp
[
i
].
DataBuffer
[
j
];
idx
++
;
gcd
->
x_axis_type
[
0
]
=
curve_eAxis_x
;
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
gcd
->
y_data
[
i
]
=
(
double
*
)
calloc
(
1
,
8
*
max_points
);
int
write_buffer
=
(
int
)
tp
[
i
].
WriteBuffer
;
start_idx
=
write_buffer
*
trend_buff_size
/
2
+
int
(
tp
[
i
].
NextWriteIndex
[
write_buffer
]);
if
(
start_idx
==
0
)
{
start_idx
=
tp
[
i
].
NoOfSample
-
1
+
trend_buff_size
/
2
;
write_buffer
=
1
;
}
}
if
(
start_idx
!=
(
int
)
tp
[
i
].
NoOfSample
-
1
+
write_buffer
*
trend_buff_size
/
2
)
{
for
(
j
=
tp
[
i
].
NoOfSample
-
1
+
write_buffer
*
trend_buff_size
/
2
;
j
>
start_idx
;
j
--
)
{
for
(
k
=
0
;
k
<
interval
[
i
];
k
++
)
{
gcd
->
y_data
[
i
][
idx
]
=
tp
[
i
].
DataBuffer
[
j
];
idx
++
;
}
else
if
(
start_idx
==
trend_buff_size
/
2
)
{
start_idx
=
tp
[
i
].
NoOfSample
-
1
;
write_buffer
=
0
;
}
else
start_idx
--
;
int
idx
=
0
;
for
(
j
=
start_idx
;
j
>=
write_buffer
*
trend_buff_size
/
2
;
j
--
)
{
for
(
k
=
0
;
k
<
interval
[
i
];
k
++
)
{
gcd
->
y_data
[
i
][
idx
]
=
tp
[
i
].
DataBuffer
[
j
];
idx
++
;
}
}
for
(
j
=
tp
[
i
].
NoOfSample
-
1
+
(
!
write_buffer
)
*
trend_buff_size
/
2
;
j
>=
(
!
write_buffer
)
*
trend_buff_size
/
2
;
j
--
)
{
for
(
k
=
0
;
k
<
interval
[
i
];
k
++
)
{
gcd
->
y_data
[
i
][
idx
]
=
tp
[
i
].
DataBuffer
[
j
];
idx
++
;
}
}
if
(
start_idx
!=
(
int
)
tp
[
i
].
NoOfSample
-
1
+
write_buffer
*
trend_buff_size
/
2
)
{
for
(
j
=
tp
[
i
].
NoOfSample
-
1
+
write_buffer
*
trend_buff_size
/
2
;
j
>
start_idx
;
j
--
)
{
for
(
k
=
0
;
k
<
interval
[
i
];
k
++
)
{
gcd
->
y_data
[
i
][
idx
]
=
tp
[
i
].
DataBuffer
[
j
];
idx
++
;
}
}
}
last_buffer
[
i
]
=
tp
[
i
].
WriteBuffer
;
last_next_index
[
i
]
=
tp
[
i
].
NextWriteIndex
[
last_buffer
[
i
]];
gcd
->
y_axis_type
[
i
]
=
curve_eAxis_y
;
}
last_buffer
[
i
]
=
tp
[
i
].
WriteBuffer
;
last_next_index
[
i
]
=
tp
[
i
].
NextWriteIndex
[
last_buffer
[
i
]];
gcd
->
y_axis_type
[
i
]
=
curve_eAxis_y
;
}
// Subscribe to object
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
*
sts
=
gdh_RefObjectInfo
(
trend_name
[
i
],
(
pwr_tAddress
*
)
&
trend_p
[
i
],
&
subid
[
i
],
sizeof
(
pwr_sClass_DsTrend
));
if
(
EVEN
(
*
sts
))
return
;
strcpy
(
gcd
->
y_name
[
i
],
object_name
[
i
]);
switch
(
trend_p
[
i
]
->
DataType
)
{
// Subscribe to object
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
*
sts
=
gdh_RefObjectInfo
(
trend_name
[
i
],
(
pwr_tAddress
*
)
&
trend_p
[
i
],
&
subid
[
i
],
sizeof
(
pwr_sClass_DsTrend
));
if
(
EVEN
(
*
sts
))
return
;
strcpy
(
gcd
->
y_name
[
i
],
object_name
[
i
]);
switch
(
trend_p
[
i
]
->
DataType
)
{
case
pwr_eType_Float32
:
case
pwr_eType_Int32
:
case
pwr_eType_UInt32
:
...
...
@@ -243,31 +252,189 @@ XttTrend::XttTrend( void *parent_ctx,
break
;
default:
element_size
[
i
]
=
4
;
}
gcd
->
rows
[
i
]
=
max_points
;
}
gcd
->
cols
=
trend_cnt
;
gcd
->
x_reverse
=
1
;
gcd
->
get_borders
();
gcd
->
get_default_axis
();
gcd
->
select_color
(
0
);
if
(
!
trend_list
)
{
// Use axis values from plotgroup object
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
if
(
plot
.
YMinValue
[
i
]
!=
plot
.
YMaxValue
[
i
])
gcd
->
scale
(
gcd
->
y_axis_type
[
i
],
gcd
->
y_value_type
[
i
],
plot
.
YMinValue
[
i
],
plot
.
YMaxValue
[
i
],
&
gcd
->
y_min_value_axis
[
i
],
&
gcd
->
y_max_value_axis
[
i
],
&
gcd
->
y_trend_lines
[
i
],
&
gcd
->
y_axis_lines
[
i
],
&
gcd
->
y_axis_linelongq
[
i
],
&
gcd
->
y_axis_valueq
[
i
],
gcd
->
y_format
[
i
],
&
gcd
->
y_axis_width
[
i
],
1
,
1
);
}
}
gcd
->
rows
[
i
]
=
max_points
;
}
gcd
->
cols
=
trend_cnt
;
gcd
->
x_reverse
=
1
;
gcd
->
get_borders
();
gcd
->
get_default_axis
();
gcd
->
select_color
(
0
);
if
(
!
trend_list
)
{
// Use axis values from plotgroup object
else
if
(
trend_tid
==
pwr_cClass_DsTrendCurve
)
{
pwr_sClass_DsTrendCurve
tcp
[
XTT_TREND_MAX
];
unsigned
int
actual_data_size
[
XTT_TREND_MAX
];
double
fmin_interval
;
int
tcp_i
;
// Get current status of the trend objects
i
=
0
;
tcp_i
=
0
;
max_points
=
0
;
for
(
aref_p
=
aref_list
;
cdh_ObjidIsNotNull
(
aref_p
->
Objid
);
aref_p
++
)
{
*
sts
=
gdh_AttrrefToName
(
aref_p
,
trend_name
[
i
],
sizeof
(
trend_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
*
sts
=
gdh_GetObjectInfo
(
trend_name
[
i
],
&
tcp
[
tcp_i
],
sizeof
(
tcp
[
0
]));
if
(
EVEN
(
*
sts
))
return
;
for
(
int
j
=
0
;
j
<
10
;
j
++
)
{
if
(
cdh_ObjidIsNotNull
(
tcp
[
tcp_i
].
Attribute
[
j
].
Objid
)
&&
cdh_ObjidIsNotNull
(
tcp
[
tcp_i
].
Buffers
[
j
].
Objid
))
{
*
sts
=
gdh_AttrrefToName
(
&
tcp
[
tcp_i
].
Buffers
[
j
],
object_name
[
i
],
sizeof
(
object_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
*
sts
=
gdh_AttrrefToName
(
&
tcp
[
tcp_i
].
Attribute
[
j
],
object_name
[
i
],
sizeof
(
object_name
[
0
]),
cdh_mNName
);
if
(
EVEN
(
*
sts
))
return
;
element_size
[
i
]
=
cdh_TypeToSize
(
(
pwr_eType
)
tcp
[
tcp_i
].
AttributeType
[
j
]);
element_type
[
i
]
=
(
pwr_eType
)
tcp
[
tcp_i
].
AttributeType
[
j
];
cb_info
[
i
].
resolution
=
tcp
[
tcp_i
].
DisplayResolution
;
if
(
cb_info
[
i
].
resolution
<=
0
)
cb_info
[
i
].
resolution
=
1
;
cb_info
[
i
].
samples
=
tcp
[
tcp_i
].
DisplayTime
/
tcp
[
tcp_i
].
ScanTime
/
cb_info
[
i
].
resolution
;
cb_info
[
i
].
bufsize
=
cb_info
[
i
].
samples
*
element_size
[
i
];
cb_info
[
i
].
bufp
=
(
char
*
)
calloc
(
1
,
cb_info
[
i
].
bufsize
);
cb_info
[
i
].
circ_aref
=
tcp
[
tcp_i
].
Buffers
[
j
];
*
sts
=
gdh_GetCircBuffInfo
(
&
cb_info
[
i
],
1
);
if
(
EVEN
(
*
sts
))
continue
;
actual_data_size
[
i
]
=
cb_info
[
i
].
size
;
if
(
actual_data_size
[
i
]
>
cb_info
[
i
].
bufsize
)
printf
(
"** Sample size error !!!
\n
"
);
i
++
;
}
}
if
(
tcp_i
==
0
)
{
update_time
=
tcp
[
0
].
DisplayUpdateTime
*
1000
;
fmin_interval
=
tcp
[
0
].
ScanTime
;
}
tcp_i
++
;
}
trend_cnt
=
i
;
if
(
trend_cnt
==
0
)
{
*
sts
=
XNAV__TRENDCONFIG
;
return
;
}
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
if
(
plot
.
YMinValue
[
i
]
!=
plot
.
YMaxValue
[
i
])
gcd
->
scale
(
gcd
->
y_axis_type
[
i
],
gcd
->
y_value_type
[
i
],
plot
.
YMinValue
[
i
],
plot
.
YMaxValue
[
i
],
&
gcd
->
y_min_value_axis
[
i
],
&
gcd
->
y_max_value_axis
[
i
],
&
gcd
->
y_trend_lines
[
i
],
&
gcd
->
y_axis_lines
[
i
],
&
gcd
->
y_axis_linelongq
[
i
],
&
gcd
->
y_axis_valueq
[
i
],
gcd
->
y_format
[
i
],
&
gcd
->
y_axis_width
[
i
],
1
,
1
);
if
(
(
int
)
cb_info
[
i
].
samples
>
max_points
)
max_points
=
cb_info
[
i
].
samples
;
}
// Create data for time axis
gcd
=
new
GeCurveData
(
curve_eDataType_DsTrend
);
gcd
->
x_data
[
0
]
=
(
double
*
)
malloc
(
8
*
max_points
);
strcpy
(
gcd
->
x_name
,
"Time"
);
for
(
j
=
0
;
j
<
max_points
;
j
++
)
{
gcd
->
x_data
[
0
][
j
]
=
double
(
fmin_interval
*
j
*
tcp
[
0
].
DisplayResolution
);
}
gcd
->
x_axis_type
[
0
]
=
curve_eAxis_x
;
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
gcd
->
y_data
[
i
]
=
(
double
*
)
calloc
(
1
,
8
*
max_points
);
switch
(
element_type
[
i
])
{
case
pwr_eType_Float32
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tFloat32
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tFloat32
));
break
;
case
pwr_eType_Float64
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tFloat64
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tFloat64
));
break
;
case
pwr_eType_Boolean
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tBoolean
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tBoolean
));
break
;
case
pwr_eType_Int64
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt64
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tInt64
));
break
;
case
pwr_eType_UInt64
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt64
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tUInt64
));
break
;
case
pwr_eType_Int32
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt32
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tInt32
));
break
;
case
pwr_eType_UInt32
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt32
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tUInt32
));
break
;
case
pwr_eType_Int16
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt16
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tInt16
));
break
;
case
pwr_eType_UInt16
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt16
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tUInt16
));
break
;
case
pwr_eType_Int8
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt8
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tInt8
));
break
;
case
pwr_eType_UInt8
:
for
(
unsigned
int
j
=
0
;
j
<
actual_data_size
[
i
];
j
++
)
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt8
*
)((
char
*
)
cb_info
[
i
].
bufp
+
(
actual_data_size
[
i
]
-
j
-
1
)
*
sizeof
(
pwr_tUInt8
));
break
;
default:
;
}
gcd
->
y_axis_type
[
i
]
=
curve_eAxis_y
;
strcpy
(
gcd
->
y_name
[
i
],
object_name
[
i
]);
gcd
->
rows
[
i
]
=
max_points
;
}
gcd
->
cols
=
trend_cnt
;
gcd
->
x_reverse
=
1
;
gcd
->
get_borders
();
gcd
->
get_default_axis
();
gcd
->
select_color
(
0
);
if
(
!
trend_list
)
{
// Use axis values from plotgroup object
for
(
i
=
0
;
i
<
trend_cnt
;
i
++
)
{
if
(
plot
.
YMinValue
[
i
]
!=
plot
.
YMaxValue
[
i
])
gcd
->
scale
(
gcd
->
y_axis_type
[
i
],
gcd
->
y_value_type
[
i
],
plot
.
YMinValue
[
i
],
plot
.
YMaxValue
[
i
],
&
gcd
->
y_min_value_axis
[
i
],
&
gcd
->
y_max_value_axis
[
i
],
&
gcd
->
y_trend_lines
[
i
],
&
gcd
->
y_axis_lines
[
i
],
&
gcd
->
y_axis_linelongq
[
i
],
&
gcd
->
y_axis_valueq
[
i
],
gcd
->
y_format
[
i
],
&
gcd
->
y_axis_width
[
i
],
1
,
1
);
}
}
}
}
XttTrend
::~
XttTrend
()
{
for
(
int
i
=
0
;
i
<
XTT_TREND_MAX
;
i
++
)
if
(
cb_info
[
i
].
bufp
)
free
(
cb_info
[
i
].
bufp
);
}
void
XttTrend
::
pop
()
...
...
@@ -285,6 +452,17 @@ void XttTrend::trend_close_cb( void *ctx)
delete
trend
;
}
void
XttTrend
::
trend_snapshot_cb
(
void
*
ctx
)
{
XttTrend
*
trend
=
(
XttTrend
*
)
ctx
;
pwr_tCmd
cmd
;
sprintf
(
cmd
,
"open tcurve %s"
,
trend
->
trend_name
[
0
]);
if
(
trend
->
command_cb
)
(
trend
->
command_cb
)(
trend
->
xnav
,
cmd
);
}
void
XttTrend
::
trend_help_cb
(
void
*
ctx
)
{
XttTrend
*
trend
=
(
XttTrend
*
)
ctx
;
...
...
@@ -296,48 +474,118 @@ void XttTrend::trend_help_cb( void *ctx)
void
XttTrend
::
trend_scan
(
void
*
data
)
{
XttTrend
*
trend
=
(
XttTrend
*
)
data
;
int
i
,
j
,
k
;
int
write_buffer
;
int
idx
;
int
values
;
int
trend_buff_size
=
(
int
)
sizeof
(
trend
->
trend_p
[
0
]
->
DataBuffer
)
/
sizeof
(
trend
->
trend_p
[
0
]
->
DataBuffer
[
0
]);
// Check if any new value
i
=
trend
->
min_interval_idx
;
if
(
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
trend
->
trend_p
[
i
]
->
WriteBuffer
]
!=
trend
->
last_next_index
[
i
])
{
values
=
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
trend
->
trend_p
[
i
]
->
WriteBuffer
]
-
trend
->
last_next_index
[
i
];
if
(
values
<
0
)
values
=
values
+
trend
->
trend_p
[
i
]
->
NoOfSample
;
trend
->
last_next_index
[
i
]
=
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
trend
->
trend_p
[
i
]
->
WriteBuffer
];
for
(
k
=
0
;
k
<
values
;
k
++
)
{
// Add new points
for
(
i
=
0
;
i
<
trend
->
trend_cnt
;
i
++
)
{
// Shift data
for
(
j
=
trend
->
max_points
-
1
;
j
>
0
;
j
--
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
trend
->
gcd
->
y_data
[
i
][
j
-
1
];
// Insert new value
write_buffer
=
trend
->
trend_p
[
i
]
->
WriteBuffer
;
idx
=
write_buffer
*
trend_buff_size
/
2
+
int
(
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
write_buffer
])
-
(
values
-
1
-
k
);
if
(
idx
==
0
||
idx
==
trend_buff_size
/
2
)
idx
=
trend
->
trend_p
[
i
]
->
NoOfSample
-
1
+
(
!
write_buffer
)
*
trend_buff_size
/
2
;
else
idx
--
;
trend
->
gcd
->
y_data
[
i
][
0
]
=
trend
->
trend_p
[
i
]
->
DataBuffer
[
idx
];
int
i
,
j
,
k
;
if
(
trend
->
trend_tid
==
pwr_cClass_DsTrend
)
{
int
write_buffer
;
int
idx
;
int
values
;
int
trend_buff_size
=
(
int
)
sizeof
(
trend
->
trend_p
[
0
]
->
DataBuffer
)
/
sizeof
(
trend
->
trend_p
[
0
]
->
DataBuffer
[
0
]);
// Check if any new value
i
=
trend
->
min_interval_idx
;
if
(
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
trend
->
trend_p
[
i
]
->
WriteBuffer
]
!=
trend
->
last_next_index
[
i
])
{
values
=
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
trend
->
trend_p
[
i
]
->
WriteBuffer
]
-
trend
->
last_next_index
[
i
];
if
(
values
<
0
)
values
=
values
+
trend
->
trend_p
[
i
]
->
NoOfSample
;
trend
->
last_next_index
[
i
]
=
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
trend
->
trend_p
[
i
]
->
WriteBuffer
];
for
(
k
=
0
;
k
<
values
;
k
++
)
{
// Add new points
for
(
i
=
0
;
i
<
trend
->
trend_cnt
;
i
++
)
{
// Shift data
for
(
j
=
trend
->
max_points
-
1
;
j
>
0
;
j
--
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
trend
->
gcd
->
y_data
[
i
][
j
-
1
];
// Insert new value
write_buffer
=
trend
->
trend_p
[
i
]
->
WriteBuffer
;
idx
=
write_buffer
*
trend_buff_size
/
2
+
int
(
trend
->
trend_p
[
i
]
->
NextWriteIndex
[
write_buffer
])
-
(
values
-
1
-
k
);
if
(
idx
==
0
||
idx
==
trend_buff_size
/
2
)
idx
=
trend
->
trend_p
[
i
]
->
NoOfSample
-
1
+
(
!
write_buffer
)
*
trend_buff_size
/
2
;
else
idx
--
;
trend
->
gcd
->
y_data
[
i
][
0
]
=
trend
->
trend_p
[
i
]
->
DataBuffer
[
idx
];
}
trend
->
curve
->
points_added
(
1
);
}
}
}
else
if
(
trend
->
trend_tid
==
pwr_cClass_DsTrendCurve
)
{
pwr_tStatus
sts
;
unsigned
int
size
;
sts
=
gdh_UpdateCircBuffInfo
(
trend
->
cb_info
,
trend
->
trend_cnt
);
if
(
EVEN
(
sts
))
return
;
for
(
i
=
0
;
i
<
trend
->
trend_cnt
;
i
++
)
{
size
=
trend
->
cb_info
[
i
].
size
;
if
(
size
>
0
)
{
// Shift data
for
(
j
=
trend
->
cb_info
[
i
].
samples
-
1
;
j
>=
(
int
)
size
;
j
--
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
trend
->
gcd
->
y_data
[
i
][
j
-
size
];
// Insert new value
switch
(
trend
->
element_type
[
i
])
{
case
pwr_eType_Float64
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tFloat64
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tFloat64
));
break
;
case
pwr_eType_Float32
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tFloat32
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tFloat32
));
break
;
case
pwr_eType_Boolean
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tBoolean
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tBoolean
));
break
;
case
pwr_eType_Int64
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt64
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tInt64
));
break
;
case
pwr_eType_UInt64
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt64
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tUInt64
));
break
;
case
pwr_eType_Int32
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt32
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tInt32
));
break
;
case
pwr_eType_UInt32
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt32
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tUInt32
));
break
;
case
pwr_eType_Int16
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt16
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tInt16
));
break
;
case
pwr_eType_UInt16
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt16
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tUInt16
));
break
;
case
pwr_eType_Int8
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tInt8
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tInt8
));
break
;
case
pwr_eType_UInt8
:
for
(
j
=
0
;
j
<
(
int
)
size
;
j
++
)
trend
->
gcd
->
y_data
[
i
][
j
]
=
*
(
pwr_tUInt8
*
)((
char
*
)
trend
->
cb_info
[
i
].
bufp
+
(
size
-
j
-
1
)
*
sizeof
(
pwr_tUInt8
));
break
;
default:
;
}
}
trend
->
curve
->
points_added
();
}
if
(
size
>
0
)
trend
->
curve
->
points_added
(
size
);
}
trend
->
timerid
->
add
(
1000
,
trend_scan
,
trend
);
trend
->
timerid
->
add
(
trend
->
update_time
,
trend_scan
,
trend
);
}
...
...
xtt/lib/xtt/src/xtt_trend.h
View file @
c216641b
...
...
@@ -61,16 +61,22 @@ class XttTrend {
pwr_tRefId
subid
[
XTT_TREND_MAX
];
pwr_sClass_DsTrend
*
trend_p
[
XTT_TREND_MAX
];
int
element_size
[
XTT_TREND_MAX
];
pwr_eType
element_type
[
XTT_TREND_MAX
];
int
interval
[
XTT_TREND_MAX
];
pwr_tAName
trend_name
[
XTT_TREND_MAX
];
int
max_time
;
int
min_interval
;
int
min_interval_idx
;
int
max_points
;
pwr_tTid
trend_tid
;
int
update_time
;
gdh_sCircBuffInfo
cb_info
[
XTT_TREND_MAX
];
CoWowTimer
*
timerid
;
int
last_buffer
[
XTT_TREND_MAX
];
int
last_next_index
[
XTT_TREND_MAX
];
void
(
*
close_cb
)(
void
*
,
XttTrend
*
);
void
(
*
help_cb
)(
void
*
,
const
char
*
);
void
(
*
command_cb
)(
void
*
,
const
char
*
);
CoWow
*
wow
;
XttTrend
(
void
*
xn_parent_ctx
,
...
...
@@ -83,6 +89,7 @@ class XttTrend {
static
void
trend_close_cb
(
void
*
ctx
);
static
void
trend_help_cb
(
void
*
ctx
);
static
void
trend_snapshot_cb
(
void
*
ctx
);
static
void
trend_scan
(
void
*
data
);
};
...
...
xtt/lib/xtt/src/xtt_xnav.h
View file @
c216641b
...
...
@@ -114,6 +114,7 @@ class XColWind;
class
Block
;
class
XttTrend
;
class
XttSevHist
;
class
XttTCurve
;
class
XttFast
;
class
XAttOne
;
class
GeCurve
;
...
...
@@ -373,6 +374,7 @@ class XNav {
virtual
XttSevHist
*
xttsevhist_new
(
char
*
name
,
pwr_tOid
*
oidv
,
pwr_tOName
*
aname
,
pwr_tOName
*
oname
,
bool
*
sevhistobjectv
,
sevcli_tCtx
scctx
,
pwr_tStatus
*
sts
)
{
return
0
;}
virtual
XttTCurve
*
xtttcurve_new
(
char
*
name
,
pwr_tAttrRef
*
arefv
,
pwr_tStatus
*
sts
)
{
return
0
;}
virtual
XttFast
*
xttfast_new
(
char
*
name
,
pwr_tAttrRef
*
objar
,
pwr_tStatus
*
sts
)
{
return
0
;}
virtual
XAttOne
*
xattone_new
(
pwr_tAttrRef
*
objar
,
char
*
title
,
unsigned
int
priv
,
pwr_tStatus
*
sts
)
{
return
0
;}
...
...
xtt/lib/xtt/src/xtt_xnav_command.cpp
View file @
c216641b
...
...
@@ -83,6 +83,7 @@
#include "ge_curve.h"
#include "xtt_trend.h"
#include "xtt_sevhist.h"
#include "xtt_tcurve.h"
#include "xtt_fast.h"
#include "xtt_xcrr.h"
#include "xtt_menu.h"
...
...
@@ -169,7 +170,10 @@ static void xnav_op_map_cb( void *ctx);
static
int
xnav_op_get_alarm_info_cb
(
void
*
xnav
,
evlist_sAlarmInfo
*
info
);
static
void
xnav_op_ack_last_cb
(
void
*
xnav
,
unsigned
long
type
,
unsigned
long
prio
);
static
void
xnav_trend_close_cb
(
void
*
ctx
,
XttTrend
*
trend
);
static
void
xnav_trend_command_cb
(
void
*
ctx
,
const
char
*
key
);
static
void
xnav_trend_help_cb
(
void
*
ctx
,
const
char
*
key
);
static
void
xnav_tcurve_close_cb
(
void
*
ctx
,
XttTCurve
*
trend
);
static
void
xnav_tcurve_help_cb
(
void
*
ctx
,
const
char
*
key
);
static
void
xnav_sevhist_help_cb
(
void
*
ctx
,
const
char
*
key
);
static
int
xnav_sevhist_get_select_cb
(
void
*
ctx
,
pwr_tOid
*
oid
,
char
*
aname
,
char
*
oname
);
static
int
xnav_get_select_cb
(
void
*
ctx
,
pwr_tAttrRef
*
aref
,
int
*
is_attr
);
...
...
@@ -3029,6 +3033,8 @@ static int xnav_open_func( void *client_data,
switch
(
classid
)
{
case
pwr_cClass_DsTrend
:
break
;
case
pwr_cClass_DsTrendCurve
:
break
;
case
pwr_cClass_PlotGroup
:
plotgroup
=
aref_vect
[
i
];
plotgroup_found
=
1
;
...
...
@@ -3070,7 +3076,9 @@ static int xnav_open_func( void *client_data,
xnav
->
message
(
'E'
,
"Error in trend configuration"
);
else
{
trend
->
close_cb
=
xnav_trend_close_cb
;
trend
->
help_cb
=
xnav_trend_command_cb
;
trend
->
help_cb
=
xnav_trend_help_cb
;
trend
->
command_cb
=
xnav_trend_command_cb
;
xnav
->
appl
.
insert
(
applist_eType_Trend
,
(
void
*
)
trend
,
&
plotgroup
,
""
,
NULL
);
}
...
...
@@ -3087,6 +3095,7 @@ static int xnav_open_func( void *client_data,
xnav
->
message
(
'E'
,
"Error in trend configuration"
);
else
{
trend
->
close_cb
=
xnav_trend_close_cb
;
trend
->
command_cb
=
xnav_trend_command_cb
;
trend
->
help_cb
=
xnav_trend_help_cb
;
xnav
->
appl
.
insert
(
applist_eType_Trend
,
(
void
*
)
trend
,
&
aref_vect
[
0
],
""
,
NULL
);
...
...
@@ -3096,7 +3105,8 @@ static int xnav_open_func( void *client_data,
else
{
trend
=
xnav
->
xtttrend_new
(
title_str
,
aref_vect
,
0
,
&
sts
);
if
(
ODD
(
sts
))
{
trend
->
help_cb
=
xnav_trend_help_cb
;
trend
->
close_cb
=
xnav_trend_close_cb
;
trend
->
command_cb
=
xnav_trend_command_cb
;
trend
->
help_cb
=
xnav_trend_help_cb
;
}
}
...
...
@@ -3168,6 +3178,56 @@ static int xnav_open_func( void *client_data,
xnav
->
wow
->
CreateList
(
"History List"
,
(
char
*
)
cname
,
sizeof
(
cname
[
0
]),
xnav_open_shist_cb
,
xnav_open_shist_cancel_cb
,
ctx
);
}
else
if
(
cdh_NoCaseStrncmp
(
arg1_str
,
"TCURVE"
,
strlen
(
arg1_str
))
==
0
)
{
pwr_tAName
name_str
;
char
*
name_ptr
;
pwr_tAttrRef
aref_vect
[
2
];
pwr_tStatus
sts
;
char
title_str
[
80
];
/* Get the name qualifier */
if
(
ODD
(
dcli_get_qualifier
(
"dcli_arg2"
,
name_str
,
sizeof
(
name_str
))))
{
if
(
name_str
[
0
]
!=
'/'
)
/* Assume that this is the namestring */
name_ptr
=
name_str
;
else
{
xnav
->
message
(
'E'
,
"Syntax error"
);
return
XNAV__HOLDCOMMAND
;
}
}
else
{
if
(
ODD
(
dcli_get_qualifier
(
"/NAME"
,
name_str
,
sizeof
(
name_str
))))
name_ptr
=
name_str
;
else
{
/* Get the selected object */
sts
=
xnav
->
get_current_aref
(
&
aref_vect
[
0
],
name_str
,
sizeof
(
name_str
),
cdh_mName_path
|
cdh_mName_object
|
cdh_mName_attribute
);
if
(
EVEN
(
sts
))
{
xnav
->
message
(
'E'
,
"Enter name or select an object"
);
return
XNAV__SUCCESS
;
}
name_ptr
=
name_str
;
}
}
if
(
EVEN
(
dcli_get_qualifier
(
"/TITLE"
,
title_str
,
sizeof
(
title_str
))))
{
strcpy
(
title_str
,
"Trend"
);
}
memset
(
aref_vect
,
0
,
sizeof
(
aref_vect
));
sts
=
gdh_NameToAttrref
(
pwr_cNObjid
,
name_str
,
&
aref_vect
[
0
]);
if
(
EVEN
(
sts
))
{
xnav
->
message
(
'E'
,
"Object not found"
);
return
XNAV__HOLDCOMMAND
;
}
XttTCurve
*
tcurve
=
xnav
->
xtttcurve_new
(
title_str
,
aref_vect
,
&
sts
);
if
(
ODD
(
sts
))
{
tcurve
->
close_cb
=
xnav_tcurve_close_cb
;
tcurve
->
help_cb
=
xnav_tcurve_help_cb
;
}
return
XNAV__SUCCESS
;
}
else
if
(
cdh_NoCaseStrncmp
(
arg1_str
,
"HISTORY"
,
strlen
(
arg1_str
))
==
0
)
{
...
...
@@ -3909,6 +3969,7 @@ static int xnav_close_func( void *client_data,
switch
(
classid
)
{
case
pwr_cClass_PlotGroup
:
case
pwr_cClass_DsTrend
:
case
pwr_cClass_DsTrendCurve
:
plotgroup_found
=
1
;
break
;
default:
...
...
@@ -4150,6 +4211,13 @@ static void xnav_trend_close_cb( void *ctx, XttTrend *trend)
delete
trend
;
}
static
void
xnav_trend_command_cb
(
void
*
ctx
,
const
char
*
cmd
)
{
XNav
*
xnav
=
(
XNav
*
)
ctx
;
xnav
->
command
(
(
char
*
)
cmd
);
}
static
void
xnav_trend_help_cb
(
void
*
ctx
,
const
char
*
key
)
{
XNav
*
xnav
=
(
XNav
*
)
ctx
;
...
...
@@ -4163,6 +4231,27 @@ static void xnav_trend_help_cb( void *ctx, const char *key)
xnav
->
message
(
' '
,
null_str
);
}
static
void
xnav_tcurve_close_cb
(
void
*
ctx
,
XttTCurve
*
trend
)
{
XNav
*
xnav
=
(
XNav
*
)
ctx
;
xnav
->
appl
.
remove
(
(
void
*
)
trend
);
delete
trend
;
}
static
void
xnav_tcurve_help_cb
(
void
*
ctx
,
const
char
*
key
)
{
XNav
*
xnav
=
(
XNav
*
)
ctx
;
int
sts
;
sts
=
CoXHelp
::
dhelp
(
key
,
""
,
navh_eHelpFile_Base
,
NULL
,
0
);
if
(
EVEN
(
sts
))
xnav
->
message
(
'E'
,
"Unable to find topic"
);
else
xnav
->
message
(
' '
,
null_str
);
}
static
void
xnav_sevhist_help_cb
(
void
*
ctx
,
const
char
*
key
)
{
XNav
*
xnav
=
(
XNav
*
)
ctx
;
...
...
@@ -7893,6 +7982,7 @@ static void xnav_show_objectlist_cb( void *ctx, char *text)
switch
(
cid
)
{
case
pwr_cClass_DsTrend
:
case
pwr_cClass_DsTrendCurve
:
sprintf
(
cmd
,
"open trend/name=%s/title=
\"
%s
\"
"
,
text
,
text
);
break
;
case
pwr_cClass_DsFastCurve
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment