Commit 5347a161 authored by claes's avatar claes

PlcConnect method added

parent 7b34241a
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
#include "wb_pwrs.h" #include "wb_pwrs.h"
#include "wb_pwrs_msg.h" #include "wb_pwrs_msg.h"
#include "wb_ldh.h" #include "wb_ldh.h"
#include "pwr_baseclasses.h"
#include "ge.h" #include "ge.h"
#include "co_wow.h"
static pwr_tStatus AnteCreate ( static pwr_tStatus AnteCreate (
ldh_tSesContext Session, ldh_tSesContext Session,
...@@ -46,9 +48,174 @@ static pwr_tStatus OpenClassGraph ( ...@@ -46,9 +48,174 @@ static pwr_tStatus OpenClassGraph (
return PWRS__SUCCESS; return PWRS__SUCCESS;
} }
static pwr_tStatus ConfigFc (
ldh_sMenuCall *ip
)
{
int sts;
pwr_tOName name;
pwr_tOName pname;
pwr_tObjName oname;
int size;
pwr_tCid cid;
pwr_tTid tid;
pwr_tInt32 int_val;
pwr_tObjid oid;
int plcconnect = 0;
char str[80];
pwr_sMenuButton mb;
sts = ldh_GetChild(ip->PointedSession, ip->Pointed.Objid, &oid);
if ( ODD(sts)) {
wow_DisplayError( ip->WindowContext, "Error",
"ClassDef is already configured\n Object has child");
return 0;
}
/* If argument is PlcConnect, configure a connected function object
i.e. an $Intern named PlcConnnect, a PlcConnect MenuRef, and
connectmethod 10 */
sts = ldh_ReadObjectBody(ip->PointedSession,
ip->ItemList[ip->ChosenItem].MenuObject,
"SysBody", &mb, sizeof(pwr_sMenuButton));
if ( strcmp(mb.MethodArguments[0], "PlcConnect") == 0)
plcconnect = 1;
sts = ldh_ObjidToName( ip->PointedSession, ip->Pointed.Objid, ldh_eName_Hierarchy,
pname, sizeof(pname), &size);
if ( EVEN(sts)) return sts;
sts = ldh_ObjidToName( ip->PointedSession, ip->Pointed.Objid, ldh_eName_Object,
oname, sizeof(oname), &size);
if ( EVEN(sts)) return sts;
sts = ldh_CreateObject( ip->PointedSession, &oid, "RtBody", pwr_eClass_ObjBodyDef,
ip->Pointed.Objid, ldh_eDest_IntoFirst);
if ( plcconnect) {
strcpy( name, pname);
strcat( name, "-");
strcat( name, "RtBody");
sts = ldh_NameToObjid( ip->PointedSession, &oid, name);
if ( EVEN(sts)) return sts;
sts = ldh_CreateObject( ip->PointedSession, &oid, "PlcConnect", pwr_eClass_Intern,
oid, ldh_eDest_IntoLast);
if ( ODD(sts)) {
tid = pwr_eType_AttrRef;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "TypeRef", (char *)&tid,
sizeof(tid));
if ( EVEN(sts)) return sts;
}
}
sts = ldh_CreateObject( ip->PointedSession, &oid, "DevBody", pwr_eClass_ObjBodyDef,
ip->Pointed.Objid, ldh_eDest_IntoLast);
if ( EVEN(sts)) {
// The object already exist
}
strcpy( name, pname);
strcat( name, "-");
strcat( name, "DevBody");
sts = ldh_NameToObjid( ip->PointedSession, &oid, name);
if ( EVEN(sts)) return sts;
sts = ldh_CreateObject( ip->PointedSession, &oid, "PlcNode", pwr_eClass_Buffer,
oid, ldh_eDest_IntoLast);
if ( ODD(sts)) {
cid = pwr_eClass_PlcNode;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "Class", (char *)&cid,
sizeof(cid));
if ( EVEN(sts)) return sts;
}
sts = ldh_CreateObject( ip->PointedSession, &oid, "GraphPlcNode",
pwr_eClass_GraphPlcNode,
ip->Pointed.Objid, ldh_eDest_IntoLast);
if ( ODD(sts)) {
cid = pwr_cClass_windowplc;
int_val = 1;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "subwindows",
(char *)&int_val, sizeof(int_val));
if ( EVEN(sts)) return sts;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "subwindow_class[0]",
(char *)&cid, sizeof(cid));
if ( EVEN(sts)) return sts;
int_val = 1;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "segname_annotation",
(char *)&int_val, sizeof(int_val));
if ( EVEN(sts)) return sts;
int_val = 58;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "compmethod",
(char *)&int_val, sizeof(int_val));
if ( EVEN(sts)) return sts;
if ( plcconnect) {
int_val = 10;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "connectmethod",
(char *)&int_val, sizeof(int_val));
if ( EVEN(sts)) return sts;
}
int_val = 2;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "executeordermethod",
(char *)&int_val, sizeof(int_val));
if ( EVEN(sts)) return sts;
oname[15] = 0;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "objname",
oname, sizeof(pwr_tString16));
if ( EVEN(sts)) return sts;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "graphname",
oname, sizeof(pwr_tString16));
if ( EVEN(sts)) return sts;
}
if ( plcconnect) {
sts = ldh_CreateObject( ip->PointedSession, &oid, "RtXtt",
pwr_eClass_RtMenu,
ip->Pointed.Objid, ldh_eDest_IntoLast);
strcpy( name, pname);
strcat( name, "-");
strcat( name, "RtXtt");
sts = ldh_NameToObjid( ip->PointedSession, &oid, name);
if ( EVEN(sts)) return sts;
sts = ldh_CreateObject( ip->PointedSession, &oid, "PlcConnect", pwr_eClass_MenuRef,
oid, ldh_eDest_IntoLast);
if ( ODD(sts)) {
strcpy( str, "PlcConnect");
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "ButtonName",
str, sizeof(pwr_tString40));
if ( EVEN(sts)) return sts;
sts = ldh_SetObjectPar(ip->PointedSession, oid, "SysBody", "RefAttribute",
str, sizeof(pwr_tString40));
if ( EVEN(sts)) return sts;
}
}
sts = ldh_CreateObject( ip->PointedSession, &oid, "Code",
pwr_cClass_PlcTemplate,
ip->Pointed.Objid, ldh_eDest_IntoLast);
return PWRS__SUCCESS;
}
pwr_dExport pwr_BindMethods($ClassDef) = { pwr_dExport pwr_BindMethods($ClassDef) = {
pwr_BindMethod(AnteCreate), pwr_BindMethod(AnteCreate),
pwr_BindMethod(OpenClassGraph), pwr_BindMethod(OpenClassGraph),
pwr_BindMethod(ConfigFc),
pwr_NullMethod pwr_NullMethod
}; };
......
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