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
8808c371
Commit
8808c371
authored
Dec 03, 2018
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NMps, added new Function CheckObjects for cells to automatically remove deleted objects
parent
9b8554db
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
138 additions
and
12 deletions
+138
-12
nmps/lib/nmps/src/nmps.h
nmps/lib/nmps/src/nmps.h
+1
-0
nmps/lib/nmps/src/nmps_appl.c
nmps/lib/nmps/src/nmps_appl.c
+6
-10
nmps/lib/nmps/src/nmps_plc.c
nmps/lib/nmps/src/nmps_plc.c
+98
-0
nmps/wbl/nmps/src/nmps.wb_load
nmps/wbl/nmps/src/nmps.wb_load
+16
-2
src/lib/rt/src/rt_gdh.c
src/lib/rt/src/rt_gdh.c
+15
-0
src/lib/rt/src/rt_gdh.h
src/lib/rt/src/rt_gdh.h
+2
-0
No files found.
nmps/lib/nmps/src/nmps.h
View file @
8808c371
...
...
@@ -68,6 +68,7 @@
#define NMPS_CELLFUNC_DELETE 4
#define NMPS_CELLFUNC_RESETDELETE 8
#define NMPS_CELLFUNC_BACKUP 16
#define NMPS_CELLFUNC_CHECKOBJECTS 32
#define NMPS_TRPFUNC_UNIT 1
#define NMPS_TRPFUNC_ALL 2
...
...
nmps/lib/nmps/src/nmps_appl.c
View file @
8808c371
...
...
@@ -359,7 +359,7 @@ pwr_tStatus nmpsappl_MirrorInit(pwr_tString80*
/* Allocate memory for the data objects array in applctx */
if
(
options
&
nmpsappl_mOption_Remove
)
/* Remove requires the d
ubbel
size */
/* Remove requires the d
ouble
size */
applctx
->
datainfo
=
(
nmpsappl_t_datainfo
*
)
calloc
(
applctx
->
total_cellsize
*
2
,
sizeof
(
nmpsappl_t_datainfo
));
else
...
...
@@ -379,16 +379,12 @@ pwr_tStatus nmpsappl_MirrorInit(pwr_tString80*
*@brief Update mirroring.
*
* nmpsappl_Mirror mirrors the content of one or several cells into an
*application
* program.
* application program.
*
* The function handles direct link of cells and dataobjects, and returns a list
*of
* data objects to the application together with information about front, back,
*select
* properties, and which data objects are new or has disappeard. The application
*also
* receives a pointer to each data object.
* of data objects to the application together with information about front, back,
* select properties, and which data objects are new or has disappeard. The
* application also receives a pointer to each data object.
*
* The mirroring is initiated by calling nmpsappl_MirrorInit. The cells are
* mirrored are specified in this call. Then nmpsappl_Mirror is called cyclic
...
...
@@ -399,7 +395,7 @@ pwr_tStatus nmpsappl_MirrorInit(pwr_tString80*
* Several mirroring can be handled in the same application (max 32), and each
* mirroring can handle maximum 32 cells.
*
* Ex
empel
* Ex
ample
* @code
* #include "pwr_inc:pwr.h"
* #include "ssab_inc:rs_nmps_appl.h"
...
...
nmps/lib/nmps/src/nmps_plc.c
View file @
8808c371
...
...
@@ -165,6 +165,44 @@ void NMpsCell_exec(plc_sThread* tp, pwr_sClass_NMpsCell* object)
object
->
BackupNow
=
1
;
}
}
if
(
object
->
Function
&
NMPS_CELLFUNC_CHECKOBJECTS
)
{
data_index
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
for
(
i
=
0
;
i
<
object
->
LastIndex
;
i
++
)
{
sts
=
gdh_CheckLocalObject
(
data_index
->
DataP
.
Aref
.
Objid
);
if
(
EVEN
(
sts
))
{
/* Remove object */
sts
=
gdh_DLUnrefObjectInfo
(
data_index
->
Data_Dlid
);
if
(
i
<
object
->
LastIndex
)
{
size
=
(
object
->
LastIndex
-
i
)
*
sizeof
(
*
data_max
);
#if defined OS_LINUX
tmp_buf
=
malloc
(
size
);
memcpy
(
tmp_buf
,
(
char
*
)
data_index
+
sizeof
(
*
data_max
),
size
);
memcpy
(
data_index
,
tmp_buf
,
size
);
free
(
tmp_buf
);
#else
memcpy
(
data_index
,
(
char
*
)
data_index
+
sizeof
(
*
data_max
),
size
);
#endif
}
data_last
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
data_last
+=
object
->
LastIndex
-
1
;
memset
(
data_last
,
0
,
sizeof
(
*
data_last
));
object
->
CellFull
=
0
;
object
->
LastIndex
--
;
if
(
object
->
LastIndex
>
0
)
{
data_last
--
;
memcpy
(
&
object
->
DataLP
,
data_last
,
sizeof
(
*
data_last
));
memcpy
(
&
object
->
DataLastP
,
data_last
,
sizeof
(
*
data_last
));
}
else
{
memset
(
&
object
->
DataLP
,
0
,
sizeof
(
*
data_last
));
memset
(
&
object
->
DataLastP
,
0
,
sizeof
(
*
data_last
));
}
i
--
;
}
else
data_index
++
;
}
}
if
(
object
->
ExternFlag
)
{
/* Insert new object in Front position */
...
...
@@ -180,6 +218,19 @@ void NMpsCell_exec(plc_sThread* tp, pwr_sClass_NMpsCell* object)
else
if
(
object
->
ExternIndex
>
object
->
LastIndex
+
1
)
object
->
ExternStatus
=
2
;
/* Felkod !!! */
else
{
data_index
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
for
(
i
=
0
;
i
<
object
->
LastIndex
;
i
++
)
{
if
(
cdh_ObjidIsEqual
(
data_index
->
DataP
.
Aref
.
Objid
,
object
->
ExternObjId
))
{
object
->
ExternStatus
=
2
;
object
->
ExternFlag
=
0
;
data_index
=
0
;
break
;
}
data_index
++
;
}
if
(
!
data_index
)
break
;
extern_attrref
.
Objid
=
object
->
ExternObjId
;
extern_attrref
.
Offset
=
0
;
extern_attrref
.
Size
=
4
;
...
...
@@ -694,6 +745,40 @@ void NMpsStoreCell_exec(plc_sThread* tp, pwr_sClass_NMpsStoreCell* object)
object
->
BackupNow
=
1
;
}
}
if
(
object
->
Function
&
NMPS_CELLFUNC_CHECKOBJECTS
)
{
data_index
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
for
(
i
=
0
;
i
<
object
->
LastIndex
;
i
++
)
{
sts
=
gdh_CheckLocalObject
(
data_index
->
DataP
.
Aref
.
Objid
);
if
(
EVEN
(
sts
))
{
/* Remove object */
sts
=
gdh_DLUnrefObjectInfo
(
data_index
->
Data_Dlid
);
if
(
i
<
object
->
LastIndex
)
{
size
=
(
object
->
LastIndex
-
i
)
*
sizeof
(
*
data_max
);
#if defined OS_LINUX
tmp_buf
=
malloc
(
size
);
memcpy
(
tmp_buf
,
(
char
*
)
data_index
+
sizeof
(
*
data_max
),
size
);
memcpy
(
data_index
,
tmp_buf
,
size
);
free
(
tmp_buf
);
#else
memcpy
(
data_index
,
(
char
*
)
data_index
+
sizeof
(
*
data_max
),
size
);
#endif
}
data_last
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
data_last
+=
object
->
LastIndex
-
1
;
memset
(
data_last
,
0
,
sizeof
(
*
data_last
));
object
->
CellFull
=
0
;
object
->
LastIndex
--
;
if
((
object
->
SelectIndex
!=
0
)
&&
(
object
->
SelectIndex
>
i
))
object
->
SelectIndex
--
;
i
--
;
}
else
data_index
++
;
}
}
if
(
object
->
ExternFlag
)
{
/* Insert new object in Front position */
...
...
@@ -710,6 +795,19 @@ void NMpsStoreCell_exec(plc_sThread* tp, pwr_sClass_NMpsStoreCell* object)
else
if
(
object
->
ExternIndex
>
object
->
LastIndex
+
1
)
object
->
ExternStatus
=
2
;
/* Felkod !!! */
else
{
data_index
=
(
plc_t_DataInfo
*
)
&
object
->
Data1P
;
for
(
i
=
0
;
i
<
object
->
LastIndex
;
i
++
)
{
if
(
cdh_ObjidIsEqual
(
data_index
->
DataP
.
Aref
.
Objid
,
object
->
ExternObjId
))
{
object
->
ExternStatus
=
2
;
object
->
ExternFlag
=
0
;
data_index
=
0
;
break
;
}
data_index
++
;
}
if
(
!
data_index
)
break
;
extern_attrref
.
Objid
=
object
->
ExternObjId
;
extern_attrref
.
Offset
=
0
;
extern_attrref
.
Size
=
4
;
...
...
nmps/wbl/nmps/src/nmps.wb_load
View file @
8808c371
Volume NMps $ClassVolume 0.0.1.1
Body SysBody 01-JAN-1970 01:00:00.00
Attr NextOix = "_X
89
"
Attr NextOix = "_X
91
"
EndBody
Object Type $TypeHier 2 07-JUL-2017 13:58:14.00
Object CellFunctionMask $TypeDef 1 07-JUL-2017 13:58:14.00
...
...
@@ -30,6 +30,13 @@ Volume NMps $ClassVolume 0.0.1.1
Attr Value = 16
EndBody
EndObject
Object CheckObjects $Bit 90 03-DEC-2018 16:17:11.48
Body SysBody 03-DEC-2018 16:17:19.07
Attr Text = "CheckObjects"
Attr PgmName = "CheckObjects"
Attr Value = 32
EndBody
EndObject
EndObject
Object OutCellFunctionMask $TypeDef 2 07-JUL-2017 13:58:14.00
Body SysBody 01-JAN-1970 01:00:00.00
...
...
@@ -86,6 +93,13 @@ Volume NMps $ClassVolume 0.0.1.1
Attr Value = 16
EndBody
EndObject
Object CheckObjects $Bit 91 03-DEC-2018 16:17:24.71
Body SysBody 03-DEC-2018 16:17:24.71
Attr Text = "CheckObjects"
Attr PgmName = "CheckObjects"
Attr Value = 32
EndBody
EndObject
EndObject
Object TrpFunctionMask $TypeDef 4 07-JUL-2017 13:58:14.00
Body SysBody 01-JAN-1970 01:00:00.00
...
...
@@ -5869,7 +5883,7 @@ Volume NMps $ClassVolume 0.0.1.1
!/**
! @Group MaterialPlanning,Plc
!
! Note
!
Obsolete since V5.2
! NoteObsolete since V5.2
! Replaced by GetDataRefp.
!*/
Object GetDap $ClassDef 19 07-JUL-2017 13:58:14.00
...
...
src/lib/rt/src/rt_gdh.c
View file @
8808c371
...
...
@@ -5243,6 +5243,20 @@ pwr_tStatus gdh_GetLocalClassList(int cidcnt, pwr_tCid* cid, int attrobjects,
return
GDH__SUCCESS
;
}
pwr_tStatus
gdh_CheckLocalObject
(
pwr_tOid
oid
)
{
pwr_tStatus
sts
;
gdb_sObject
*
op
;
gdh_ScopeLock
{
op
=
vol_OidToObject
(
&
sts
,
oid
,
gdb_mLo_local
,
vol_mTrans_none
,
cvol_eHint_none
);
}
gdh_ScopeUnlock
;
if
(
op
==
NULL
)
return
sts
;
return
GDH__SUCCESS
;
}
/**
* @brief Thread save function to fetch a direct linked absolute time value.
* Sets the time lock to ensure that the time is not modified during
...
...
@@ -5477,3 +5491,4 @@ pwr_tStatus gdh_SetObjectInfoStr(char* name, /**< Attribute name */
lck_Unlock
(
lck_eLock_Str
);
return
sts
;
}
src/lib/rt/src/rt_gdh.h
View file @
8808c371
...
...
@@ -435,6 +435,8 @@ pwr_tStatus gdh_GetGlobalClassList(int cidcnt, pwr_tCid* cid, int attrobjects,
pwr_tStatus
gdh_GetLocalClassList
(
int
cidcnt
,
pwr_tCid
*
cid
,
int
attrobjects
,
pwr_tAttrRef
*
classlist
[],
int
*
listcnt
);
pwr_tStatus
gdh_CheckLocalObject
(
pwr_tOid
oid
);
/* Thread safe functions for times and strings */
void
gdh_GetTimeDL
(
pwr_tTime
*
atp
,
pwr_tTime
*
time
);
void
gdh_SetTimeDL
(
pwr_tTime
*
atp
,
pwr_tTime
*
time
);
...
...
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