static pwr_tStatus PostMove ( ldh_tSesContext Session, pwr_tObjid Object, pwr_tObjid Father, pwr_tClassId Class ) { pwr_tStatus sts; int size; pwr_tAName Name; pwr_sAttrRef Attribute; /* If father of ASup has an "ActualValue" attribute, then make this ASup refer to this attribute. */ sts = ldh_ObjidToName(Session, Father, ldh_eName_Hierarchy, Name, sizeof(Name), &size); if (EVEN(sts)) return PWRB__SUCCESS; strcat(Name, ".ActualValue"); sts = ldh_NameToAttrRef(Session, Name, &Attribute); if (EVEN(sts)) return PWRB__SUCCESS; sts = ldh_SetObjectPar(Session, Object, "RtBody", "DataName", (char *)&Attribute, sizeof(Attribute)); if (EVEN(sts)) return PWRB__SUCCESS; return PWRB__SUCCESS; }
static pwr_tStatus PostCreate ( ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Father, pwr_tCid Class ) { pwr_tStatus sts; pwr_tObjName name; pwr_tMask value = 1; int size; sts = ldh_ObjidToName( Session, Object, ldh_eName_Object, name, sizeof(name), &size); if ( EVEN(sts)) return sts; if ( strcmp( name, "OpDefault") == 0) { // Set OpHide in OpWindLayout sts = ldh_SetObjectPar( Session, Object, "RtBody", "OpWindLayout", (char *) &value, sizeof(value)); if ( EVEN(sts)) return sts; } return PWRS__SUCCESS; }
void WAttTextGtk::set_attr_value() { int size = input_max_length + 1; pwr_tStatus sts; gchar *text, *textutf8; unsigned char* s; if (editmode) { GtkTextIter start_iter, end_iter; gtk_text_buffer_get_start_iter(textbuffer, &start_iter); gtk_text_buffer_get_end_iter(textbuffer, &end_iter); textutf8 = gtk_text_buffer_get_text(textbuffer, &start_iter, &end_iter, FALSE); text = g_convert(textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL); g_free(textutf8); if (text) { // Replace ctrl characters with space for (s = (unsigned char*)text; *s; s++) { if (*s < ' ' && *s != 10 && *s != 13) *s = ' '; } sts = ldh_SetObjectPar(ldhses, aref.Objid, "DevBody", aname, text, size); g_free(text); } else wow->DisplayError("Input error", "Invalid character"); } }
static pwr_tStatus PostCreate ( ldh_tSesContext Session, pwr_tOid Object, pwr_tOid Father, pwr_tCid Class ) { pwr_tOid oid; pwr_tOid toid; pwr_tStatus sts; int cnt = 0; sts = ldh_GetClassList( Session, pwr_cClass_PlcThread, &oid); while ( ODD(sts)) { cnt++; toid = oid; sts = ldh_GetNextObject( Session, oid, &oid); } if ( cnt > 0) { sts = ldh_SetObjectPar( Session, Object, "RtBody", "ThreadObject", (char *)&toid, sizeof(toid)); if ( EVEN(sts)) return sts; } return PWRB__SUCCESS; }
static pwr_tStatus PostCreate ( ldh_tSesContext Session, pwr_tObjid Object, pwr_tObjid Father, pwr_tClassId Class ) { pwr_tStatus sts; pwr_tObjName name, uname; int size; // Set class name in StructName sts = ldh_ObjidToName( Session, Father, cdh_mName_object, name, sizeof(name), &size); if ( EVEN(sts)) return sts; strcpy( uname, wb_name::unatName( name)); sts = ldh_SetObjectPar( Session, Object, "SysBody", "StructName", uname, sizeof(pwr_tPgmName)); if ( EVEN(sts)) return sts; return PWRS__SUCCESS; }
static pwr_tStatus Connect ( ldh_sMenuCall *ip ) { pwr_tStatus sts; pwr_sMenuButton mb; pwr_sAttrRef PattrRef; pwr_sAttrRef aref = ip->Selected[0]; sts = ldh_ReadObjectBody(ip->PointedSession, ip->ItemList[ip->ChosenItem].MenuObject, "SysBody", &mb, sizeof(pwr_sMenuButton)); if (EVEN(sts)) return sts; if ( strcmp( mb.MethodArguments[1], "") != 0) { char arg_cid_str[20][32]; int arg_cid_cnt; int i; int cid_ok = 0; pwr_tCid cid; pwr_tCid arg_cid; // arg 1 holds the allowed class or classes to connect to arg_cid_cnt = dcli_parse( mb.MethodArguments[1], ",", "", (char *) arg_cid_str, sizeof( arg_cid_str) / sizeof( arg_cid_str[0]), sizeof( arg_cid_str[0]), 0); sts = ldh_GetAttrRefTid( ip->PointedSession, &ip->Selected[0], &cid); if ( EVEN(sts)) return 0; for ( i = 0; i < arg_cid_cnt; i++) { sts = ldh_ClassNameToId( ip->PointedSession, &arg_cid, arg_cid_str[i]); if ( EVEN(sts)) return 0; if ( cid == arg_cid) { cid_ok = 1; break; } } if ( !cid_ok) return 0; } if ( strcmp( mb.MethodArguments[2], "") != 0) // Body in MethodArguments 2, probably DevBody sts = ldh_SetObjectPar( ip->PointedSession, ip->Pointed.Objid, mb.MethodArguments[2], mb.MethodArguments[0], (char *) &ip->Selected[0], sizeof(ip->Selected[0])); else { char *name_p; pwr_tAName name; int size; pwr_tCid cid; // If Selected is a Template object in a classvolume, replace with // symbol $IoConnect if ( cdh_IsClassVolume( aref.Objid.vid)) { sts = ldh_ObjidToName( ip->PointedSession, aref.Objid, ldh_eName_Object, name, sizeof(name), &size); if ( ODD(sts) && strcmp( name, "Template") == 0) { sts = ldh_GetObjectClass( ip->PointedSession, aref.Objid, &cid); if ( EVEN(sts)) return sts; aref.Objid.vid = ldh_cIoConnectVolume; aref.Objid.oix = cid; } } // Assume RtBody or SysBody sts = ldh_AttrRefToName(ip->PointedSession, &ip->Pointed, ldh_eName_VolPath, &name_p, &size); if ( ODD(sts)) { strcpy( name, name_p); strcat( name, "."); strcat( name, mb.MethodArguments[0]); sts = ldh_NameToAttrRef( ip->PointedSession, name, &PattrRef); if (ODD(sts)) sts = ldh_WriteAttribute(ip->PointedSession, &PattrRef, &aref, sizeof(aref)); } } char msg[500]; if ( ODD(sts)) { pwr_tAName name; char *name_p; int len; sts = ldh_AttrRefToName( ip->PointedSession, &aref, ldh_eName_Hierarchy, &name_p, &len); if ( EVEN(sts)) cdh_ObjidToString( name, aref.Objid, 1); else strcpy( name, name_p); sprintf( msg, "%s connected to: %s", mb.MethodArguments[0], name); ip->wtt->message( 'I', msg); } else { msg_GetMsg( sts, msg, sizeof(msg)); ip->wtt->message( 'E', msg); } 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; unsigned int flags; pwr_tInt32 int_val; pwr_tObjid oid; pwr_tObjid coid; int plcconnect = 0; int plctemplate = 0; char str[80]; pwr_sMenuButton mb; sts = ldh_GetChild(ip->PointedSession, ip->Pointed.Objid, &oid); if ( ODD(sts)) { ip->wnav->wow->DisplayError( "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; plctemplate = 1; } else if ( strcmp(mb.MethodArguments[0], "CCode") == 0) { plcconnect = 0; plctemplate = 0; } else if ( strcmp(mb.MethodArguments[0], "PlcConnectCCode") == 0) { plcconnect = 1; plctemplate = 0; } else { plcconnect = 0; plctemplate = 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) { // Create PlcConnect attribute 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, &coid, "PlcConnect", pwr_eClass_Intern, oid, ldh_eDest_IntoLast); if ( ODD(sts)) { tid = pwr_eType_AttrRef; sts = ldh_SetObjectPar(ip->PointedSession, coid, "SysBody", "TypeRef", (char *)&tid, sizeof(tid)); if ( EVEN(sts)) return sts; } if ( !plctemplate) { // Create PlcConnectP attribute sts = ldh_CreateObject( ip->PointedSession, &coid, "PlcConnectP", pwr_eClass_Intern, oid, ldh_eDest_IntoLast); if ( ODD(sts)) { tid = pwr_eType_Char; sts = ldh_SetObjectPar(ip->PointedSession, coid, "SysBody", "TypeRef", (char *)&tid, sizeof(tid)); if ( EVEN(sts)) return sts; flags = PWR_MASK_INVISIBLE | PWR_MASK_POINTER | PWR_MASK_PRIVATE; sts = ldh_SetObjectPar(ip->PointedSession, coid, "SysBody", "Flags", (char *)&flags, sizeof(flags)); 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)) { if ( plctemplate) { pwr_tCid scid[2]; scid[0] = pwr_cClass_windowplc; scid[1] = 0; 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 *)scid, sizeof(scid)); 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; if ( plctemplate) int_val = 58; else if ( plcconnect) int_val = 35; else int_val = 4; 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; } } if ( plctemplate) { sts = ldh_CreateObject( ip->PointedSession, &oid, "Code", pwr_cClass_PlcTemplate, ip->Pointed.Objid, ldh_eDest_IntoLast); } return PWRS__SUCCESS; }