Commit d29602e6 authored by Claes Sjofors's avatar Claes Sjofors

rt iocopyarea for ATv, DTv and Sv, and time and string locks

parent 4f7e57f2
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include "co_math.h" #include "co_math.h"
#include "rt_gdh.h" #include "rt_gdh.h"
#include "rt_errh.h" #include "rt_errh.h"
#include "rt_nmps_lock.h" #include "rt_lck.h"
#include "rt_gdh_msg.h" #include "rt_gdh_msg.h"
#include "rt_hash_msg.h" #include "rt_hash_msg.h"
#include "rs_nmps_msg.h" #include "rs_nmps_msg.h"
...@@ -410,7 +410,7 @@ nmpsappl_MirrorInit( ...@@ -410,7 +410,7 @@ nmpsappl_MirrorInit(
(nmpsappl_t_datainfo *) calloc( applctx->total_cellsize, (nmpsappl_t_datainfo *) calloc( applctx->total_cellsize,
sizeof(nmpsappl_t_datainfo)); sizeof(nmpsappl_t_datainfo));
nmps_create_lock( &sts); lck_Create( &sts, lck_eLock_NMps);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
applctx->options = options; applctx->options = options;
...@@ -505,10 +505,10 @@ nmpsappl_Mirror( ...@@ -505,10 +505,10 @@ nmpsappl_Mirror(
for ( i = 0; i < applctx->cellist_count; i++) for ( i = 0; i < applctx->cellist_count; i++)
{ {
cellist_ptr = applctx->cellist[i]; cellist_ptr = applctx->cellist[i];
nmps_Lock; lck_LockNMps;
memcpy( cellist_ptr->tmp_cell, cellist_ptr->object_ptr, memcpy( cellist_ptr->tmp_cell, cellist_ptr->object_ptr,
cellist_ptr->tmp_size); cellist_ptr->tmp_size);
nmps_Unlock; lck_UnlockNMps;
} }
applctx->data_count = 0; applctx->data_count = 0;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include "co_math.h" #include "co_math.h"
#include "rt_gdh.h" #include "rt_gdh.h"
#include "rt_plc.h" #include "rt_plc.h"
#include "rt_nmps_lock.h" #include "rt_lck.h"
#include "nmps.h" #include "nmps.h"
#include "rs_nmps_msg.h" #include "rs_nmps_msg.h"
...@@ -101,7 +101,7 @@ void NMpsCell_init( pwr_sClass_NMpsCell *object) ...@@ -101,7 +101,7 @@ void NMpsCell_init( pwr_sClass_NMpsCell *object)
int i; int i;
pwr_tStatus sts; pwr_tStatus sts;
nmps_create_lock( &sts); lck_Create( &sts, lck_eLock_NMps);
if ( !(object->Function & NMPS_CELLFUNC_BACKUP)) if ( !(object->Function & NMPS_CELLFUNC_BACKUP))
NMpsCell_init_time( object); NMpsCell_init_time( object);
...@@ -149,13 +149,13 @@ void NMpsCell_exec( ...@@ -149,13 +149,13 @@ void NMpsCell_exec(
if ( !(object->ReloadDone & NMPS_CELL_RELOADDONE)) if ( !(object->ReloadDone & NMPS_CELL_RELOADDONE))
return; return;
else { else {
nmps_Lock; lck_LockNMps;
NMpsCell_init_time( object); NMpsCell_init_time( object);
object->ReloadDone &= ~NMPS_CELL_RELOADDONE; object->ReloadDone &= ~NMPS_CELL_RELOADDONE;
} }
} }
else else
nmps_Lock; lck_LockNMps;
if ( object->FrontNew) object->FrontNew = 0; if ( object->FrontNew) object->FrontNew = 0;
...@@ -434,7 +434,7 @@ void NMpsCell_exec( ...@@ -434,7 +434,7 @@ void NMpsCell_exec(
case NMPS_OPTYPE_FORWARD_FRONT: case NMPS_OPTYPE_FORWARD_FRONT:
/* Insert at front of object front of data */ /* Insert at front of object front of data */
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
if ( object->LastIndex > 0) if ( object->LastIndex > 0)
...@@ -472,7 +472,7 @@ void NMpsCell_exec( ...@@ -472,7 +472,7 @@ void NMpsCell_exec(
{ {
/* This it not the correct object */ /* This it not the correct object */
object->InFlag = 0; object->InFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
object->Data1_Back = 1; object->Data1_Back = 1;
...@@ -485,7 +485,7 @@ void NMpsCell_exec( ...@@ -485,7 +485,7 @@ void NMpsCell_exec(
break; break;
case NMPS_OPTYPE_FORWARD_UNIT: case NMPS_OPTYPE_FORWARD_UNIT:
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
if ( object->LastIndex > 0) if ( object->LastIndex > 0)
...@@ -520,7 +520,7 @@ void NMpsCell_exec( ...@@ -520,7 +520,7 @@ void NMpsCell_exec(
case NMPS_OPTYPE_REVERSE_BACK: case NMPS_OPTYPE_REVERSE_BACK:
/* Insert at rear of object back of data */ /* Insert at rear of object back of data */
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
data_last = (plc_t_DataInfo *) &object->Data1P; data_last = (plc_t_DataInfo *) &object->Data1P;
...@@ -541,7 +541,7 @@ void NMpsCell_exec( ...@@ -541,7 +541,7 @@ void NMpsCell_exec(
case NMPS_OPTYPE_REVERSE_UNIT: case NMPS_OPTYPE_REVERSE_UNIT:
/* Insert at rear of object all of data */ /* Insert at rear of object all of data */
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
data_last = (plc_t_DataInfo *) &object->Data1P; data_last = (plc_t_DataInfo *) &object->Data1P;
...@@ -567,7 +567,7 @@ void NMpsCell_exec( ...@@ -567,7 +567,7 @@ void NMpsCell_exec(
{ {
/* This it not the correct object */ /* This it not the correct object */
object->InFlag = 0; object->InFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
data_last->Data_Front = 1; data_last->Data_Front = 1;
...@@ -591,7 +591,7 @@ void NMpsCell_exec( ...@@ -591,7 +591,7 @@ void NMpsCell_exec(
if ( object->LastIndex == 0) if ( object->LastIndex == 0)
{ {
object->OutRearFlag = 0; object->OutRearFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
...@@ -637,7 +637,7 @@ void NMpsCell_exec( ...@@ -637,7 +637,7 @@ void NMpsCell_exec(
if ( object->LastIndex == 0) if ( object->LastIndex == 0)
{ {
object->OutFrontFlag = 0; object->OutFrontFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
#if defined OS_LINUX #if defined OS_LINUX
...@@ -683,7 +683,7 @@ void NMpsCell_exec( ...@@ -683,7 +683,7 @@ void NMpsCell_exec(
} }
object->NumberOfData = object->LastIndex; object->NumberOfData = object->LastIndex;
nmps_Unlock; lck_UnlockNMps;
} }
...@@ -695,7 +695,7 @@ void NMpsStoreCell_init( pwr_sClass_NMpsStoreCell *object) ...@@ -695,7 +695,7 @@ void NMpsStoreCell_init( pwr_sClass_NMpsStoreCell *object)
int i; int i;
pwr_tStatus sts; pwr_tStatus sts;
nmps_create_lock( &sts); lck_Create( &sts, lck_eLock_NMps);
if ( !(object->Function & NMPS_CELLFUNC_BACKUP)) if ( !(object->Function & NMPS_CELLFUNC_BACKUP))
NMpsCell_init_time( (pwr_sClass_NMpsCell *) object); NMpsCell_init_time( (pwr_sClass_NMpsCell *) object);
...@@ -747,13 +747,13 @@ void NMpsStoreCell_exec( ...@@ -747,13 +747,13 @@ void NMpsStoreCell_exec(
return; return;
else else
{ {
nmps_Lock; lck_LockNMps;
NMpsCell_init_time( (pwr_sClass_NMpsCell *)object); NMpsCell_init_time( (pwr_sClass_NMpsCell *)object);
object->ReloadDone &= ~NMPS_CELL_RELOADDONE; object->ReloadDone &= ~NMPS_CELL_RELOADDONE;
} }
} }
else else
nmps_Lock; lck_LockNMps;
if ( object->FrontNew) object->FrontNew = 0; if ( object->FrontNew) object->FrontNew = 0;
if ( object->RearNew) object->RearNew = 0; if ( object->RearNew) object->RearNew = 0;
...@@ -1195,7 +1195,7 @@ void NMpsStoreCell_exec( ...@@ -1195,7 +1195,7 @@ void NMpsStoreCell_exec(
case NMPS_OPTYPE_FORWARD_FRONT: case NMPS_OPTYPE_FORWARD_FRONT:
/* Insert at front of object front of data */ /* Insert at front of object front of data */
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
if ( object->LastIndex > 0) if ( object->LastIndex > 0)
...@@ -1232,7 +1232,7 @@ void NMpsStoreCell_exec( ...@@ -1232,7 +1232,7 @@ void NMpsStoreCell_exec(
{ {
/* This it not the correct object */ /* This it not the correct object */
object->InFlag = 0; object->InFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
object->Data1_Back = 1; object->Data1_Back = 1;
...@@ -1245,7 +1245,7 @@ void NMpsStoreCell_exec( ...@@ -1245,7 +1245,7 @@ void NMpsStoreCell_exec(
break; break;
case NMPS_OPTYPE_FORWARD_UNIT: case NMPS_OPTYPE_FORWARD_UNIT:
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
if ( object->LastIndex > 0) if ( object->LastIndex > 0)
...@@ -1279,7 +1279,7 @@ void NMpsStoreCell_exec( ...@@ -1279,7 +1279,7 @@ void NMpsStoreCell_exec(
case NMPS_OPTYPE_REVERSE_BACK: case NMPS_OPTYPE_REVERSE_BACK:
/* Insert at rear of object back of data */ /* Insert at rear of object back of data */
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
data_last = (plc_t_DataInfo *) &object->Data1P; data_last = (plc_t_DataInfo *) &object->Data1P;
...@@ -1297,7 +1297,7 @@ void NMpsStoreCell_exec( ...@@ -1297,7 +1297,7 @@ void NMpsStoreCell_exec(
case NMPS_OPTYPE_REVERSE_UNIT: case NMPS_OPTYPE_REVERSE_UNIT:
/* Insert at rear of object all of data */ /* Insert at rear of object all of data */
if ( object->CellFull) { if ( object->CellFull) {
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
data_last = (plc_t_DataInfo *) &object->Data1P; data_last = (plc_t_DataInfo *) &object->Data1P;
...@@ -1320,7 +1320,7 @@ void NMpsStoreCell_exec( ...@@ -1320,7 +1320,7 @@ void NMpsStoreCell_exec(
{ {
/* This it not the correct object */ /* This it not the correct object */
object->InFlag = 0; object->InFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
data_last->Data_Front = 1; data_last->Data_Front = 1;
...@@ -1341,7 +1341,7 @@ void NMpsStoreCell_exec( ...@@ -1341,7 +1341,7 @@ void NMpsStoreCell_exec(
if ( object->LastIndex == 0) if ( object->LastIndex == 0)
{ {
object->OutRearFlag = 0; object->OutRearFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
...@@ -1411,7 +1411,7 @@ void NMpsStoreCell_exec( ...@@ -1411,7 +1411,7 @@ void NMpsStoreCell_exec(
if ( object->LastIndex == 0) if ( object->LastIndex == 0)
{ {
object->OutFrontFlag = 0; object->OutFrontFlag = 0;
nmps_Unlock; lck_UnlockNMps;
return; return;
} }
...@@ -1481,7 +1481,7 @@ void NMpsStoreCell_exec( ...@@ -1481,7 +1481,7 @@ void NMpsStoreCell_exec(
} }
object->NumberOfData = object->DataSelected; object->NumberOfData = object->DataSelected;
nmps_Unlock; lck_UnlockNMps;
} }
/*_* /*_*
......
...@@ -927,9 +927,15 @@ load_backup () ...@@ -927,9 +927,15 @@ load_backup ()
pwr_sClass_AvArea *avp; pwr_sClass_AvArea *avp;
pwr_sClass_DvArea *dvp; pwr_sClass_DvArea *dvp;
pwr_sClass_IvArea *ivp; pwr_sClass_IvArea *ivp;
pwr_sClass_ATvArea *atvp;
pwr_sClass_DTvArea *dtvp;
pwr_sClass_SvArea *svp;
pwr_sClass_InitArea *iavp; pwr_sClass_InitArea *iavp;
pwr_sClass_InitArea *idvp; pwr_sClass_InitArea *idvp;
pwr_sClass_InitArea *iivp; pwr_sClass_InitArea *iivp;
pwr_sClass_InitArea *iatvp;
pwr_sClass_InitArea *idtvp;
pwr_sClass_InitArea *isvp;
pwr_tStatus sts; pwr_tStatus sts;
int i; int i;
pwr_sClass_IOHandler *iop; pwr_sClass_IOHandler *iop;
...@@ -1001,6 +1007,42 @@ load_backup () ...@@ -1001,6 +1007,42 @@ load_backup ()
return; return;
} }
sts = gdh_NameToObjid("pwrNode-active-io-atv", &oid);
if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-atv, &oid), %m", sts);
return;
}
sts = gdh_ObjidToPointer(oid, (void *) &atvp);
if (EVEN(sts)) {
errh_Error("gdh_ObjidToPointer(oid, (void *) &atvp), %m", sts);
return;
}
sts = gdh_NameToObjid("pwrNode-active-io-dtv", &oid);
if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-dtv, &oid), %m", sts);
return;
}
sts = gdh_ObjidToPointer(oid, (void *) &dtvp);
if (EVEN(sts)) {
errh_Error("gdh_ObjidToPointer(oid, (void *) &dtvp), %m", sts);
return;
}
sts = gdh_NameToObjid("pwrNode-active-io-sv", &oid);
if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-sv, &oid), %m", sts);
return;
}
sts = gdh_ObjidToPointer(oid, (void *) &svp);
if (EVEN(sts)) {
errh_Error("gdh_ObjidToPointer(oid, (void *) &svp), %m", sts);
return;
}
sts = gdh_NameToObjid("pwrNode-active-io-iv_init", &oid); sts = gdh_NameToObjid("pwrNode-active-io-iv_init", &oid);
if (EVEN(sts)) { if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-iv_init, &oid), %m", sts); errh_Error("gdh_NameToObjid(pwrNode-active-io-iv_init, &oid), %m", sts);
...@@ -1013,6 +1055,42 @@ load_backup () ...@@ -1013,6 +1055,42 @@ load_backup ()
return; return;
} }
sts = gdh_NameToObjid("pwrNode-active-io-atv_init", &oid);
if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-atv_init, &oid), %m", sts);
return;
}
sts = gdh_ObjidToPointer(oid, (void *) &iatvp);
if (EVEN(sts)) {
errh_Error("gdh_ObjidToPointer(oid, (void *) &iatvp), %m", sts);
return;
}
sts = gdh_NameToObjid("pwrNode-active-io-dtv_init", &oid);
if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-dtv_init, &oid), %m", sts);
return;
}
sts = gdh_ObjidToPointer(oid, (void *) &idtvp);
if (EVEN(sts)) {
errh_Error("gdh_ObjidToPointer(oid, (void *) &idtvp), %m", sts);
return;
}
sts = gdh_NameToObjid("pwrNode-active-io-sv_init", &oid);
if (EVEN(sts)) {
errh_Error("gdh_NameToObjid(pwrNode-active-io-sv_init, &oid), %m", sts);
return;
}
sts = gdh_ObjidToPointer(oid, (void *) &isvp);
if (EVEN(sts)) {
errh_Error("gdh_ObjidToPointer(oid, (void *) &isvp), %m", sts);
return;
}
for (i = 0; i < iop->AvCount; i++) { for (i = 0; i < iop->AvCount; i++) {
pwr_tFloat32 *ifp = gdh_TranslateRtdbPointer(iavp->Value[i]); pwr_tFloat32 *ifp = gdh_TranslateRtdbPointer(iavp->Value[i]);
avp->Value[i]= *ifp; avp->Value[i]= *ifp;
...@@ -1028,11 +1106,29 @@ load_backup () ...@@ -1028,11 +1106,29 @@ load_backup ()
ivp->Value[i] = *iip; ivp->Value[i] = *iip;
} }
for (i = 1; i < iop->ATvCount; i++) {
pwr_tTime *iatp = gdh_TranslateRtdbPointer(iatvp->Value[i]);
atvp->Value[i] = *iatp;
}
for (i = 0; i < iop->DTvCount; i++) {
pwr_tDeltaTime *idtp = gdh_TranslateRtdbPointer(idtvp->Value[i]);
dtvp->Value[i] = *idtp;
}
for (i = 0; i < iop->SvCount; i++) {
char *istrp = gdh_TranslateRtdbPointer(isvp->Value[i]);
strncpy( svp->Value[i], istrp, sizeof(svp->Value[0]));
}
typedef struct { typedef struct {
union { union {
pwr_tFloat32 *f; pwr_tFloat32 *f;
pwr_tInt32 *i; pwr_tInt32 *i;
pwr_tBoolean *b; pwr_tBoolean *b;
pwr_tTime *at;
pwr_tDeltaTime *dt;
pwr_tString80 *str;
} actval_p; } actval_p;
pwr_tUInt32 validx; pwr_tUInt32 validx;
union { union {
...@@ -1046,6 +1142,9 @@ load_backup () ...@@ -1046,6 +1142,9 @@ load_backup ()
pwr_sClass_Di *di; pwr_sClass_Di *di;
pwr_sClass_Do *dox; pwr_sClass_Do *dox;
pwr_sClass_Co *co; pwr_sClass_Co *co;
pwr_sClass_ATv *atv;
pwr_sClass_DTv *dtv;
pwr_sClass_Sv *sv;
} op; } op;
} ini_sRestoreSig; } ini_sRestoreSig;
...@@ -1104,6 +1203,60 @@ load_backup () ...@@ -1104,6 +1203,60 @@ load_backup ()
i++; i++;
} }
ini_sRestoreSig *rsatv = calloc( sizeof(ini_sRestoreSig), iop->ATvCount);
i = 1;
for ( sts = gdh_GetClassListAttrRef(pwr_cClass_ATv, &aref);
ODD(sts);
sts = gdh_GetNextAttrRef(pwr_cClass_ATv, &aref, &aref)) {
if ( i >= iop->ATvCount) break;
sts = gdh_AttrRefToPointer( &aref, (pwr_tAddress *)&rsatv[i].op.atv);
if ( EVEN(sts)) {
errh_Error("gdh_AttrRefToPointer ATv, %m", sts);
return;
}
rsatv[i].actval_p.at = rsatv[i].op.atv->ActualValue;
rsatv[i].validx = rsatv[i].op.atv->ValueIndex;
i++;
}
ini_sRestoreSig *rsdtv = calloc( sizeof(ini_sRestoreSig), iop->DTvCount);
i = 0;
for ( sts = gdh_GetClassListAttrRef(pwr_cClass_DTv, &aref);
ODD(sts);
sts = gdh_GetNextAttrRef(pwr_cClass_DTv, &aref, &aref)) {
if ( i >= iop->DTvCount) break;
sts = gdh_AttrRefToPointer( &aref, (pwr_tAddress *)&rsdtv[i].op.dtv);
if ( EVEN(sts)) {
errh_Error("gdh_AttrRefToPointer DTv, %m", sts);
return;
}
rsdtv[i].actval_p.dt = rsdtv[i].op.dtv->ActualValue;
rsdtv[i].validx = rsdtv[i].op.dtv->ValueIndex;
i++;
}
ini_sRestoreSig *rssv = calloc( sizeof(ini_sRestoreSig), iop->SvCount);
i = 0;
for ( sts = gdh_GetClassListAttrRef(pwr_cClass_Sv, &aref);
ODD(sts);
sts = gdh_GetNextAttrRef(pwr_cClass_Sv, &aref, &aref)) {
if ( i >= iop->SvCount) break;
sts = gdh_AttrRefToPointer( &aref, (pwr_tAddress *)&rssv[i].op.sv);
if ( EVEN(sts)) {
errh_Error("gdh_AttrRefToPointer Sv, %m", sts);
return;
}
rssv[i].actval_p.str = rssv[i].op.sv->ActualValue;
rssv[i].validx = rssv[i].op.sv->ValueIndex;
i++;
}
ini_sRestoreSig *rsai = calloc( sizeof(ini_sRestoreSig), iop->AiCount); ini_sRestoreSig *rsai = calloc( sizeof(ini_sRestoreSig), iop->AiCount);
i = 0; i = 0;
for ( sts = gdh_GetClassListAttrRef(pwr_cClass_Ai, &aref); for ( sts = gdh_GetClassListAttrRef(pwr_cClass_Ai, &aref);
...@@ -1258,6 +1411,24 @@ load_backup () ...@@ -1258,6 +1411,24 @@ load_backup ()
} }
free( rsiv); free( rsiv);
for ( i = 1; i < iop->ATvCount; i++) {
rsatv[i].op.atv->ActualValue = rsatv[i].actval_p.at;
rsatv[i].op.atv->ValueIndex = rsatv[i].validx;
}
free( rsatv);
for ( i = 0; i < iop->DTvCount; i++) {
rsdtv[i].op.dtv->ActualValue = rsdtv[i].actval_p.dt;
rsdtv[i].op.dtv->ValueIndex = rsdtv[i].validx;
}
free( rsdtv);
for ( i = 0; i < iop->SvCount; i++) {
rssv[i].op.sv->ActualValue = rssv[i].actval_p.str;
rssv[i].op.sv->ValueIndex = rssv[i].validx;
}
free( rssv);
for ( i = 0; i < iop->AiCount; i++) { for ( i = 0; i < iop->AiCount; i++) {
rsai[i].op.ai->ActualValue = rsai[i].actval_p.f; rsai[i].op.ai->ActualValue = rsai[i].actval_p.f;
rsai[i].op.ai->ValueIndex = rsai[i].validx; rsai[i].op.ai->ValueIndex = rsai[i].validx;
...@@ -1317,6 +1488,21 @@ load_backup () ...@@ -1317,6 +1488,21 @@ load_backup ()
pwr_tInt32 *iip = gdh_TranslateRtdbPointer(iivp->Value[i]); pwr_tInt32 *iip = gdh_TranslateRtdbPointer(iivp->Value[i]);
*iip = ivp->Value[i]; *iip = ivp->Value[i];
} }
for (i = 1; i < iop->ATvCount; i++) {
pwr_tTime *iatp = gdh_TranslateRtdbPointer(iatvp->Value[i]);
*iatp = atvp->Value[i];
}
for (i = 0; i < iop->DTvCount; i++) {
pwr_tDeltaTime *idtp = gdh_TranslateRtdbPointer(idtvp->Value[i]);
*idtp = dtvp->Value[i];
}
for (i = 0; i < iop->SvCount; i++) {
char *istrp = gdh_TranslateRtdbPointer(isvp->Value[i]);
strncpy( istrp, svp->Value[i], 80);
}
} }
static void ini_errl_cb( void *userdata, char *str, char severity, pwr_tStatus sts, int anix, static void ini_errl_cb( void *userdata, char *str, char severity, pwr_tStatus sts, int anix,
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
#include "rt_que.h" #include "rt_que.h"
#include "rt_csup.h" #include "rt_csup.h"
#include "rt_ini_event.h" #include "rt_ini_event.h"
#include "rt_nmps_lock.h" #include "rt_lck.h"
#include "rt_aproc.h" #include "rt_aproc.h"
#include "rt_pwr_msg.h" #include "rt_pwr_msg.h"
...@@ -208,7 +208,9 @@ int main ( ...@@ -208,7 +208,9 @@ int main (
stop_threads(pp); stop_threads(pp);
clean_all(pp); clean_all(pp);
nmps_delete_lock( &sts); lck_Delete( &sts, lck_eLock_NMps);
lck_Delete( &sts, lck_eLock_Time);
lck_Delete( &sts, lck_eLock_Str);
break; break;
case ini_mEvent_oldPlcStop: case ini_mEvent_oldPlcStop:
errh_SetStatus( PWR__SRVTERM); errh_SetStatus( PWR__SRVTERM);
...@@ -258,12 +260,15 @@ init_process ( char *name) ...@@ -258,12 +260,15 @@ init_process ( char *name)
exit(sts); exit(sts);
} }
// nmps_create_lock( &sts); lck_Create( &sts, lck_eLock_Time);
// if (EVEN(sts)) { if (EVEN(sts))
// errh_Fatal("nmps_create_lock, %m", sts); errh_Fatal("lock create time, %m", sts);
// errh_SetStatus( PWR__SRVTERM); lck_Create( &sts, lck_eLock_Str);
// exit(sts); if (EVEN(sts))
//} errh_Fatal("lock create str, %m", sts);
lck_Create( &sts, lck_eLock_NMps);
if (EVEN(sts))
errh_Fatal("lock create NMps, %m", sts);
if ( strstr( name, "rt_plc_core") != 0) if ( strstr( name, "rt_plc_core") != 0)
pp->is_core = 1; pp->is_core = 1;
...@@ -427,6 +432,7 @@ init_plc ( ...@@ -427,6 +432,7 @@ init_plc (
init_grafcet(pp); init_grafcet(pp);
link_io_base_areas(pp); link_io_base_areas(pp);
pp->system_time = (pwr_tTime *)pp->base.atv_a.p;
return sts; return sts;
} }
...@@ -555,6 +561,9 @@ link_io_base_areas ( ...@@ -555,6 +561,9 @@ link_io_base_areas (
dlink_area((plc_sDlink *)&pp->base.ii_a, "pwrNode-active-io-ii", pp->IOHandler->IiCount * sizeof(pwr_tInt32)); dlink_area((plc_sDlink *)&pp->base.ii_a, "pwrNode-active-io-ii", pp->IOHandler->IiCount * sizeof(pwr_tInt32));
dlink_area((plc_sDlink *)&pp->base.io_a, "pwrNode-active-io-io", pp->IOHandler->IoCount * sizeof(pwr_tInt32)); dlink_area((plc_sDlink *)&pp->base.io_a, "pwrNode-active-io-io", pp->IOHandler->IoCount * sizeof(pwr_tInt32));
dlink_area((plc_sDlink *)&pp->base.iv_a, "pwrNode-active-io-iv", pp->IOHandler->IvCount * sizeof(pwr_tInt32)); dlink_area((plc_sDlink *)&pp->base.iv_a, "pwrNode-active-io-iv", pp->IOHandler->IvCount * sizeof(pwr_tInt32));
dlink_area((plc_sDlink *)&pp->base.atv_a, "pwrNode-active-io-atv", pp->IOHandler->ATvCount * sizeof(pwr_tTime));
dlink_area((plc_sDlink *)&pp->base.dtv_a, "pwrNode-active-io-dtv", pp->IOHandler->DTvCount * sizeof(pwr_tDeltaTime));
dlink_area((plc_sDlink *)&pp->base.sv_a, "pwrNode-active-io-sv", pp->IOHandler->SvCount * sizeof(pwr_tString80));
dlink_area((plc_sDlink *)&pp->base.bi_a, "pwrNode-active-io-bi", pp->IOHandler->BiSize); dlink_area((plc_sDlink *)&pp->base.bi_a, "pwrNode-active-io-bi", pp->IOHandler->BiSize);
dlink_area((plc_sDlink *)&pp->base.bo_a, "pwrNode-active-io-bo", pp->IOHandler->BoSize); dlink_area((plc_sDlink *)&pp->base.bo_a, "pwrNode-active-io-bo", pp->IOHandler->BoSize);
dlink_area((plc_sDlink *)&pp->base.av_i, "pwrNode-active-io-av_init", pp->IOHandler->AvCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.av_i, "pwrNode-active-io-av_init", pp->IOHandler->AvCount * sizeof(pwr_tUInt64));
...@@ -566,6 +575,9 @@ link_io_base_areas ( ...@@ -566,6 +575,9 @@ link_io_base_areas (
dlink_area((plc_sDlink *)&pp->base.do_i, "pwrNode-active-io-do_init", pp->IOHandler->DoCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.do_i, "pwrNode-active-io-do_init", pp->IOHandler->DoCount * sizeof(pwr_tUInt64));
dlink_area((plc_sDlink *)&pp->base.ii_i, "pwrNode-active-io-ii_init", pp->IOHandler->IiCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.ii_i, "pwrNode-active-io-ii_init", pp->IOHandler->IiCount * sizeof(pwr_tUInt64));
dlink_area((plc_sDlink *)&pp->base.io_i, "pwrNode-active-io-io_init", pp->IOHandler->IoCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.io_i, "pwrNode-active-io-io_init", pp->IOHandler->IoCount * sizeof(pwr_tUInt64));
dlink_area((plc_sDlink *)&pp->base.atv_i, "pwrNode-active-io-iatv_init", pp->IOHandler->ATvCount * sizeof(pwr_tTime));
dlink_area((plc_sDlink *)&pp->base.dtv_i, "pwrNode-active-io-idtv_init", pp->IOHandler->DTvCount * sizeof(pwr_tDeltaTime));
dlink_area((plc_sDlink *)&pp->base.sv_i, "pwrNode-active-io-isv_init", pp->IOHandler->SvCount * sizeof(pwr_tString80));
dlink_area((plc_sDlink *)&pp->base.bi_i, "pwrNode-active-io-bi_init", pp->IOHandler->BiCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.bi_i, "pwrNode-active-io-bi_init", pp->IOHandler->BiCount * sizeof(pwr_tUInt64));
dlink_area((plc_sDlink *)&pp->base.bi_isize, "pwrNode-active-io-bi_initsize", pp->IOHandler->BiCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.bi_isize, "pwrNode-active-io-bi_initsize", pp->IOHandler->BiCount * sizeof(pwr_tUInt64));
dlink_area((plc_sDlink *)&pp->base.bo_i, "pwrNode-active-io-bo_init", pp->IOHandler->BoCount * sizeof(pwr_tUInt64)); dlink_area((plc_sDlink *)&pp->base.bo_i, "pwrNode-active-io-bo_init", pp->IOHandler->BoCount * sizeof(pwr_tUInt64));
...@@ -617,6 +629,15 @@ link_io_copy_areas ( ...@@ -617,6 +629,15 @@ link_io_copy_areas (
tp->copy.iv_a = pp->base.iv_a; tp->copy.iv_a = pp->base.iv_a;
tp->copy.iv_a.p = calloc(1, tp->copy.iv_a.size); tp->copy.iv_a.p = calloc(1, tp->copy.iv_a.size);
tp->copy.atv_a = pp->base.atv_a;
tp->copy.atv_a.p = calloc(1, tp->copy.atv_a.size);
tp->copy.dtv_a = pp->base.dtv_a;
tp->copy.dtv_a.p = calloc(1, tp->copy.dtv_a.size);
tp->copy.sv_a = pp->base.sv_a;
tp->copy.sv_a.p = calloc(1, tp->copy.sv_a.size);
tp->copy.bi_a = pp->base.bi_a; tp->copy.bi_a = pp->base.bi_a;
tp->copy.bi_a.p = calloc(1, tp->copy.bi_a.size); tp->copy.bi_a.p = calloc(1, tp->copy.bi_a.size);
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include "rt_subc.h" #include "rt_subc.h"
#include "rt_sanc.h" #include "rt_sanc.h"
#include "rt_dl.h" #include "rt_dl.h"
#include "rt_lck.h"
#if defined (OS_LYNX) || defined(OS_LINUX) || defined OS_MACOS #if defined (OS_LYNX) || defined(OS_LINUX) || defined OS_MACOS
# define gdh_Lock pthread_mutex_lock(&gdbroot->thread_lock); gdb_Lock # define gdh_Lock pthread_mutex_lock(&gdbroot->thread_lock); gdb_Lock
...@@ -5159,3 +5160,261 @@ pwr_tStatus gdh_GetLocalClassList( int cidcnt, pwr_tCid *cid, int attrobjects, p ...@@ -5159,3 +5160,261 @@ pwr_tStatus gdh_GetLocalClassList( int cidcnt, pwr_tCid *cid, int attrobjects, p
array_Close( arr); array_Close( arr);
return GDH__SUCCESS; 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
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
void gdh_GetTimeDL(
pwr_tTime *atp, /**< Direct link to time attribute */
pwr_tTime *time /**< Receives the requested time */
)
{
lck_Lock(lck_eLock_Time);
*time = *atp;
lck_Unlock(lck_eLock_Time);
}
/**
* @brief Thread save function to store a direct linked absolute time value.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
void gdh_SetTimeDL(
pwr_tTime *atp, /**< Direct link to time attribute */
pwr_tTime *time /**< Time value to set */
)
{
if ( time) {
lck_Lock(lck_eLock_Time);
*atp = *time;
lck_Unlock(lck_eLock_Time);
}
else {
/* Set current time */
lck_Lock(lck_eLock_Time);
time_GetTime( atp);
lck_Unlock(lck_eLock_Time);
}
}
/**
* @brief Thread save function to fetch a direct linked delta time value.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
void gdh_GetDeltaTimeDL(
pwr_tDeltaTime *dtp, /**< Direct link to time attribute */
pwr_tDeltaTime *time /**< Receives the requested time */
)
{
lck_Lock(lck_eLock_Time);
*time = *dtp;
lck_Unlock(lck_eLock_Time);
}
/**
* @brief Thread save function to store a direct linked delta time value.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
void gdh_SetDeltaTimeDL(
pwr_tDeltaTime *dtp, /**< Direct link to time attribute */
pwr_tDeltaTime *time /**< Time value to set */
)
{
lck_Lock(lck_eLock_Time);
*dtp = *time;
lck_Unlock(lck_eLock_Time);
}
/**
* @brief Thread save function to fetch a direct linked string value.
* Sets the string lock to ensure that the string is not modified during
* the operation.
* The application first has to attach the string lock with a call to
* lck_Create(&sts, lck_eLock_Str).
*
* @return pwr_tStatus
*/
void gdh_GetStrDL(
char *sp, /**< Direct link to string attribute */
char *str, /**< Receives the requested string */
int size /**< Size of string */
)
{
lck_Lock(lck_eLock_Str);
strncpy( str, sp, size);
lck_Unlock(lck_eLock_Str);
}
/**
* @brief Thread save function to store a direct linked string value.
* Sets the string lock to ensure that the string is not modified during
* the operation.
* The application first has to attach the string lock with a call to
* lck_Create(&sts, lck_eLock_Str).
*
* @return pwr_tStatus
*/
void gdh_SetStrDL(
char *sp, /**< Direct link to string attribute */
char *str, /**< Time value to set */
int size /**< Size of string */
)
{
lck_Lock(lck_eLock_Str);
strncpy( sp, str, size);
lck_Unlock(lck_eLock_Str);
}
/**
* @brief Fetch an absolute time value from an attribute.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
pwr_tStatus gdh_GetObjectInfoTime(
char *name, /**< Attribute name */
pwr_tTime *time /**< Receives the requested time */
)
{
pwr_tStatus sts;
lck_Lock(lck_eLock_Time);
sts = gdh_GetObjectInfo( name, (pwr_tAddress)time, sizeof(pwr_tTime));
lck_Unlock(lck_eLock_Time);
return sts;
}
/**
* @brief Store an absolute time value in an attribute.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
pwr_tStatus gdh_SetObjectInfoTime(
char *name, /**< Attribute name */
pwr_tTime *time /**< Time to set */
)
{
pwr_tStatus sts;
lck_Lock(lck_eLock_Time);
sts = gdh_SetObjectInfo( name, (void *)time, sizeof(pwr_tTime));
lck_Unlock(lck_eLock_Time);
return sts;
}
/**
* @brief Fetch an delta time value from an attribute.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
pwr_tStatus gdh_GetObjectInfoDeltaTime(
char *name, /**< Attribute name */
pwr_tDeltaTime *time /**< Receives the requested time */
)
{
pwr_tStatus sts;
lck_Lock(lck_eLock_Time);
sts = gdh_GetObjectInfo( name, (void *)time, sizeof(pwr_tDeltaTime));
lck_Unlock(lck_eLock_Time);
return sts;
}
/**
* @brief Store a delta time value in an attribute.
* Sets the time lock to ensure that the time is not modified during
* the operation.
* The application first has to attach the time lock with a call to
* lck_Create(&sts, lck_eLock_Time).
*
* @return pwr_tStatus
*/
pwr_tStatus gdh_SetObjectInfoDeltaTime(
char *name, /**< Attribute name */
pwr_tDeltaTime *time /**< Time to set */
)
{
pwr_tStatus sts;
lck_Lock(lck_eLock_Time);
sts = gdh_SetObjectInfo( name, (void *)time, sizeof(pwr_tDeltaTime));
lck_Unlock(lck_eLock_Time);
return sts;
}
/**
* @brief Fetch a string value from an attribute.
* Sets the string lock to ensure that the string is not modified during
* the operation.
* The application first has to attach the string lock with a call to
* lck_Create(&sts, lck_eLock_Str).
*
* @return pwr_tStatus
*/
pwr_tStatus gdh_GetObjectInfoStr(
char *name, /**< Attribute name */
char *str, /**< Receives the requested string */
int size /**< String size */
)
{
pwr_tStatus sts;
lck_Lock(lck_eLock_Str);
sts = gdh_GetObjectInfo( name, (void *)str, size);
lck_Unlock(lck_eLock_Str);
return sts;
}
/**
* @brief Store a string value in an attribute.
* Sets the string lock to ensure that the string is not modified during
* the operation.
* The application first has to attach the string lock with a call to
* lck_Create(&sts, lck_eLock_Str).
*
* @return pwr_tStatus
*/
pwr_tStatus gdh_SetObjectInfoStr(
char *name, /**< Attribute name */
char *str, /**< String to set */
int size /**< String size */
)
{
pwr_tStatus sts;
lck_Lock(lck_eLock_Str);
sts = gdh_SetObjectInfo( name, (void *)str, size);
lck_Unlock(lck_eLock_Str);
return sts;
}
...@@ -861,6 +861,20 @@ gdh_GetLocalClassList( ...@@ -861,6 +861,20 @@ gdh_GetLocalClassList(
int *listcnt int *listcnt
); );
/* 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);
void gdh_GetDeltaTimeDL( pwr_tDeltaTime *dtp, pwr_tDeltaTime *time);
void gdh_SetDeltaTimeDL( pwr_tDeltaTime *dtp, pwr_tDeltaTime *time);
void gdh_GetStrDL( char *sp, char *str, int size);
void gdh_SetStrDL( char *sp, char *str, int size);
pwr_tStatus gdh_GetObjectInfoTime( char *name, pwr_tTime *time);
pwr_tStatus gdh_SetObjectInfoTime( char *name, pwr_tTime *time);
pwr_tStatus gdh_GetObjectInfoDeltaTime( char *name, pwr_tDeltaTime *time);
pwr_tStatus gdh_SetObjectInfoDeltaTime( char *name, pwr_tDeltaTime *time);
pwr_tStatus gdh_GetObjectInfoStr( char *name, char *str, int size);
pwr_tStatus gdh_SetObjectInfoStr( char *name, char *str, int size);
/** @} */ /** @} */
#if defined __cplusplus #if defined __cplusplus
......
...@@ -1920,7 +1920,8 @@ create_active_io () ...@@ -1920,7 +1920,8 @@ create_active_io ()
pwr_tStatus sts; pwr_tStatus sts;
pwr_tObjid oid; pwr_tObjid oid;
pwr_tAttrRef aref; pwr_tAttrRef aref;
int ai_cnt, ao_cnt, av_cnt, di_cnt, do_cnt, dv_cnt, ii_cnt, io_cnt, iv_cnt, co_cnt, bi_cnt, bo_cnt; int ai_cnt, ao_cnt, av_cnt, di_cnt, do_cnt, dv_cnt, ii_cnt, io_cnt, iv_cnt;
int atv_cnt, dtv_cnt, sv_cnt, co_cnt, bi_cnt, bo_cnt;
int bi_size, bo_size; int bi_size, bo_size;
pwr_tCid subcid; pwr_tCid subcid;
pwr_tAttrRef actval_aref; pwr_tAttrRef actval_aref;
...@@ -1984,6 +1985,24 @@ create_active_io () ...@@ -1984,6 +1985,24 @@ create_active_io ()
sts = gdh_GetNextAttrRef( pwr_cClass_Iv, &aref, &aref)) sts = gdh_GetNextAttrRef( pwr_cClass_Iv, &aref, &aref))
iv_cnt++; iv_cnt++;
atv_cnt = 1;
for ( sts = gdh_GetClassListAttrRef( pwr_cClass_ATv, &aref);
ODD(sts);
sts = gdh_GetNextAttrRef( pwr_cClass_ATv, &aref, &aref))
atv_cnt++;
dtv_cnt = 0;
for ( sts = gdh_GetClassListAttrRef( pwr_cClass_DTv, &aref);
ODD(sts);
sts = gdh_GetNextAttrRef( pwr_cClass_DTv, &aref, &aref))
dtv_cnt++;
sv_cnt = 0;
for ( sts = gdh_GetClassListAttrRef( pwr_cClass_Sv, &aref);
ODD(sts);
sts = gdh_GetNextAttrRef( pwr_cClass_Sv, &aref, &aref))
sv_cnt++;
co_cnt = 0; co_cnt = 0;
for ( sts = gdh_GetClassListAttrRef( pwr_cClass_Co, &aref); for ( sts = gdh_GetClassListAttrRef( pwr_cClass_Co, &aref);
ODD(sts); ODD(sts);
...@@ -2073,6 +2092,15 @@ create_active_io () ...@@ -2073,6 +2092,15 @@ create_active_io ()
sts = gdh_CreateObject("pwrNode-active-io-iv", pwr_cClass_IvArea, sts = gdh_CreateObject("pwrNode-active-io-iv", pwr_cClass_IvArea,
iv_cnt * sizeof(((pwr_sClass_IvArea*)0)->Value[0]), iv_cnt * sizeof(((pwr_sClass_IvArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid); &oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-atv", pwr_cClass_ATvArea,
atv_cnt * sizeof(((pwr_sClass_ATvArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-dtv", pwr_cClass_DTvArea,
dtv_cnt * sizeof(((pwr_sClass_DTvArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-sv", pwr_cClass_SvArea,
sv_cnt * sizeof(((pwr_sClass_SvArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-bi", pwr_cClass_BiArea, sts = gdh_CreateObject("pwrNode-active-io-bi", pwr_cClass_BiArea,
bi_size, bi_size,
&oid, pwr_cNObjid, 0, pwr_cNObjid); &oid, pwr_cNObjid, 0, pwr_cNObjid);
...@@ -2106,6 +2134,15 @@ create_active_io () ...@@ -2106,6 +2134,15 @@ create_active_io ()
sts = gdh_CreateObject("pwrNode-active-io-io_init", pwr_cClass_InitArea, sts = gdh_CreateObject("pwrNode-active-io-io_init", pwr_cClass_InitArea,
io_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]), io_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid); &oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-atv_init", pwr_cClass_InitArea,
atv_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-dtv_init", pwr_cClass_InitArea,
dtv_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-sv_init", pwr_cClass_InitArea,
sv_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid);
sts = gdh_CreateObject("pwrNode-active-io-bi_init", pwr_cClass_InitArea, sts = gdh_CreateObject("pwrNode-active-io-bi_init", pwr_cClass_InitArea,
bi_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]), bi_cnt * sizeof(((pwr_sClass_InitArea*)0)->Value[0]),
&oid, pwr_cNObjid, 0, pwr_cNObjid); &oid, pwr_cNObjid, 0, pwr_cNObjid);
...@@ -2171,6 +2208,12 @@ delete_old_io () ...@@ -2171,6 +2208,12 @@ delete_old_io ()
if(ODD(sts)) gdh_DeleteObject(oid); if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-iv", &oid); sts = gdh_NameToObjid("pwrNode-old-io-iv", &oid);
if(ODD(sts)) gdh_DeleteObject(oid); if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-atv", &oid);
if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-dtv", &oid);
if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-sv", &oid);
if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-bi", &oid); sts = gdh_NameToObjid("pwrNode-old-io-bi", &oid);
if(ODD(sts)) gdh_DeleteObject(oid); if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-bo", &oid); sts = gdh_NameToObjid("pwrNode-old-io-bo", &oid);
...@@ -2193,6 +2236,12 @@ delete_old_io () ...@@ -2193,6 +2236,12 @@ delete_old_io ()
if(ODD(sts)) gdh_DeleteObject(oid); if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-io_init", &oid); sts = gdh_NameToObjid("pwrNode-old-io-io_init", &oid);
if(ODD(sts)) gdh_DeleteObject(oid); if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-atv_init", &oid);
if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-dtv_init", &oid);
if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-sv_init", &oid);
if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-bi_init", &oid); sts = gdh_NameToObjid("pwrNode-old-io-bi_init", &oid);
if(ODD(sts)) gdh_DeleteObject(oid); if(ODD(sts)) gdh_DeleteObject(oid);
sts = gdh_NameToObjid("pwrNode-old-io-bi_initsize", &oid); sts = gdh_NameToObjid("pwrNode-old-io-bi_initsize", &oid);
......
...@@ -1185,6 +1185,199 @@ io_init_iv_signals ( ...@@ -1185,6 +1185,199 @@ io_init_iv_signals (
return sts; return sts;
} }
/*----------------------------------------------------------------------------*\
Initialization of atv signals.
\*----------------------------------------------------------------------------*/
static pwr_tStatus
io_init_atv_signals (
pwr_sClass_IOHandler *io_op)
{
pwr_tObjid area_objid;
pwr_sAttrRef aref;
pwr_sClass_ATvArea *area_op;
pwr_sClass_ATv *o;
pwr_tStatus sts;
pwr_tTime *p;
pwr_tInt32 atv_count=0;
pwr_sClass_InitArea *iarea_op;
/* Get pointer to area-object */
sts = gdh_NameToObjid( "pwrNode-active-io-atv", &area_objid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( area_objid, (void *) &area_op);
if (EVEN(sts)) return sts;
/* Get pointer to area-object */
sts = gdh_NameToObjid( "pwrNode-active-io-atv_init", &area_objid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( area_objid, (void *) &iarea_op);
if (EVEN(sts)) return sts;
/* First index is reserved for system time */
p = area_op->Value + 1;
atv_count++;
/* Loop ATv-object */
sts = gdh_GetClassListAttrRef( pwr_cClass_ATv, &aref);
if (EVEN(sts) && sts != GDH__NOSUCHOBJ && sts != GDH__BADOBJTYPE && sts != GDH__NO_TYPE) {
errh_Error("Get class list of ATv\n%m", sts);
}
while (ODD(sts)) {
sts = gdh_AttrRefToPointer( &aref, (void *)&o);
if (EVEN(sts) && sts != GDH__NO_TYPE) return sts;
if (sts != GDH__REMOTE) {
gdh_StoreRtdbPointer( (unsigned long *)&o->ActualValue, p);
o->ValueIndex = atv_count;
gdh_StoreRtdbPointer( (unsigned long *)&iarea_op->Value[atv_count], &o->InitialValue);
atv_count++;
p++;
}
sts = gdh_GetNextAttrRef( pwr_cClass_ATv, &aref, &aref);
if (EVEN(sts) && sts != GDH__NO_TYPE) return sts;
}
if (sts == GDH__NO_TYPE || sts == GDH__NOSUCHOBJ || sts == GDH__BADOBJTYPE)
sts = IO__SUCCESS;
io_op->ATvCount = atv_count;
return sts;
}
/*----------------------------------------------------------------------------*\
Initialization of dtv signals.
\*----------------------------------------------------------------------------*/
static pwr_tStatus
io_init_dtv_signals (
pwr_sClass_IOHandler *io_op)
{
pwr_tObjid area_objid;
pwr_sAttrRef aref;
pwr_sClass_DTvArea *area_op;
pwr_sClass_DTv *o;
pwr_tStatus sts;
pwr_tDeltaTime *p;
pwr_tInt32 dtv_count=0;
pwr_sClass_InitArea *iarea_op;
/* Get pointer to area-object */
sts = gdh_NameToObjid( "pwrNode-active-io-dtv", &area_objid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( area_objid, (void *) &area_op);
if (EVEN(sts)) return sts;
/* Get pointer to area-object */
sts = gdh_NameToObjid( "pwrNode-active-io-dtv_init", &area_objid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( area_objid, (void *) &iarea_op);
if (EVEN(sts)) return sts;
p = area_op->Value;
/* Loop DTv-object */
sts = gdh_GetClassListAttrRef( pwr_cClass_DTv, &aref);
if (EVEN(sts) && sts != GDH__NOSUCHOBJ && sts != GDH__BADOBJTYPE && sts != GDH__NO_TYPE) {
errh_Error("Get class list of DTv\n%m", sts);
}
while (ODD(sts)) {
sts = gdh_AttrRefToPointer( &aref, (void *)&o);
if (EVEN(sts) && sts != GDH__NO_TYPE) return sts;
if (sts != GDH__REMOTE) {
gdh_StoreRtdbPointer( (unsigned long *)&o->ActualValue, p);
o->ValueIndex = dtv_count;
gdh_StoreRtdbPointer( (unsigned long *)&iarea_op->Value[dtv_count], &o->InitialValue);
dtv_count++;
p++;
}
sts = gdh_GetNextAttrRef( pwr_cClass_DTv, &aref, &aref);
if (EVEN(sts) && sts != GDH__NO_TYPE) return sts;
}
if (sts == GDH__NO_TYPE || sts == GDH__NOSUCHOBJ || sts == GDH__BADOBJTYPE)
sts = IO__SUCCESS;
io_op->DTvCount = dtv_count;
return sts;
}
/*----------------------------------------------------------------------------*\
Initialization of sv signals.
\*----------------------------------------------------------------------------*/
static pwr_tStatus
io_init_sv_signals (
pwr_sClass_IOHandler *io_op)
{
pwr_tObjid area_objid;
pwr_sAttrRef aref;
pwr_sClass_SvArea *area_op;
pwr_sClass_Sv *o;
pwr_tStatus sts;
pwr_tString80 *p;
pwr_tInt32 sv_count=0;
pwr_sClass_InitArea *iarea_op;
/* Get pointer to area-object */
sts = gdh_NameToObjid( "pwrNode-active-io-sv", &area_objid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( area_objid, (void *) &area_op);
if (EVEN(sts)) return sts;
/* Get pointer to area-object */
sts = gdh_NameToObjid( "pwrNode-active-io-sv_init", &area_objid);
if (EVEN(sts)) return sts;
sts = gdh_ObjidToPointer( area_objid, (void *) &iarea_op);
if (EVEN(sts)) return sts;
p = area_op->Value;
/* Loop Sv-object */
sts = gdh_GetClassListAttrRef( pwr_cClass_Sv, &aref);
if (EVEN(sts) && sts != GDH__NOSUCHOBJ && sts != GDH__BADOBJTYPE && sts != GDH__NO_TYPE) {
errh_Error("Get class list of Sv\n%m", sts);
}
while (ODD(sts)) {
sts = gdh_AttrRefToPointer( &aref, (void *)&o);
if (EVEN(sts) && sts != GDH__NO_TYPE) return sts;
if (sts != GDH__REMOTE) {
gdh_StoreRtdbPointer( (unsigned long *)&o->ActualValue, p);
o->ValueIndex = sv_count;
gdh_StoreRtdbPointer( (unsigned long *)&iarea_op->Value[sv_count], &o->InitialValue);
sv_count++;
p++;
}
sts = gdh_GetNextAttrRef( pwr_cClass_Sv, &aref, &aref);
if (EVEN(sts) && sts != GDH__NO_TYPE) return sts;
}
if (sts == GDH__NO_TYPE || sts == GDH__NOSUCHOBJ || sts == GDH__BADOBJTYPE)
sts = IO__SUCCESS;
io_op->SvCount = sv_count;
return sts;
}
/*----------------------------------------------------------------------------*\ /*----------------------------------------------------------------------------*\
Initialization of Bi signals and channels. Initialization of Bi signals and channels.
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
...@@ -1616,6 +1809,15 @@ pwr_tStatus io_init_signals( void) ...@@ -1616,6 +1809,15 @@ pwr_tStatus io_init_signals( void)
sts = io_init_iv_signals( io_op); sts = io_init_iv_signals( io_op);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = io_init_atv_signals( io_op);
if ( EVEN(sts)) return sts;
sts = io_init_dtv_signals( io_op);
if ( EVEN(sts)) return sts;
sts = io_init_sv_signals( io_op);
if ( EVEN(sts)) return sts;
sts = io_init_bi_signals( io_op); sts = io_init_bi_signals( io_op);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 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 <string.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "pwr.h"
#include "rt_sect.h"
#include "rt_nmps_lock.h"
sect_sHead *nmps_locksect = 0;
void nmps_create_lock( pwr_tStatus *sts)
{
pwr_tBoolean created;
if ( !nmps_locksect) {
nmps_locksect = sect_Alloc( sts, &created, 0, sizeof(sect_sMutex),
nmps_cName_Lock, sect_mFlags_Create);
if ( ODD(*sts) && created)
sect_InitLock( sts, nmps_locksect, (sect_sMutex *)nmps_locksect->base);
}
}
void nmps_unlink_lock( pwr_tStatus *sts)
{
if ( nmps_locksect) {
if ( shmdt( nmps_locksect) == -1)
*sts = 0;
else
*sts = 1;
}
}
void nmps_delete_lock( pwr_tStatus *sts)
{
if ( nmps_locksect) {
char segname[128];
char busid[8];
char *str = getenv(pwr_dEnvBusId);
key_t key;
int shm_id;
struct shmid_ds ds;
strncpy( busid, (str ? str : "XXX"), 3);
busid[3] = '\0';
sprintf(segname, "%s_%.3s", nmps_cName_Lock, busid);
key = ftok(segname, 'P');
shm_id = shmget(key, 0, 0660);
if ( shmdt( nmps_locksect->base) == -1)
printf( "Detach of nmps lock failed\n");
if ( shmctl(shm_id, IPC_RMID, &ds) == -1)
printf( "Remove of nmps lock failed\n");
// unlink(segname);
posix_sem_unlink(segname);
sect_Free( sts, nmps_locksect);
}
}
\ No newline at end of file
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2017 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 rt_nmps_lock_h
#define rt_nmps_lock_h
#if defined __cplusplus
extern "C" {
#endif
#include "pwr.h"
#include "rt_sect.h"
#define nmps_cName_Lock "/tmp/pwr_nmps_lock"
#define nmps_Lock sect_Lock( NULL, nmps_locksect, (sect_sMutex *)nmps_locksect->base);
#define nmps_Unlock sect_Unlock( NULL, nmps_locksect, (sect_sMutex *)nmps_locksect->base);
extern sect_sHead *nmps_locksect;
void nmps_create_lock( pwr_tStatus *sts);
void nmps_delete_lock( pwr_tStatus *sts);
void nmps_unlink_lock( pwr_tStatus *sts);
#if defined __cplusplus
}
#endif
#endif
\ No newline at end of file
...@@ -116,6 +116,9 @@ typedef struct { ...@@ -116,6 +116,9 @@ typedef struct {
IO_AREA(pwr_sClass_IiArea) ii_a; IO_AREA(pwr_sClass_IiArea) ii_a;
IO_AREA(pwr_sClass_IoArea) io_a; IO_AREA(pwr_sClass_IoArea) io_a;
IO_AREA(pwr_sClass_IvArea) iv_a; IO_AREA(pwr_sClass_IvArea) iv_a;
IO_AREA(pwr_sClass_ATvArea) atv_a;
IO_AREA(pwr_sClass_DTvArea) dtv_a;
IO_AREA(pwr_sClass_SvArea) sv_a;
IO_AREA(pwr_sClass_BiArea) bi_a; IO_AREA(pwr_sClass_BiArea) bi_a;
IO_AREA(pwr_sClass_BoArea) bo_a; IO_AREA(pwr_sClass_BoArea) bo_a;
IO_AREA(pwr_sClass_InitArea) av_i; IO_AREA(pwr_sClass_InitArea) av_i;
...@@ -127,6 +130,9 @@ typedef struct { ...@@ -127,6 +130,9 @@ typedef struct {
IO_AREA(pwr_sClass_InitArea) ao_i; IO_AREA(pwr_sClass_InitArea) ao_i;
IO_AREA(pwr_sClass_InitArea) do_i; IO_AREA(pwr_sClass_InitArea) do_i;
IO_AREA(pwr_sClass_InitArea) io_i; IO_AREA(pwr_sClass_InitArea) io_i;
IO_AREA(pwr_sClass_InitArea) atv_i;
IO_AREA(pwr_sClass_InitArea) dtv_i;
IO_AREA(pwr_sClass_InitArea) sv_i;
IO_AREA(pwr_sClass_InitArea) bi_i; IO_AREA(pwr_sClass_InitArea) bi_i;
IO_AREA(pwr_sClass_InitArea) bi_isize; IO_AREA(pwr_sClass_InitArea) bi_isize;
IO_AREA(pwr_sClass_InitArea) bo_i; IO_AREA(pwr_sClass_InitArea) bo_i;
...@@ -195,6 +201,8 @@ struct plc_sThread { ...@@ -195,6 +201,8 @@ struct plc_sThread {
pwr_tRedundancyStateEnum redu_state_old; pwr_tRedundancyStateEnum redu_state_old;
int redu_table_version_req_sent; int redu_table_version_req_sent;
redu_tCtx redu; redu_tCtx redu;
int tim_copy_lock;
int str_copy_lock;
}; };
struct plc_sProcess { struct plc_sProcess {
...@@ -212,6 +220,7 @@ struct plc_sProcess { ...@@ -212,6 +220,7 @@ struct plc_sProcess {
thread_sMutex io_copy_mutex; thread_sMutex io_copy_mutex;
plc_sArea base; plc_sArea base;
int is_core; int is_core;
pwr_tTime *system_time;
}; };
#if defined OS_LYNX || defined OS_LINUX #if defined OS_LYNX || defined OS_LINUX
......
...@@ -200,6 +200,9 @@ plc_rtdbref ( ...@@ -200,6 +200,9 @@ plc_rtdbref (
case pwr_cClass_Av: case pwr_cClass_Av:
case pwr_cClass_Iv: case pwr_cClass_Iv:
case pwr_cClass_Co: case pwr_cClass_Co:
case pwr_cClass_ATv:
case pwr_cClass_DTv:
case pwr_cClass_Sv:
sts = plc_GetObjectAttrValue(la->ObjType, la->AttrRef, ".ValueIndex", &Index, sizeof(pwr_tInt32)); sts = plc_GetObjectAttrValue(la->ObjType, la->AttrRef, ".ValueIndex", &Index, sizeof(pwr_tInt32));
if (EVEN(sts)) { if (EVEN(sts)) {
errh_Error("plc_GetObjectAttrValue object %s.ValueIndex\n%m", cdh_ObjidToString(la->AttrRef.Objid,0), sts); errh_Error("plc_GetObjectAttrValue object %s.ValueIndex\n%m", cdh_ObjidToString(la->AttrRef.Objid,0), sts);
...@@ -265,6 +268,21 @@ plc_rtdbref ( ...@@ -265,6 +268,21 @@ plc_rtdbref (
*la->Pointer = &tp->copy.iv_a.p->Value[Index]; *la->Pointer = &tp->copy.iv_a.p->Value[Index];
break; break;
case pwr_cClass_ATv:
if (la->UseCode == UC_READ && local_object)
*la->Pointer = &tp->copy.atv_a.p->Value[Index];
break;
case pwr_cClass_DTv:
if (la->UseCode == UC_READ && local_object)
*la->Pointer = &tp->copy.dtv_a.p->Value[Index];
break;
case pwr_cClass_Sv:
if (la->UseCode == UC_READ && local_object)
*la->Pointer = &tp->copy.sv_a.p->Value[Index];
break;
/* Special: UC_READ => AbsValue, UC_READ2 => RawValue */ /* Special: UC_READ => AbsValue, UC_READ2 => RawValue */
case pwr_cClass_Co: case pwr_cClass_Co:
if (local_object) { if (local_object) {
......
...@@ -133,3 +133,16 @@ typedef struct { ...@@ -133,3 +133,16 @@ typedef struct {
typedef struct { typedef struct {
char ActualValue[1]; char ActualValue[1];
} plc_sClass_BString; } plc_sClass_BString;
typedef struct {
pwr_tTime ActualValue;
} plc_sClass_ATv;
typedef struct {
pwr_tDeltaTime ActualValue;
} plc_sClass_DTv;
typedef struct {
pwr_tString80 ActualValue;
} plc_sClass_Sv;
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "pwr_systemclasses.h" #include "pwr_systemclasses.h"
#include "pwr_baseclasses.h" #include "pwr_baseclasses.h"
#include "co_time.h" #include "co_time.h"
#include "rt_lck.h"
#include "rt_plc.h" #include "rt_plc.h"
#include "rt_plc_rt.h" #include "rt_plc_rt.h"
#include "rt_plc_dirlink.h" #include "rt_plc_dirlink.h"
......
...@@ -36,14 +36,24 @@ ...@@ -36,14 +36,24 @@
/* Preprocessor routines for string operations */ /* Preprocessor routines for string operations */
/*_*
GETSV
get string value
@aref getsv GetSv
*/
#define GetSv_init(tp) \
tp->str_copy_lock = 1;
/*_* /*_*
STOSV STOSV
store string value store string value
@aref stosv StoSv @aref stosv StoSv
*/ */
#define stosv_exec(obj,in) \ #define stosv_exec(obj,in) \
lck_LockStr; \
strncpy( obj->ActualValue, in, sizeof(obj->ActualValue)); \ strncpy( obj->ActualValue, in, sizeof(obj->ActualValue)); \
obj->ActualValue[sizeof(obj->ActualValue)-1] = 0; obj->ActualValue[sizeof(obj->ActualValue)-1] = 0; \
lck_UnlockStr;
/*_* /*_*
CSTOSV CSTOSV
...@@ -52,8 +62,10 @@ ...@@ -52,8 +62,10 @@
*/ */
#define cstosv_exec(obj,in,cond) \ #define cstosv_exec(obj,in,cond) \
if ( cond ) { \ if ( cond ) { \
lck_LockStr; \
strncpy( obj->ActualValue, in, sizeof(obj->ActualValue)); \ strncpy( obj->ActualValue, in, sizeof(obj->ActualValue)); \
obj->ActualValue[sizeof(obj->ActualValue)-1] = 0; \ obj->ActualValue[sizeof(obj->ActualValue)-1] = 0; \
lck_UnlockStr; \
} }
/*_* /*_*
...@@ -93,8 +105,10 @@ ...@@ -93,8 +105,10 @@
@aref stosp StoSp @aref stosp StoSp
*/ */
#define stosp_exec(ut,in,size) \ #define stosp_exec(ut,in,size) \
lck_LockStr; \
strncpy( ut, in, size); \ strncpy( ut, in, size); \
ut[size-1] = 0; ut[size-1] = 0; \
lck_UnlockStr;
/*_* /*_*
CSTOSP CSTOSP
...@@ -103,8 +117,10 @@ ...@@ -103,8 +117,10 @@
*/ */
#define cstosp_exec(ut,in,cond,size) \ #define cstosp_exec(ut,in,cond,size) \
if ( cond) { \ if ( cond) { \
lck_LockStr; \
strncpy( ut, in, size); \ strncpy( ut, in, size); \
ut[size-1] = 0; \ ut[size-1] = 0; \
lck_UnlockStr; \
} }
/*_* /*_*
...@@ -113,8 +129,10 @@ ...@@ -113,8 +129,10 @@
@aref stonumsp StoNumSp @aref stonumsp StoNumSp
*/ */
#define stonumsp_exec(ut,in,size,num) \ #define stonumsp_exec(ut,in,size,num) \
lck_LockStr; \
strncpy( ut, in, num < size ? num : size); \ strncpy( ut, in, num < size ? num : size); \
ut[size-1] = 0; ut[size-1] = 0; \
lck_UnlockStr;
/*_* /*_*
CSTONUMSP CSTONUMSP
...@@ -123,10 +141,22 @@ ...@@ -123,10 +141,22 @@
*/ */
#define cstonumsp_exec(ut,in,cond,size, num) \ #define cstonumsp_exec(ut,in,cond,size, num) \
if ( cond) { \ if ( cond) { \
lck_LockStr; \
strncpy( ut, in, num < size ? num : size); \ strncpy( ut, in, num < size ? num : size); \
ut[size-1] = 0; \ ut[size-1] = 0; \
lck_UnlockStr; \
} }
/*_*
GetSp
Get string attribute
@aref getsp GetSp
*/
#define GetSp_exec(object,in) \
lck_LockStr; \
strncpy( object->ActVal, in, sizeof(object->ActVal)); \
lck_UnlockStr;
/*_* /*_*
SUBSTR SUBSTR
@aref substr SubStr @aref substr SubStr
......
...@@ -36,13 +36,21 @@ ...@@ -36,13 +36,21 @@
/* Preprocessor routines for time operations */ /* Preprocessor routines for time operations */
#define GetDTv_init(tp) \
tp->tim_copy_lock = 1;
#define GetATv_init(tp) \
tp->tim_copy_lock = 1;
/*_* /*_*
STOATV STOATV
store absolute time value store absolute time value
@aref stoatv StoATv @aref stoatv StoATv
*/ */
#define StoATv_exec(obj,in) \ #define StoATv_exec(obj,in) \
obj->ActualValue = in; lck_LockTime; \
obj->ActualValue = in; \
lck_UnlockTime;
/*_* /*_*
STODTV STODTV
...@@ -50,7 +58,9 @@ ...@@ -50,7 +58,9 @@
@aref stodtv StoDTv @aref stodtv StoDTv
*/ */
#define StoDTv_exec(obj,in) \ #define StoDTv_exec(obj,in) \
obj->ActualValue = in; lck_LockTime; \
obj->ActualValue = in; \
lck_UnlockTime;
/*_* /*_*
CSTOATV CSTOATV
...@@ -58,8 +68,11 @@ ...@@ -58,8 +68,11 @@
@aref cstoatv CStoATv @aref cstoatv CStoATv
*/ */
#define CStoATv_exec(obj,in,cond) \ #define CStoATv_exec(obj,in,cond) \
if ( cond ) \ if ( cond ) { \
obj->ActualValue = in; lck_LockTime; \
obj->ActualValue = in; \
lck_UnlockTime; \
}
/*_* /*_*
CSTODTV CSTODTV
...@@ -67,8 +80,11 @@ ...@@ -67,8 +80,11 @@
@aref cstodtv CStoDTv @aref cstodtv CStoDTv
*/ */
#define CStoDTv_exec(obj,in,cond) \ #define CStoDTv_exec(obj,in,cond) \
if ( cond ) \ if ( cond ) { \
obj->ActualValue = in; lck_LockTime; \
obj->ActualValue = in; \
lck_UnlockTime; \
}
/*_* /*_*
STOATP STOATP
...@@ -76,7 +92,9 @@ ...@@ -76,7 +92,9 @@
@aref stoatp StoATp @aref stoatp StoATp
*/ */
#define StoATp_exec(ut,in) \ #define StoATp_exec(ut,in) \
ut = in; lck_LockTime; \
ut = in; \
lck_UnlockTime;
/*_* /*_*
STODTP STODTP
...@@ -84,7 +102,9 @@ ...@@ -84,7 +102,9 @@
@aref stodtp StoDTp @aref stodtp StoDTp
*/ */
#define StoDTp_exec(ut,in) \ #define StoDTp_exec(ut,in) \
ut = in; lck_LockTime; \
ut = in; \
lck_UnlockTime;
/*_* /*_*
CSTOATP CSTOATP
...@@ -92,8 +112,31 @@ ...@@ -92,8 +112,31 @@
@aref cstoatp CStoATp @aref cstoatp CStoATp
*/ */
#define CStoATp_exec(ut,in,cond) \ #define CStoATp_exec(ut,in,cond) \
if ( cond) \ if ( cond) { \
ut = in; lck_LockTime; \
ut = in; \
lck_UnlockTime; \
}
/*_*
GetATp
Get absolute time attribute
@aref getatp GetATp
*/
#define GetATp_exec(object,in) \
lck_LockTime; \
object->ActVal = in; \
lck_UnlockTime;
/*_*
GetDTp
Get delta time attribute
@aref getatp GetDTp
*/
#define GetDTp_exec(object,in) \
lck_LockTime; \
object->ActVal = in; \
lck_UnlockTime;
/*_* /*_*
CSTODTP CSTODTP
...@@ -101,8 +144,11 @@ ...@@ -101,8 +144,11 @@
@aref cstodtp CStoDTp @aref cstodtp CStoDTp
*/ */
#define CStoDTp_exec(ut,in,cond) \ #define CStoDTp_exec(ut,in,cond) \
if ( cond) \ if ( cond) { \
ut = in; lck_LockTime; \
ut = in; \
lck_UnlockTime; \
}
/*_* /*_*
ATADD ATADD
...@@ -157,8 +203,11 @@ ...@@ -157,8 +203,11 @@
CURRENTTIME CURRENTTIME
@aref currentime CurrentTime @aref currentime CurrentTime
*/ */
#define CurrentTime_init(tp) \
tp->tim_copy_lock = 1;
#define CurrentTime_exec(obj) \ #define CurrentTime_exec(obj) \
obj->Time = tp->pp->Node->SystemTime; obj->Time = *tp->pp->system_time;
/*_* /*_*
ATGREATERTHAN ATGREATERTHAN
......
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#include "rt_csup.h" #include "rt_csup.h"
#include "rt_c_plcthread.h" #include "rt_c_plcthread.h"
#include "rt_c_node.h" #include "rt_c_node.h"
#include "rt_lck.h"
#define MIN_SCANTIME 1e-9 #define MIN_SCANTIME 1e-9
...@@ -391,7 +392,6 @@ plc_thread ( ...@@ -391,7 +392,6 @@ plc_thread (
} }
thread_MutexLock(&tp->pp->io_copy_mutex); thread_MutexLock(&tp->pp->io_copy_mutex);
memcpy(tp->copy.ai_a.p, tp->pp->base.ai_a.p, tp->copy.ai_a.size); memcpy(tp->copy.ai_a.p, tp->pp->base.ai_a.p, tp->copy.ai_a.size);
memcpy(tp->copy.ao_a.p, tp->pp->base.ao_a.p, tp->copy.ao_a.size); memcpy(tp->copy.ao_a.p, tp->pp->base.ao_a.p, tp->copy.ao_a.size);
memcpy(tp->copy.av_a.p, tp->pp->base.av_a.p, tp->copy.av_a.size); memcpy(tp->copy.av_a.p, tp->pp->base.av_a.p, tp->copy.av_a.size);
...@@ -405,9 +405,20 @@ plc_thread ( ...@@ -405,9 +405,20 @@ plc_thread (
memcpy(tp->copy.iv_a.p, tp->pp->base.iv_a.p, tp->copy.iv_a.size); memcpy(tp->copy.iv_a.p, tp->pp->base.iv_a.p, tp->copy.iv_a.size);
memcpy(tp->copy.bi_a.p, tp->pp->base.bi_a.p, tp->copy.bi_a.size); memcpy(tp->copy.bi_a.p, tp->pp->base.bi_a.p, tp->copy.bi_a.size);
memcpy(tp->copy.bo_a.p, tp->pp->base.bo_a.p, tp->copy.bo_a.size); memcpy(tp->copy.bo_a.p, tp->pp->base.bo_a.p, tp->copy.bo_a.size);
thread_MutexUnlock(&tp->pp->io_copy_mutex); thread_MutexUnlock(&tp->pp->io_copy_mutex);
if ( tp->tim_copy_lock) {
lck_LockTime;
memcpy(tp->copy.atv_a.p, tp->pp->base.atv_a.p, tp->copy.atv_a.size);
memcpy(tp->copy.dtv_a.p, tp->pp->base.dtv_a.p, tp->copy.dtv_a.size);
lck_UnlockTime;
}
if ( tp->str_copy_lock) {
lck_LockStr;
memcpy(tp->copy.sv_a.p, tp->pp->base.sv_a.p, tp->copy.sv_a.size);
lck_UnlockStr;
}
que_Put(&sts, &tp->q_out, &tp->event, (void *)3); que_Put(&sts, &tp->q_out, &tp->event, (void *)3);
phase = (long int)que_Get(&sts, &tp->q_in, NULL, NULL); phase = (long int)que_Get(&sts, &tp->q_in, NULL, NULL);
pwr_Assert(phase == 4); pwr_Assert(phase == 4);
...@@ -644,7 +655,6 @@ scan ( ...@@ -644,7 +655,6 @@ scan (
tp->emergency_break_old = pp->Node->EmergBreakTrue; tp->emergency_break_old = pp->Node->EmergBreakTrue;
thread_MutexLock(&pp->io_copy_mutex); thread_MutexLock(&pp->io_copy_mutex);
memcpy(tp->copy.ai_a.p, pp->base.ai_a.p, tp->copy.ai_a.size); memcpy(tp->copy.ai_a.p, pp->base.ai_a.p, tp->copy.ai_a.size);
memcpy(tp->copy.ao_a.p, pp->base.ao_a.p, tp->copy.ao_a.size); memcpy(tp->copy.ao_a.p, pp->base.ao_a.p, tp->copy.ao_a.size);
memcpy(tp->copy.av_a.p, pp->base.av_a.p, tp->copy.av_a.size); memcpy(tp->copy.av_a.p, pp->base.av_a.p, tp->copy.av_a.size);
...@@ -658,9 +668,21 @@ scan ( ...@@ -658,9 +668,21 @@ scan (
memcpy(tp->copy.iv_a.p, pp->base.iv_a.p, tp->copy.iv_a.size); memcpy(tp->copy.iv_a.p, pp->base.iv_a.p, tp->copy.iv_a.size);
memcpy(tp->copy.bi_a.p, pp->base.bi_a.p, tp->copy.bi_a.size); memcpy(tp->copy.bi_a.p, pp->base.bi_a.p, tp->copy.bi_a.size);
memcpy(tp->copy.bo_a.p, pp->base.bo_a.p, tp->copy.bo_a.size); memcpy(tp->copy.bo_a.p, pp->base.bo_a.p, tp->copy.bo_a.size);
thread_MutexUnlock(&pp->io_copy_mutex); thread_MutexUnlock(&pp->io_copy_mutex);
if ( tp->tim_copy_lock) {
lck_LockTime;
*pp->system_time = tp->before_scan_abs;
memcpy(tp->copy.atv_a.p, pp->base.atv_a.p, tp->copy.atv_a.size);
memcpy(tp->copy.dtv_a.p, pp->base.dtv_a.p, tp->copy.dtv_a.size);
lck_UnlockTime;
}
if ( tp->str_copy_lock) {
lck_LockStr;
memcpy(tp->copy.sv_a.p, pp->base.sv_a.p, tp->copy.sv_a.size);
lck_UnlockStr;
}
/* Execute all the PLC code */ /* Execute all the PLC code */
tp->exec(0, tp); tp->exec(0, tp);
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
! !
SObject pwrb:Class SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 2.0
! @Group PlantConfiguration,Signals ! @Group PlantConfiguration,Signals
! @Summary Absolute time value ! @Summary Absolute time value
! Absolute time value. ! Absolute time value.
...@@ -69,10 +69,35 @@ SObject pwrb:Class ...@@ -69,10 +69,35 @@ SObject pwrb:Class
!*/ !*/
Object ActualValue $Attribute 2 Object ActualValue $Attribute 2
Body SysBody Body SysBody
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_POINTER
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_REDUTRANSFER Attr Flags |= PWR_MASK_REDUTRANSFER
Attr Size = 16
EndBody
EndObject
!/**
! InitialValue specifies starting value of the signal at
! Proview startup.
!*/
Object InitialValue $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$Time" Attr TypeRef = "pwrs:Type-$Time"
EndBody EndBody
EndObject EndObject
!/**
! Index in the ATvArea array of the Area objects
! that are used for base frequency and partial frequency
! samples. Initiated at boot time by rt_ini.
!*/
Object ValueIndex $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_PRIVATE
EndBody
EndObject
EndObject EndObject
EndObject EndObject
EndSObject EndSObject
\ No newline at end of file
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2017 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_atvarea.wb_load -- Defines the class ATvArea.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Area object for ATv values
! Area object for ATv values.
!
! The values of ATv-signals is stored in the Value
! attribut. The index is given by ValueIndex in the
! ATv-objects which is assigned at io initiation.
!
! The object is created at runtime in the dynamic system volume pwrNode.
!*/
Object ATvArea $ClassDef 702
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "ATvArea"
EndBody
Object Value $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$Time"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_DYNAMIC
Attr Elements = 1
EndBody
EndObject
EndObject
EndObject
EndSObject
\ No newline at end of file
...@@ -143,7 +143,7 @@ SObject pwrb:Class ...@@ -143,7 +143,7 @@ SObject pwrb:Class
Attr subwindows = 0 Attr subwindows = 0
Attr graphmethod = 8 Attr graphmethod = 8
Attr graphindex = 1 Attr graphindex = 1
Attr default_mask[0] = 2 Attr default_mask[0] = 3
Attr default_mask[1] = 0 Attr default_mask[1] = 0
Attr segname_annotation = 0 Attr segname_annotation = 0
Attr devbody_annotation = 1 Attr devbody_annotation = 1
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
! !
SObject pwrb:Class SObject pwrb:Class
!/** !/**
! @Version 1.0 ! @Version 2.0
! @Group PlantConfiguration,Signals ! @Group PlantConfiguration,Signals
! @Summary Delta time value ! @Summary Delta time value
! Delta time value. ! Delta time value.
...@@ -70,7 +70,32 @@ SObject pwrb:Class ...@@ -70,7 +70,32 @@ SObject pwrb:Class
Object ActualValue $Attribute 2 Object ActualValue $Attribute 2
Body SysBody Body SysBody
Attr TypeRef = "pwrs:Type-$DeltaTime" Attr TypeRef = "pwrs:Type-$DeltaTime"
Attr Flags |= PWR_MASK_POINTER
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_REDUTRANSFER Attr Flags |= PWR_MASK_REDUTRANSFER
Attr Size = 16
EndBody
EndObject
!/**
! InitialValue specifies starting value of the signal at
! Proview startup.
!*/
Object InitialValue $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$DeltaTime"
EndBody
EndObject
!/**
! Index in the ATvArea array of the Area objects
! that are used for base frequency and partial frequency
! samples. Initiated at boot time by rt_ini.
!*/
Object ValueIndex $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_PRIVATE
EndBody EndBody
EndObject EndObject
EndObject EndObject
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2017 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_dtvarea.wb_load -- Defines the class DTvArea.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Area object for DTv values
! Area object for DTv values.
!
! The values of DTv-signals is stored in the Value
! attribut. The index is given by ValueIndex in the
! DTv-objects which is assigned at io initiation.
!
! The object is created at runtime in the dynamic system volume pwrNode.
!*/
Object DTvArea $ClassDef 701
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "DTvArea"
EndBody
Object Value $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$DeltaTime"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_DYNAMIC
Attr Elements = 1
EndBody
EndObject
EndObject
EndObject
EndSObject
\ No newline at end of file
...@@ -46,19 +46,16 @@ SObject pwrb:Class ...@@ -46,19 +46,16 @@ SObject pwrb:Class
! Fetches the value of an absolute time attribute. ! Fetches the value of an absolute time attribute.
! !
! The complete name of quantity has to be supplied. ! The complete name of quantity has to be supplied.
!
! The GetATp object
! - is a pure address reference,
! - contains no relevant information (=data) in rtdb,
! - is without executable code.
!*/ !*/
Object GetATp $ClassDef 445 Object GetATp $ClassDef 445
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_AttrEd Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtAndDevBodies Attr Method = pwr_eMethod_RtAndDevBodies
Attr Flags = pwr_mClassDef_DevOnly
EndBody EndBody
Object RtBody $ObjBodyDef 1 Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "GetATp"
EndBody
!/** !/**
! Used by the PLC Editor. ! Used by the PLC Editor.
!*/ !*/
...@@ -66,9 +63,8 @@ SObject pwrb:Class ...@@ -66,9 +63,8 @@ SObject pwrb:Class
Body SysBody Body SysBody
Attr PgmName = "ActVal" Attr PgmName = "ActVal"
Attr Flags |= PWR_MASK_STATE Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_RTVIRTUAL Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_DEVBODYREF Attr Flags |= PWR_MASK_REDUTRANSFER
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$Time" Attr TypeRef = "pwrs:Type-$Time"
Attr GraphName = "VAL" Attr GraphName = "VAL"
EndBody EndBody
...@@ -122,12 +118,12 @@ SObject pwrb:Class ...@@ -122,12 +118,12 @@ SObject pwrb:Class
Attr default_mask[1] = 1 Attr default_mask[1] = 1
Attr segname_annotation = 0 Attr segname_annotation = 0
Attr devbody_annotation = 1 Attr devbody_annotation = 1
Attr compmethod = 10 Attr compmethod = 36
Attr compindex = 0 Attr compindex = 0
Attr tracemethod = 0 Attr tracemethod = 0
Attr traceindex = 0 Attr traceindex = 0
Attr connectmethod = 7 Attr connectmethod = 7
Attr executeordermethod = 0 Attr executeordermethod = 2
Attr objname = "GetATp" Attr objname = "GetATp"
Attr graphname = "ATp" Attr graphname = "ATp"
Attr debugpar = "" Attr debugpar = ""
......
...@@ -60,6 +60,9 @@ SObject pwrb:Class ...@@ -60,6 +60,9 @@ SObject pwrb:Class
Attr Flags = pwr_mClassDef_DevOnly Attr Flags = pwr_mClassDef_DevOnly
EndBody EndBody
Object RtBody $ObjBodyDef 1 Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "GetATv"
EndBody
!/** !/**
! Used by the PLC Editor. ! Used by the PLC Editor.
!*/ !*/
......
...@@ -46,19 +46,16 @@ SObject pwrb:Class ...@@ -46,19 +46,16 @@ SObject pwrb:Class
! Fetches the value of an absolute time attribute. ! Fetches the value of an absolute time attribute.
! !
! The complete name of quantity has to be supplied. ! The complete name of quantity has to be supplied.
!
! The GetDTp object
! - is a pure address reference,
! - contains no relevant information (=data) in rtdb,
! - is without executable code.
!*/ !*/
Object GetDTp $ClassDef 446 Object GetDTp $ClassDef 446
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_AttrEd Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtAndDevBodies Attr Method = pwr_eMethod_RtAndDevBodies
Attr Flags = pwr_mClassDef_DevOnly
EndBody EndBody
Object RtBody $ObjBodyDef 1 Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "GetDTp"
EndBody
!/** !/**
! Used by the PLC Editor. ! Used by the PLC Editor.
!*/ !*/
...@@ -66,10 +63,9 @@ SObject pwrb:Class ...@@ -66,10 +63,9 @@ SObject pwrb:Class
Body SysBody Body SysBody
Attr PgmName = "ActVal" Attr PgmName = "ActVal"
Attr Flags |= PWR_MASK_STATE Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_RTVIRTUAL Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_DEVBODYREF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$DeltaTime" Attr TypeRef = "pwrs:Type-$DeltaTime"
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "VAL" Attr GraphName = "VAL"
EndBody EndBody
EndObject EndObject
...@@ -122,12 +118,12 @@ SObject pwrb:Class ...@@ -122,12 +118,12 @@ SObject pwrb:Class
Attr default_mask[1] = 1 Attr default_mask[1] = 1
Attr segname_annotation = 0 Attr segname_annotation = 0
Attr devbody_annotation = 1 Attr devbody_annotation = 1
Attr compmethod = 10 Attr compmethod = 36
Attr compindex = 0 Attr compindex = 0
Attr tracemethod = 0 Attr tracemethod = 0
Attr traceindex = 0 Attr traceindex = 0
Attr connectmethod = 7 Attr connectmethod = 7
Attr executeordermethod = 0 Attr executeordermethod = 2
Attr objname = "GetDTp" Attr objname = "GetDTp"
Attr graphname = "DTp" Attr graphname = "DTp"
Attr debugpar = "" Attr debugpar = ""
......
...@@ -60,6 +60,9 @@ SObject pwrb:Class ...@@ -60,6 +60,9 @@ SObject pwrb:Class
Attr Flags = pwr_mClassDef_DevOnly Attr Flags = pwr_mClassDef_DevOnly
EndBody EndBody
Object RtBody $ObjBodyDef 1 Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "GetDTv"
EndBody
!/** !/**
! Used by the PLC Editor. ! Used by the PLC Editor.
!*/ !*/
......
...@@ -49,18 +49,16 @@ SObject pwrb:Class ...@@ -49,18 +49,16 @@ SObject pwrb:Class
! !
! The complete name of quantity has to be supplied. ! The complete name of quantity has to be supplied.
! !
! The GetSp object
! - is a pure address reference,
! - contains no relevant information (=data) in rtdb,
! - is without executable code.
!*/ !*/
Object GetSp $ClassDef 309 Object GetSp $ClassDef 309
Body SysBody Body SysBody
Attr Editor = pwr_eEditor_AttrEd Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtAndDevBodies Attr Method = pwr_eMethod_RtAndDevBodies
Attr Flags = pwr_mClassDef_DevOnly
EndBody EndBody
Object RtBody $ObjBodyDef 1 Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "GetSp"
EndBody
!/** !/**
! Used by the PLC Editor. ! Used by the PLC Editor.
!*/ !*/
...@@ -68,10 +66,9 @@ SObject pwrb:Class ...@@ -68,10 +66,9 @@ SObject pwrb:Class
Body SysBody Body SysBody
Attr PgmName = "ActVal" Attr PgmName = "ActVal"
Attr Flags |= PWR_MASK_STATE Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_RTVIRTUAL Attr Flags |= PWR_MASK_NOEDIT
Attr Flags |= PWR_MASK_DEVBODYREF
Attr Flags |= PWR_MASK_INVISIBLE
Attr TypeRef = "pwrs:Type-$String80" Attr TypeRef = "pwrs:Type-$String80"
Attr Flags |= PWR_MASK_REDUTRANSFER
Attr GraphName = "VAL" Attr GraphName = "VAL"
EndBody EndBody
EndObject EndObject
...@@ -124,12 +121,12 @@ SObject pwrb:Class ...@@ -124,12 +121,12 @@ SObject pwrb:Class
Attr default_mask[1] = 1 Attr default_mask[1] = 1
Attr segname_annotation = 0 Attr segname_annotation = 0
Attr devbody_annotation = 1 Attr devbody_annotation = 1
Attr compmethod = 10 Attr compmethod = 36
Attr compindex = 0 Attr compindex = 0
Attr tracemethod = 0 Attr tracemethod = 0
Attr traceindex = 0 Attr traceindex = 0
Attr connectmethod = 7 Attr connectmethod = 7
Attr executeordermethod = 0 Attr executeordermethod = 2
Attr objname = "GetSp" Attr objname = "GetSp"
Attr graphname = "Sp" Attr graphname = "Sp"
Attr debugpar = "" Attr debugpar = ""
......
...@@ -60,6 +60,9 @@ SObject pwrb:Class ...@@ -60,6 +60,9 @@ SObject pwrb:Class
Attr Flags = pwr_mClassDef_DevOnly Attr Flags = pwr_mClassDef_DevOnly
EndBody EndBody
Object RtBody $ObjBodyDef 1 Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "GetSv"
EndBody
!/** !/**
! Used by the PLC Editor. ! Used by the PLC Editor.
!*/ !*/
......
...@@ -263,6 +263,36 @@ SObject pwrb:Class ...@@ -263,6 +263,36 @@ SObject pwrb:Class
EndBody EndBody
EndObject EndObject
!/** !/**
! Number of configured ATv objects in the node.
!*/
Object ATvCount $Attribute 23
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Number of configured DTv objects in the node.
!*/
Object DTvCount $Attribute 24
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Number of configured Sv objects in the node.
!*/
Object SvCount $Attribute 25
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_INVISIBLE
EndBody
EndObject
!/**
! Number of configured Bi objects in the node. ! Number of configured Bi objects in the node.
!*/ !*/
Object BiCount $Attribute 15 Object BiCount $Attribute 15
......
...@@ -70,7 +70,32 @@ SObject pwrb:Class ...@@ -70,7 +70,32 @@ SObject pwrb:Class
Object ActualValue $Attribute 2 Object ActualValue $Attribute 2
Body SysBody Body SysBody
Attr TypeRef = "pwrs:Type-$String80" Attr TypeRef = "pwrs:Type-$String80"
Attr Flags |= PWR_MASK_POINTER
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_REDUTRANSFER Attr Flags |= PWR_MASK_REDUTRANSFER
Attr Size = 80
EndBody
EndObject
!/**
! InitialValue specifies starting value of the signal at
! Proview startup.
!*/
Object InitialValue $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
!/**
! Index in the SvArea array of the Area objects
! that are used for base frequency and partial frequency
! samples. Initiated at boot time by rt_ini.
!*/
Object ValueIndex $Attribute 4
Body SysBody
Attr TypeRef = "pwrs:Type-$UInt32"
Attr Flags |= PWR_MASK_INVISIBLE
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_PRIVATE
EndBody EndBody
EndObject EndObject
EndObject EndObject
......
!
! Proview Open Source Process Control.
! Copyright (C) 2005-2017 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_svarea.wb_load -- Defines the class SvArea.
!
SObject pwrb:Class
!/**
! @Version 1.0
! @Summary Area object for Sv values
! Area object for Sv values.
!
! The values of Sv-signals is stored in the Value
! attribut. The index is given by ValueIndex in the
! Sv-objects which is assigned at io initiation.
!
! The object is created at runtime in the dynamic system volume pwrNode.
!*/
Object SvArea $ClassDef 703
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "SvArea"
EndBody
Object Value $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
Attr Flags |= PWR_MASK_ARRAY
Attr Flags |= PWR_MASK_STATE
Attr Flags |= PWR_MASK_DYNAMIC
Attr Elements = 1
EndBody
EndObject
EndObject
EndObject
EndSObject
\ No newline at end of file
...@@ -3619,20 +3619,14 @@ static int gcg_get_outputstring_spec( ...@@ -3619,20 +3619,14 @@ static int gcg_get_outputstring_spec(
free((char *) attrref); free((char *) attrref);
return GSX__SPECFOUND; return GSX__SPECFOUND;
} }
case pwr_cClass_GetSp:
case pwr_cClass_GetATp:
case pwr_cClass_GetDTp:
case pwr_cClass_GetDataRefp: { case pwr_cClass_GetDataRefp: {
/********************************************************** /**********************************************************
* GetSp, GetATP, GetDTp, GetDataRefp * GetDataRefp
***********************************************************/ ***********************************************************/
pwr_tAName aname; pwr_tAName aname;
switch ( output_node->ln.cid) { switch ( output_node->ln.cid) {
case pwr_cClass_GetSp: strcpy( aname, "SpObject"); break;
case pwr_cClass_GetATp: strcpy( aname, "ATpObject"); break;
case pwr_cClass_GetDTp: strcpy( aname, "DTpObject"); break;
case pwr_cClass_GetDataRefp: strcpy( aname, "DataRefpObject"); break; case pwr_cClass_GetDataRefp: strcpy( aname, "DataRefpObject"); break;
default: ; default: ;
} }
...@@ -6731,6 +6725,7 @@ int gcg_comp_m8( gcg_ctx gcgctx, vldh_t_node node) ...@@ -6731,6 +6725,7 @@ int gcg_comp_m8( gcg_ctx gcgctx, vldh_t_node node)
pwr_tClassId cid; pwr_tClassId cid;
pwr_tDisableAttr disabled; pwr_tDisableAttr disabled;
pwr_tCid scid; pwr_tCid scid;
char *name;
ldhses = (node->hn.wind)->hw.ldhses; ldhses = (node->hn.wind)->hw.ldhses;
...@@ -6888,29 +6883,19 @@ int gcg_comp_m8( gcg_ctx gcgctx, vldh_t_node node) ...@@ -6888,29 +6883,19 @@ int gcg_comp_m8( gcg_ctx gcgctx, vldh_t_node node)
gcg_error_msg( gcgctx, GSX__REFCLASS, node); gcg_error_msg( gcgctx, GSX__REFCLASS, node);
return GSX__NEXTNODE; return GSX__NEXTNODE;
} }
/* Insert io object in ioread list */
gcg_aref_insert( gcgctx, attrref, GCG_PREFIX_REF, node);
return GSX__SUCCESS;
break; break;
case pwr_cClass_GetATv: case pwr_cClass_GetATv:
if ( cid != pwr_cClass_ATv) { if ( cid != pwr_cClass_ATv) {
gcg_error_msg( gcgctx, GSX__REFCLASS, node); gcg_error_msg( gcgctx, GSX__REFCLASS, node);
return GSX__NEXTNODE; return GSX__NEXTNODE;
} }
break;
/* Insert io object in ioread list */
gcg_aref_insert( gcgctx, attrref, GCG_PREFIX_REF, node);
return GSX__SUCCESS;
case pwr_cClass_GetDTv: case pwr_cClass_GetDTv:
if ( cid != pwr_cClass_DTv) { if ( cid != pwr_cClass_DTv) {
gcg_error_msg( gcgctx, GSX__REFCLASS, node); gcg_error_msg( gcgctx, GSX__REFCLASS, node);
return GSX__NEXTNODE; return GSX__NEXTNODE;
} }
break;
/* Insert io object in ioread list */
gcg_aref_insert( gcgctx, attrref, GCG_PREFIX_REF, node);
return GSX__SUCCESS;
case pwr_cClass_GetConstAv: case pwr_cClass_GetConstAv:
if ( cid != pwr_cClass_ConstAv) { if ( cid != pwr_cClass_ConstAv) {
gcg_error_msg( gcgctx, GSX__REFCLASS, node); gcg_error_msg( gcgctx, GSX__REFCLASS, node);
...@@ -6948,6 +6933,18 @@ int gcg_comp_m8( gcg_ctx gcgctx, vldh_t_node node) ...@@ -6948,6 +6933,18 @@ int gcg_comp_m8( gcg_ctx gcgctx, vldh_t_node node)
/* Insert io object in ioread list */ /* Insert io object in ioread list */
gcg_ioread_insert( gcgctx, attrref, GCG_PREFIX_REF); gcg_ioread_insert( gcgctx, attrref, GCG_PREFIX_REF);
/* Print init call */
switch ( node->ln.cid) {
case pwr_cClass_GetATv:
case pwr_cClass_GetDTv:
case pwr_cClass_GetSv:
sts = gcg_get_structname( gcgctx, node->ln.oid, &name);
IF_PR fprintf( gcgctx->files[GCGM1_REF_FILE],
"%s_init( tp);\n",
name);
default: ;
}
return GSX__SUCCESS; return GSX__SUCCESS;
} }
...@@ -7034,7 +7031,7 @@ int gcg_comp_m9( gcg_ctx gcgctx, vldh_t_node node) ...@@ -7034,7 +7031,7 @@ int gcg_comp_m9( gcg_ctx gcgctx, vldh_t_node node)
* vldh_t_node node I vldh node. * vldh_t_node node I vldh node.
* *
* Description: * Description:
* Compile method for GetDp, GetAp, GetSp, GetATp, GetDTp, GetDataRefp. * Compile method for GetDp, GetAp, GetSp, GetDataRefp.
* Checks that the referenced object exists and that the referenced * Checks that the referenced object exists and that the referenced
* parameter exists in that object, and that the type of the parameter * parameter exists in that object, and that the type of the parameter
* is correct. * is correct.
...@@ -8315,10 +8312,7 @@ int gcg_comp_m11( gcg_ctx gcgctx, vldh_t_node node) ...@@ -8315,10 +8312,7 @@ int gcg_comp_m11( gcg_ctx gcgctx, vldh_t_node node)
gcg_error_msg( gcgctx, GSX__DISABLED, node); gcg_error_msg( gcgctx, GSX__DISABLED, node);
} }
if ( cid == pwr_cClass_Sv || if ( cid == pwr_cClass_DataRefv) {
cid == pwr_cClass_ATv ||
cid == pwr_cClass_DTv ||
cid == pwr_cClass_DataRefv) {
/* Insert io object in ref list */ /* Insert io object in ref list */
gcg_aref_insert( gcgctx, refattrref, GCG_PREFIX_REF, node); gcg_aref_insert( gcgctx, refattrref, GCG_PREFIX_REF, node);
...@@ -11043,6 +11037,24 @@ int gcg_comp_m36( gcg_ctx gcgctx, vldh_t_node node) ...@@ -11043,6 +11037,24 @@ int gcg_comp_m36( gcg_ctx gcgctx, vldh_t_node node)
return GSX__NEXTNODE; return GSX__NEXTNODE;
} }
break; break;
case pwr_eType_Time:
if ( node->ln.cid != pwr_cClass_GetATp) {
gcg_error_msg( gcgctx, GSX__REFPARTYPE, node);
return GSX__NEXTNODE;
}
break;
case pwr_eType_DeltaTime:
if ( node->ln.cid != pwr_cClass_GetDTp) {
gcg_error_msg( gcgctx, GSX__REFPARTYPE, node);
return GSX__NEXTNODE;
}
break;
case pwr_eType_String:
if ( node->ln.cid != pwr_cClass_GetSp) {
gcg_error_msg( gcgctx, GSX__REFPARTYPE, node);
return GSX__NEXTNODE;
}
break;
default: default:
/* Not allowed type */ /* Not allowed type */
gcg_error_msg( gcgctx, GSX__REFPARTYPE, node); gcg_error_msg( gcgctx, GSX__REFPARTYPE, node);
...@@ -11063,6 +11075,7 @@ int gcg_comp_m36( gcg_ctx gcgctx, vldh_t_node node) ...@@ -11063,6 +11075,7 @@ int gcg_comp_m36( gcg_ctx gcgctx, vldh_t_node node)
/* Insert object in ref list */ /* Insert object in ref list */
gcg_aref_insert( gcgctx, refattrref, GCG_PREFIX_REF, node); gcg_aref_insert( gcgctx, refattrref, GCG_PREFIX_REF, node);
return GSX__SUCCESS; return GSX__SUCCESS;
} }
...@@ -13880,6 +13893,15 @@ int gcg_comp_m55( gcg_ctx gcgctx, vldh_t_node node) ...@@ -13880,6 +13893,15 @@ int gcg_comp_m55( gcg_ctx gcgctx, vldh_t_node node)
gcg_scantime_print( gcgctx, node->ln.oid); gcg_scantime_print( gcgctx, node->ln.oid);
gcg_timer_print( gcgctx, node->ln.oid); gcg_timer_print( gcgctx, node->ln.oid);
/* Print init call */
switch ( node->ln.cid) {
case pwr_cClass_CurrentTime:
IF_PR fprintf( gcgctx->files[GCGM1_REF_FILE],
"%s_init( tp);\n",
name);
default: ;
}
return GSX__SUCCESS; return GSX__SUCCESS;
} }
/************************************************************************* /*************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment