Ejemplo n.º 1
0
static pwr_tStatus SyntaxCheck (
  ldh_tSesContext Session,
  pwr_tAttrRef Object,	      /* current object */
  int *ErrorCount,	      /* accumulated error count */
  int *WarningCount	      /* accumulated warning count */
) {
  wb_session *sp = (wb_session *)Session;
  pwr_tOid thread_oid;
  pwr_tOid reset_oid;

  // Check ThreadObject
  wb_attribute a = sp->attribute( Object.Objid, "RtBody", "ThreadObject");
  if (!a) return a.sts();
    
  a.value( &thread_oid);
  if ( !a) return a.sts();

  wb_object othread = sp->object( thread_oid);
  if ( !othread)
    wsx_error_msg_str( Session, "Bad thread object", Object, 'E', ErrorCount, WarningCount);
  else if ( othread.cid() != pwr_cClass_PlcThread)
    wsx_error_msg_str( Session, "Bad thread object class", Object, 'E', ErrorCount, WarningCount);
  

  // Check WindowPlc object
  bool found = 0;
  wb_object o = sp->object( Object.Objid);
  if ( !o) return o.sts();

  for ( wb_object child = o.first(); child; child = child.after()) {
    if ( child.cid() == pwr_cClass_windowplc) {
      found = 1;
      break;
    }
  }
  if ( !found)
    wsx_error_msg_str( Session, "Plc window is not created", Object, 'E', ErrorCount, WarningCount);


  // Check ResetObject if there is a grafcet sequence present
  if ( CheckChildCid( o, pwr_cClass_initstep)) {
    a = sp->attribute( Object.Objid, "DevBody", "ResetObject");
    if (!a) return a.sts();
    
    a.value( &reset_oid);
    if ( !a) return a.sts();

    wb_object oreset = sp->object( reset_oid);
    if ( !oreset)
      wsx_error_msg_str( Session, "Bad reset object", Object, 'E', ErrorCount, WarningCount);
    else if ( !(oreset.cid() == pwr_cClass_Dv ||
		oreset.cid() == pwr_cClass_Di ||
		oreset.cid() == pwr_cClass_Do))
      wsx_error_msg_str( Session, "Bad reset object class", Object, 'E', ErrorCount, WarningCount);      
  }

  return PWRB__SUCCESS;
}
Ejemplo n.º 2
0
pwr_tStatus wsx_CheckAttrRef( ldh_tSesContext	sesctx,
			      pwr_tAttrRef	aref,
			      const pwr_tObjName attribute,
			      pwr_tCid		*cid_vect,
			      int		null_is_ok,
			      int		*errorcount,
			      int		*warningcount)
{
  pwr_tAttrRef value;
  wb_session *sp = (wb_session *)sesctx;

  wb_attribute a = sp->attribute( &aref);
  if ( !a) return a.sts();

  wb_attribute a_attr( a, 0, attribute);
  if ( !a_attr) return a_attr.sts();
    
  a_attr.value( &value);
  if ( !a_attr) return a_attr.sts();

  if ( !null_is_ok && cdh_ObjidIsNull( value.Objid)) {
    char msg[80];
    sprintf ( msg, "Attribute reference is null in \"%s\"", attribute);
    wsx_error_msg_str( sesctx, msg, aref, 'E', errorcount, warningcount);
  }
  if ( cdh_ObjidIsNotNull( value.Objid)) {
    wb_attribute a_value = sp->attribute( &value);
    if ( !a_value) {
      char msg[80];
      sprintf ( msg, "Undefined attribute reference in \"%s\"", attribute);
      wsx_error_msg_str( sesctx, msg, aref, 'E', errorcount, warningcount);
    }
    else if ( cid_vect) {
      // Check attribute reference class
      bool found = false;
      for ( int i = 0; cid_vect[i]; i++) {
	if ( cid_vect[i] == a_value.tid()) {
	  found = true;
	  break;
	}
      }
      if ( !found) {
	char msg[80];
	sprintf ( msg, "Invalid class of attribute reference in \"%s\"", attribute);
	wsx_error_msg_str( sesctx, msg, aref, 'E', errorcount, warningcount);
      }
    }
  }
  return WSX__SUCCESS;
}
Ejemplo n.º 3
0
//
// SyntaxCheck
//
static pwr_tStatus SyntaxCheck (
    ldh_tSesContext Session,
    pwr_tAttrRef Object,
    int *ErrorCount,
    int *WarningCount
) {
    wb_session *sp = (wb_session *)Session;
    pwr_tString80 selectlist[40];

    wb_attribute a = sp->attribute( &Object);
    if ( !a) return a.sts();

    // Check Attribute
    wb_attribute selectlist_a( a, 0, "EventSelectList");
    if (!selectlist_a) return selectlist_a.sts();

    selectlist_a.value( selectlist);
    if ( !selectlist_a) return selectlist_a.sts();

    bool empty = true;
    for ( unsigned int i = 0; i < sizeof(selectlist)/sizeof(selectlist[0]); i++) {
        if ( strcmp( selectlist[i], "") != 0) {
            empty = false;
            break;
        }
    }
    if ( empty)
        wsx_error_msg_str( Session, "EventSelectList is empty", Object, 'W', ErrorCount, WarningCount);

    return PWRB__SUCCESS;
}
Ejemplo n.º 4
0
//
//  Syntax check.
//
static pwr_tStatus SyntaxCheck(
    ldh_tSesContext Session, pwr_tAttrRef Object, /* current object */
    int* ErrorCount, /* accumulated error count */
    int* WarningCount /* accumulated waring count */
    )
{
  wb_session* sp = (wb_session*)Session;
  pwr_tString40 server_name;

  wb_attribute a = sp->attribute(&Object);
  if (!a)
    return a.sts();

  // Check ServerNode
  wb_attribute thread_a(a, 0, "ServerNode");
  if (!thread_a)
    return thread_a.sts();

  thread_a.value(&server_name);
  if (!thread_a)
    return thread_a.sts();

  if (streq(server_name, ""))
    wsx_error_msg_str(Session, "Server name is missing", Object, 'E',
        ErrorCount, WarningCount);

  return PWRB__SUCCESS;
}
Ejemplo n.º 5
0
//
//  Syntax check.
//
static pwr_tStatus SyntaxCheck (
  ldh_tSesContext Session,
  pwr_tAttrRef Object,	      /* current object */
  int *ErrorCount,	      /* accumulated error count */
  int *WarningCount	      /* accumulated waring count */
) {

  // Check DataName
  wb_session *sp = (wb_session *)Session;
  pwr_tAttrRef dataname_aref;

  wb_attribute a = sp->attribute( &Object);
  if ( !a) return a.sts();

  wb_attribute dataname_a( a, 0, "DataName");
  if (!dataname_a) return dataname_a.sts();
    
  dataname_a.value( &dataname_aref);
  if ( !dataname_a) return dataname_a.sts();

  wb_attribute data_a = sp->attribute( &dataname_aref);
  if ( !data_a) {
    wsx_error_msg_str( Session, "Bad DataName reference", Object, 'E', ErrorCount, WarningCount);
    return PWRB__SUCCESS;
  }
  
  // Check DataName type
  switch ( data_a.tid()) {
  case	pwr_eType_Boolean:
  case	pwr_eType_Float32:
  case	pwr_eType_Float64:
  case	pwr_eType_Int8:
  case	pwr_eType_Int16:
  case	pwr_eType_Int32:
  case	pwr_eType_UInt8:
  case	pwr_eType_UInt16:
  case	pwr_eType_UInt32:
    break;
  default:
    wsx_error_msg_str( Session, "DataName type not supported", Object, 'E', ErrorCount, WarningCount);
  }
  return PWRB__SUCCESS;
}
Ejemplo n.º 6
0
static pwr_tStatus SyntaxCheck (
  ldh_tSesContext Session,
  pwr_tAttrRef Object,	      /* current object */
  int *ErrorCount,	      /* accumulated error count */
  int *WarningCount	      /* accumulated waring count */
) {
  wb_session *sp = (wb_session *)Session;
  pwr_tString80 str;

  wb_object o = sp->object( Object.Objid);
  wb_object p = o.parent();
  if ( !(!p || p.oid().oix == 0))
    wsx_error_msg_str( Session, "Not on top level", Object, 'E', ErrorCount, WarningCount);

  if ( Object.Objid.vid != ldh_cDirectoryVolume)
    wsx_error_msg_str( Session, "Not a DirectoryVolume", Object, 'E', ErrorCount, WarningCount);

  // Check SystemName
  wb_attribute a = sp->attribute( Object.Objid, "SysBody", "SystemName");
  if (!a) return a.sts();
    
  a.value( &str);
  if ( !a) return a.sts();

  dcli_trim( str, str);
  if ( strcmp( str, "") == 0)
    wsx_error_msg_str( Session, "SystemName is missing", Object, 'E', ErrorCount, WarningCount);

  // Check SystemGroup
  a = sp->attribute( Object.Objid, "SysBody", "SystemGroup");
  if (!a) return a.sts();
    
  a.value( &str);
  if ( !a) return a.sts();

  dcli_trim( str, str);
  if ( strcmp( str, "") == 0)
    wsx_error_msg_str( Session, "SystemGroup is missing", Object, 'E', ErrorCount, WarningCount);

  return PWRB__SUCCESS;
}
Ejemplo n.º 7
0
//
//  Syntax check method
//
static pwr_tStatus SyntaxCheck (
    ldh_tSesContext Session,
    pwr_tAttrRef Object,	      /* current object */
    int *ErrorCount,	      /* accumulated error count */
    int *WarningCount	      /* accumulated waring count */
) {
    wb_session *sp = (wb_session *)Session;
    pwr_tString80 str;

    wb_object o = sp->object( Object.Objid);
    wb_object p = o.parent();
    if ( !p ||
            !(p.cid() == pwr_cClass_BusConfig ||
              p.cid() == pwr_cClass_NodeConfig ||
              p.cid() == pwr_cClass_SevNodeConfig))
        wsx_error_msg_str( Session, "Bad parent", Object, 'E', ErrorCount, WarningCount);

    if ( Object.Objid.vid != ldh_cDirectoryVolume)
        wsx_error_msg_str( Session, "Not a DirectoryVolume", Object, 'E', ErrorCount, WarningCount);

    // Check NodeName
    wb_attribute a = sp->attribute( Object.Objid, "RtBody", "NodeName");
    if (!a) return a.sts();

    a.value( &str);
    if ( !a) return a.sts();

    dcli_trim( str, str);
    if ( strcmp( str, "") == 0)
        wsx_error_msg_str( Session, "NodeName is missing", Object, 'E', ErrorCount, WarningCount);

    // Check Address
    a = sp->attribute( Object.Objid, "RtBody", "Address");
    if (!a) return a.sts();

    a.value( &str);
    if ( !a) return a.sts();

    unsigned char adr1, adr2, adr3, adr4;
    int num;
    num = sscanf( str, "%hhu.%hhu.%hhu.%hhu", &adr1, &adr2, &adr3, &adr4);
    if ( num != 4)
        wsx_error_msg_str( Session, "Syntax error in Address", Object, 'E', ErrorCount, WarningCount);
    else if ( adr1 == 0 && adr2 == 0 && adr3 == 0 && adr4 == 0)
        wsx_error_msg_str( Session, "Address is zero", Object, 'E', ErrorCount, WarningCount);

    // Check Volume
    a = sp->attribute( Object.Objid, "RtBody", "Volume");
    if (!a) return a.sts();

    a.value( &str);
    if ( !a) return a.sts();

    dcli_trim( str, str);
    if ( strcmp( str, "") == 0)
        wsx_error_msg_str( Session, "Volume is missing", Object, 'E', ErrorCount, WarningCount);

    return PWRB__SUCCESS;
}
Ejemplo n.º 8
0
static pwr_tStatus SyntaxCheck( ldh_tSesContext Session,
                                pwr_tAttrRef Object,
                                int *ErrorCount,
                                int *WarningCount)
{
    wb_session *sp = (wb_session *)Session;
    pwr_tOid mount_oid;

    // Check Object attribute
    wb_attribute a = sp->attribute( Object.Objid, "SysBody", "Object");
    if (!a) return a.sts();

    a.value( &mount_oid);
    if ( !a) return a.sts();

    if ( cdh_ObjidIsNull( mount_oid)) {
        wsx_error_msg_str( Session, "Mounted object is missing", Object, 'E', ErrorCount, WarningCount);
    }
    return PWRS__SUCCESS;
}
Ejemplo n.º 9
0
pwr_tStatus wsx_CheckIoDevice( 
	ldh_tSesContext	sesctx,
	pwr_tAttrRef	aref,
	int		*errorcount,
	int		*warningcount,
	wsx_mCardOption options
)
{
  wb_session *sp = (wb_session *)sesctx;
  pwr_tMask process;
  pwr_tOid thread;

  wb_attribute a = sp->attribute( &aref);
  if ( !a) return a.sts();

  // Check Process
  wb_attribute process_a( a, 0, "Process");
  if ( !process_a) return process_a.sts();
    
  process_a.value( &process);
  if ( !process_a) return process_a.sts();
  if ( process == 0)
    wsx_error_msg_str( sesctx, "Process is not specified", aref, 'W', errorcount, warningcount);
  else if ( process == 1) {

    // Check thread object
    wb_attribute thread_a( a, 0, "ThreadObject");
    if ( !thread_a) return thread_a.sts();
    
    thread_a.value( &thread);
    if ( !thread_a) return thread_a.sts();
    if ( cdh_ObjidIsNull( thread))
      wsx_error_msg_str( sesctx, "ThreadObject is not specified", aref, 'E', errorcount, warningcount);
    else {
      wb_object thread_o = sp->object( thread);
      if ( !thread_o)
	wsx_error_msg_str( sesctx, "Undefined ThreadObject", aref, 'E', errorcount, warningcount);
      else if ( thread_o.cid() != pwr_cClass_PlcThread)
	wsx_error_msg_str( sesctx, "Error in ThreadObject class", aref, 'E', errorcount, warningcount);
    }
  }

  if ( options & wsx_mCardOption_ErrorLimits) {
    pwr_tUInt32 limit;

    // Check SoftLimit
    wb_attribute softlimit_a( a, 0, "ErrorSoftLimit");
    if ( !softlimit_a) return softlimit_a.sts();
    
    softlimit_a.value( &limit);
    if ( !softlimit_a) return softlimit_a.sts();
    if ( limit == 0)
      wsx_error_msg_str( sesctx, "ErrorSoftLimit is not specified", aref, 'W', errorcount, warningcount);

    // Check HardLimit
    wb_attribute hardlimit_a( a, 0, "ErrorHardLimit");
    if ( !hardlimit_a) return hardlimit_a.sts();
    
    hardlimit_a.value( &limit);
    if ( !hardlimit_a) return hardlimit_a.sts();
    if ( limit == 0)
      wsx_error_msg_str( sesctx, "ErrorHardLimit is not specified", aref, 'E', errorcount, warningcount);

  }
  return WSX__SUCCESS;
}