/*
* ProviewR Open Source Process Control.
* Copyright (C) 2005-2025 SSAB EMEA AB.
*
* This file is part of ProviewR.
*
* 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 ProviewR. If not, see <http://www.gnu.org/licenses/>
*
* Linking ProviewR statically or dynamically with other modules is
* making a combined work based on ProviewR. 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
* ProviewR give you permission to, from the build function in the
* ProviewR Configurator, combine ProviewR with modules generated by the
* ProviewR 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 ProviewR (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
*/
#include "rt_gdh_msg.h"
/* PREPROCESSOR RUTINER */
StoDo
#define stodo_exec(obj, in) obj->ActualValue = in;
StoDv
#define stodv_exec(obj, in) obj->ActualValue = in;
StoDp
#define stodp_exec(ut, in) ut = in;
StoAo
#define stoao_exec(obj, in) obj->ActualValue = in;
StoAv
#define stoav_exec(obj, in) obj->ActualValue = in;
StoAp
#define stoap_exec(ut, in) ut = in;
CStoAo
#define cstoao_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
CStoAv
#define cstoav_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
CStoAp
#define cstoap_exec(ut, in, cond) \
if (cond) \
ut = in;
SetDo
#define setdo_exec(obj, in) \
if (in) \
obj->ActualValue = true;
SetDv
#define setdv_exec(obj, in) \
if (in) \
obj->ActualValue = true;
SetDp
#define setdp_exec(ut, in) \
if (in) \
ut = true;
ResDo
#define resdo_exec(obj, in) \
if (in) \
obj->ActualValue = false;
ResDv
#define resdv_exec(obj, in) \
if (in) \
obj->ActualValue = false;
ResDp
#define resdp_exec(ut, in) \
if (in) \
ut = false;
StoIp
#define StoIp_exec(ut, in) ut = in;
CStoIp
#define CStoIp_exec(ut, in, cond) \
if (cond) \
ut = in;
StoAtoIp
#define StoAtoIp_exec(ut, in) ut = in > 0 ? in + 0.5 : in - 0.5;
CStoAtoIp
#define CStoAtoIp_exec(ut, in, cond) \
if (cond) \
ut = in > 0 ? in + 0.5 : in - 0.5;
GetIpToA
#define GetIpToA_exec(object, in) object->ActVal = in;
GetIp
#define GetIp_exec(object, in) object->ActVal = in;
StoDi
#define stodi_exec(obj, in) obj->ActualValue = in;
SetDi
#define setdi_exec(obj, in) \
if (in) \
obj->ActualValue = true;
ResDi
#define resdi_exec(obj, in) \
if (in) \
obj->ActualValue = false;
ToggleDi
#define toggledi_exec(obj, in) \
if (in) \
obj->ActualValue = !obj->ActualValue;
StoAi
#define stoai_exec(obj, in) obj->ActualValue = in;
CStoAi
#define cstoai_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoPi
#define stopi_exec(rawvalue, absvalue, in) \
rawvalue->RawValue = in; \
absvalue->RawValue = in;
StoIo
#define stoio_exec(obj, in) obj->ActualValue = in;
CStoIo
#define cstoio_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoIv
#define stoiv_exec(obj, in) obj->ActualValue = in;
CStoIv
#define cstoiv_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoIi
#define stoii_exec(obj, in) obj->ActualValue = in;
CStoIi
#define cstoii_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoEo
#define stoeo_exec(obj, in) obj->ActualValue = in;
CStoEo
#define cstoeo_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoEv
#define stoev_exec(obj, in) obj->ActualValue = in;
CStoEv
#define cstoev_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoEi
#define stoei_exec(obj, in) obj->ActualValue = in;
CStoEi
#define cstoei_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoBiInt32
#define StoBiInt32_exec(obj, in) obj->ActualValue = in;
CStoBiInt32
#define CStoBiInt32_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoBoInt32
#define StoBoInt32_exec(obj, in) obj->ActualValue = in;
CStoBoInt32
#define CStoBoInt32_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoBiFloat32
#define StoBiFloat32_exec(obj, in) obj->ActualValue = in;
CStoBiFloat32
#define CStoBiFloat32_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoBoFloat32
#define StoBoFloat32_exec(obj, in) obj->ActualValue = in;
CStoBoFloat32
#define CStoBoFloat32_exec(obj, in, cond) \
if (cond) \
obj->ActualValue = in;
StoBiString80
#define StoBiString80_exec(obj, in) strncpy(obj->ActualValue, in, 80);
CStoBiString80
#define CStoBiString80_exec(obj, in, cond) \
if (cond) \
strncpy(obj->ActualValue, in, 80);
StoBoString80
#define StoBoString80_exec(obj, in) strncpy(obj->ActualValue, in, 80);
CStoBoString80
#define CStoBoString80_exec(obj, in, cond) \
if (cond) \
strncpy(obj->ActualValue, in, 80);
DtoI
#define DtoI_exec(obj, in) obj->ActVal = in ? 1 : 0;
AtoI
#define AtoI_exec(obj, in) obj->ActVal = in > 0 ? in + 0.5 : in - 0.5;
ItoA
#define ItoA_exec(obj, in) obj->ActVal = in;
StoDattr
#define StoDattr_exec(attr, in) attr = in;
SetDattr
#define SetDattr_exec(attr, in) \
if (in) \
attr = true;
ResDattr
#define ResDattr_exec(attr, in) \
if (in) \
attr = false;
StoIattr
#define StoIattr_exec(attr, in) attr = in;
CStoIattr
#define CStoIattr_exec(attr, in, cond) \
if (cond) \
attr = in;
StoAattr
#define StoAattr_exec(attr, in) attr = in;
CStoAattr
#define CStoAattr_exec(attr, in, cond) \
if (cond) \
attr = in;
StoSattr
#define StoSattr_exec(attr, in, size) \
strncpy(attr, in, size); \
attr[size - 1] = 0;
CStoSattr
#define CStoSattr_exec(attr, in, cond, size) \
if (cond) { \
strncpy(attr, in, size); \
attr[size - 1] = 0; \
}
CStoExtBoolean
#define CStoExtBoolean_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tBoolean)); \
} \
obj->OldCond = cond;
CStoExtFloat32
#define CStoExtFloat32_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tFloat32)); \
} \
obj->OldCond = cond;
CStoExtFloat64
#define CStoExtFloat64_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tFloat64)); \
} \
obj->OldCond = cond;
CStoExtInt8
#define CStoExtInt8_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus = gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tInt8)); \
} \
obj->OldCond = cond;
CStoExtInt16
#define CStoExtInt16_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus = gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tInt16)); \
} \
obj->OldCond = cond;
CStoExtInt32
#define CStoExtInt32_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus = gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tInt32)); \
} \
obj->OldCond = cond;
CStoExtInt64
#define CStoExtInt64_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus = gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tInt64)); \
} \
obj->OldCond = cond;
CStoExtUInt8
#define CStoExtUInt8_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus = gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tUInt8)); \
} \
obj->OldCond = cond;
CStoExtUInt16
#define CStoExtUInt16_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tUInt16)); \
} \
obj->OldCond = cond;
CStoExtUInt32
#define CStoExtUInt32_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tUInt32)); \
} \
obj->OldCond = cond;
CStoExtUInt64
#define CStoExtUInt64_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tUInt64)); \
} \
obj->OldCond = cond;
CStoExtString
#define CStoExtString_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus \
= gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tString80)); \
} \
obj->OldCond = cond;
CStoExtTime
#define CStoExtTime_exec(obj, name, in, cond) \
if (cond && !obj->OldCond) { \
obj->LastStatus = gdh_SetObjectInfo(name, (void*)&in, sizeof(pwr_tTime)); \
} \
obj->OldCond = cond;
GetExtFloat32
#define GetExtFloat32_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tFloat32)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtFloat32_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtFloat32_init(obj, name);
GetExtFloat64
#define GetExtFloat64_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tFloat64)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtFloat64_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtFloat64_init(obj, name);
GetExtInt64
#define GetExtInt64_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tInt64)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtInt64_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtInt64_init(obj, name);
GetExtUInt64
#define GetExtUInt64_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tUInt64)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtUInt64_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtUInt64_init(obj, name);
GetExtInt32
#define GetExtInt32_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tInt32)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtInt32_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtInt32_init(obj, name);
GetExtUInt32
#define GetExtUInt32_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tUInt32)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtUInt32_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtUInt32_init(obj, name);
GetExtInt16
#define GetExtInt16_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tInt16)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtInt16_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtInt16_init(obj, name);
GetExtUInt16
#define GetExtUInt16_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tUInt16)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtUInt16_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtUInt16_init(obj, name);
GetExtInt8
#define GetExtInt8_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tInt8)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtInt8_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtInt8_init(obj, name);
GetExtUInt8
#define GetExtUInt8_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tUInt8)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtUInt8_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtUInt8_init(obj, name);
GetExtBoolean
#define GetExtBoolean_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tBoolean)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtBoolean_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtBoolean_init(obj, name);
GetExtString
#define GetExtString_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tString80)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtString_exec(obj, name) \
if (obj->ExtP) \
strncpy(obj->ActVal, (const char *)obj->ExtP, sizeof(pwr_tString80)); \
else if (tp->ext_retry_connect) \
GetExtString_init(obj, name);
GetExtTime
#define GetExtTime_init(obj, name) \
{ \
if (gdh_RefObjectInfo(name, (void**)&obj->ExtP, 0, sizeof(pwr_tTime)) == GDH__NODYNLOCOBJ) \
obj->ExtP = 0; \
}
#define GetExtTime_exec(obj, name) \
if (obj->ExtP) \
obj->ActVal = *obj->ExtP; \
else if (tp->ext_retry_connect) \
GetExtTime_init(obj, name);
Float64toA
#define Float64toA_exec(obj, in) obj->ActVal = in;
AtoFloat64
#define AtoFloat64_exec(obj, in) obj->ActVal = in;
ItoUInt32
#define ItoUInt32_exec(obj, in) obj->ActVal = in;
UInt32toI
#define UInt32toI_exec(obj, in) obj->ActVal = in;
Int64toI
#define Int64toI_exec(obj, in) obj->ActVal = in;
ItoInt64
#define ItoInt64_exec(obj, in) obj->ActVal = in;
UInt64toI
#define UInt64toI_exec(obj, in) obj->ActVal = in;
ItoUInt64
#define ItoUInt64_exec(obj, in) obj->ActVal = in;
StoDataRefv
#define StoDataRefv_exec(obj, in) \
memcpy(&obj->ActualValue, &(in), sizeof(pwr_tDataRef));
CStoDataRefv
#define CStoDataRefv_exec(obj, in, cond) \
if (cond) \
memcpy(&obj->ActualValue, &(in), sizeof(pwr_tDataRef));
GetRefD
#define GetRefD_exec(obj, value) obj->Status = value;
GetRefI
#define GetRefI_exec(obj, value) obj->ActVal = value;
GetRefA
#define GetRefA_exec(obj, value) obj->ActVal = value;
StoRefD
#define StoRefD_exec(out, in) out = in;
SetRefD
#define SetRefD_exec(out, cond) \
if (cond) \
out = true;
ResRefD
#define ResRefD_exec(out, cond) \
if (cond) \
out = false;
StoRefI
#define StoRefI_exec(out, in) out = in;
DStoRefI
#define CStoRefI_exec(out, in, cond) \
if (cond) \
out = in;
StoRefA
#define StoRefA_exec(out, in) out = in;
CStoRefA
#define CStoRefA_exec(out, in, cond) \
if (cond) \
out = in;