Commit 451af186 authored by claes's avatar claes

New plc classes for get and csto of attributes in externvolumes

parent ff037b3d
/*
* Proview $Id: rt_plc_macro_io.h,v 1.7 2005-10-18 05:11:34 claes Exp $
* Proview $Id: rt_plc_macro_io.h,v 1.8 2007-04-25 07:25:34 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -373,4 +373,260 @@
attr[size-1] = 0; \
}
/*_*
CStoExtFloat32
@aref cstoextfloat32 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;
/*_*
GetExtFloat32
@aref getextfloat32 GetExtFloat32
*/
#define GetExtFloat32_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tFloat32)); \
}
#define GetExtFloat32_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtFloat64
@aref getextfloat64 GetExtFloat64
*/
#define GetExtFloat64_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tFloat64)); \
}
#define GetExtFloat64_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtInt64
@aref getextint64 GetExtInt64
*/
#define GetExtInt64_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tInt64)); \
}
#define GetExtInt64_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtUInt64
@aref getextuint64 GetExtUInt64
*/
#define GetExtUInt64_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tUInt64)); \
}
#define GetExtUInt64_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtInt32
@aref getextint32 GetExtInt32
*/
#define GetExtInt32_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tInt32)); \
}
#define GetExtInt32_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtUInt32
@aref getextuint32 GetExtUInt32
*/
#define GetExtUInt32_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tUInt32)); \
}
#define GetExtUInt32_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtInt16
@aref getextint16 GetExtInt16
*/
#define GetExtInt16_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tInt16)); \
}
#define GetExtInt16_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtUInt16
@aref getextuint16 GetExtUInt16
*/
#define GetExtUInt16_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tUInt16)); \
}
#define GetExtUInt16_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtInt8
@aref getextint8 GetExtInt8
*/
#define GetExtInt8_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tInt8)); \
}
#define GetExtInt8_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtUInt8
@aref getextuint8 GetExtUInt8
*/
#define GetExtUInt8_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tUInt8)); \
}
#define GetExtUInt8_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtBoolean
@aref getextboolean GetExtBoolean
*/
#define GetExtBoolean_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tBoolean)); \
}
#define GetExtBoolean_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
GetExtString
@aref getextstring GetExtString
*/
#define GetExtString_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tString80)); \
}
#define GetExtString_exec(obj) \
if ( obj->ExtP) \
strncpy( obj->ActVal, obj->ExtP, sizeof(pwr_tString80));
/*_*
GetExtTime
@aref getexttime GetExtTime
*/
#define GetExtTime_init(obj, name) \
{ \
gdh_RefObjectInfo( name, &obj->ExtP, 0, sizeof(pwr_tTime)); \
}
#define GetExtTime_exec(obj) \
if ( obj->ExtP) \
obj->ActVal = *obj->ExtP;
/*_*
Float64toA
@aref float64toa Float64toA
*/
#define Float64toA_exec(obj,in) \
obj->ActVal = in;
/*_*
AtoFloat64
@aref atofloat64 AtoFloat64
*/
#define AtoFloat64_exec(obj,in) \
obj->ActVal = in;
/*_*
ItoUInt32
@aref itouint32 ItoUInt32
*/
#define ItoUInt32_exec(obj,in) \
obj->ActVal = in;
/*_*
UInt32toI
@aref uint32toi UInt32toI
*/
#define UInt32toI_exec(obj,in) \
obj->ActVal = in;
/*_*
Int64toI
@aref int64toi Int64toI
*/
#if defined OS_LINUX
#define Int64toI_exec(obj,in) \
obj->ActVal = in;
#else
#define Int64toI_exec(obj,in) \
obj->ActVal = (0x80000000 & in.high) | (0xEFFFFFFF & in.low);
#endif
/*_*
ItoInt64t
@aref itoint64 ItoInt64
*/
#if defined OS_LINUX
#define ItoInt64_exec(obj,in) \
obj->ActVal = in;
#else
#define ItoInt64_exec(obj,in) \
obj->ActVal.high = in & 0x80000000;
obj->ActVal.low = in & 0xEFFFFFFF;
#endif
/*_*
UInt64toI
@aref uint64toi UInt64toI
*/
#if defined OS_LINUX
#define UInt64toI_exec(obj,in) \
obj->ActVal = in;
#else
#define UInt64toI_exec(obj,in) \
obj->ActVal = in.low;
#endif
/*_*
ItoUInt64
@aref itouint64toi ItoUInt64
*/
#if defined OS_LINUX
#define ItoUInt64_exec(obj,in) \
obj->ActVal = in;
#else
#define ItoUInt64_exec(obj,in) \
obj->ActVal.low = in;
obj->ActVal.high = 0;
#endif
/*
* Proview $Id: wb_gcg.cpp,v 1.1 2007-01-04 07:29:03 claes Exp $
* Proview $Id: wb_gcg.cpp,v 1.2 2007-04-25 07:28:00 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -223,6 +223,8 @@ int gcg_comp_m60( gcg_ctx gcgctx, vldh_t_node node);
int gcg_comp_m61( gcg_ctx gcgctx, vldh_t_node node);
int gcg_comp_m62( gcg_ctx gcgctx, vldh_t_node node);
int gcg_comp_m63( gcg_ctx gcgctx, vldh_t_node node);
int gcg_comp_m64( gcg_ctx gcgctx, vldh_t_node node);
int gcg_comp_m65( gcg_ctx gcgctx, vldh_t_node node);
gcg_tMethod gcg_comp_m[70] = {
(gcg_tMethod)gcg_comp_m0,
......@@ -288,7 +290,9 @@ gcg_tMethod gcg_comp_m[70] = {
gcg_comp_m60,
gcg_comp_m61,
gcg_comp_m62,
gcg_comp_m63
gcg_comp_m63,
gcg_comp_m64,
gcg_comp_m65
};
......@@ -15232,6 +15236,137 @@ int gcg_comp_m63( gcg_ctx gcgctx, vldh_t_node node)
return GSX__SUCCESS;
}
/*************************************************************************
*
* Name: gcg_comp_m64()
*
* Type void
*
* Type Parameter IOGF Description
* gcg_ctx gcgctx I gcg context.
* vldh_t_node node I vldh node.
*
* Description:
* Compile method for a GetExt...
* Prints code for declaration and direkt link of rtdbpointer for
* the actual object.
* Prints an exec call :
*
* 'structname'_exec( 'objectpointer', 'in1', 'in2', 'in3'...);
*
* and init call
* 'structname'_init( 'objectpointer', "'extattribute'");
*
**************************************************************************/
int gcg_comp_m64( gcg_ctx gcgctx, vldh_t_node node)
{
int sts;
int size;
char *extattr_ptr;
char *name;
// Get extern attribute
sts = ldh_GetObjectPar( (node->hn.wind)->hw.ldhses, node->ln.oid, "DevBody",
"ExtAttribute", (char **)&extattr_ptr, &size);
if (EVEN(sts)) return sts;
if ( *extattr_ptr == 0) {
gcg_error_msg( gcgctx, GSX__REFOBJ, node);
return GSX__NEXTNODE;
}
sts = gcg_ref_insert( gcgctx, node->ln.oid, GCG_PREFIX_REF);
/* Get name for this class */
sts = gcg_get_structname( gcgctx, node->ln.oid, &name);
if( EVEN(sts)) return sts;
/* Print the execute command */
IF_PR fprintf( gcgctx->files[GCGM1_CODE_FILE],
"%s_exec( %c%s);\n",
name,
GCG_PREFIX_REF,
vldh_IdToStr(0, node->ln.oid));
/* Print the init command */
IF_PR fprintf( gcgctx->files[GCGM1_REF_FILE],
"%s_init( %c%s, \"%s\");\n",
name,
GCG_PREFIX_REF,
vldh_IdToStr(0, node->ln.oid),
extattr_ptr);
gcg_scantime_print( gcgctx, node->ln.oid);
gcg_timer_print( gcgctx, node->ln.oid);
free( extattr_ptr);
return GSX__SUCCESS;
}
/*************************************************************************
*
* Name: gcg_comp_m65()
*
* Type void
*
* Type Parameter IOGF Description
* gcg_ctx gcgctx I gcg context.
* vldh_t_node node I vldh node.
*
* Description:
* Compile method for a CStoExt...
* Prints code for declaration and direkt link of rtdbpointer for
* the actual object.
* Prints an exec call :
*
* 'structname'_exec( 'objectpointer', 'name', 'in1', 'in2');
*
* If the any inputs are not connected or not visible zero is printed
* in its place in the exec call.
*
**************************************************************************/
int gcg_comp_m65( gcg_ctx gcgctx, vldh_t_node node)
{
int sts;
int size;
char *extattr_ptr;
// Get extern attribute
sts = ldh_GetObjectPar( (node->hn.wind)->hw.ldhses, node->ln.oid, "DevBody",
"ExtAttribute", (char **)&extattr_ptr, &size);
if (EVEN(sts)) return sts;
if ( *extattr_ptr == 0) {
gcg_error_msg( gcgctx, GSX__REFOBJ, node);
return GSX__NEXTNODE;
}
sts = gcg_ref_insert( gcgctx, node->ln.oid, GCG_PREFIX_REF);
sts = gcg_print_exec_macro( gcgctx, node, node->ln.oid, GCG_PREFIX_REF);
if (EVEN(sts)) return sts;
IF_PR fprintf( gcgctx->files[GCGM1_CODE_FILE],
"\"%s\", ", extattr_ptr);
sts = gcg_print_inputs( gcgctx, node, ", ", GCG_PRINT_ALLPAR, NULL, NULL);
if ( EVEN(sts)) return sts;
IF_PR fprintf( gcgctx->files[GCGM1_CODE_FILE],
");\n");
gcg_scantime_print( gcgctx, node->ln.oid);
gcg_timer_print( gcgctx, node->ln.oid);
free( extattr_ptr);
return GSX__SUCCESS;
}
/*************************************************************************
*
* Name: gcg_wind_check_modification()
......
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