Examples of ICosDataPointServer


Examples of tcg.scada.cos.ICosDataPointServer

  }

  @Override
  protected boolean running()
  {
    ICosDataPointServer dpServer = CorbaHelper.getActiveDataPointServer(locationId);
    if (dpServer == null)
    {
      logger.error("Can not get datapoint server for location " + locationId);
      return false;
    }
     
    //get actual datapoint name
    String[] items = new String[1];
    items[0] = datapointName.replace(".Value", "");

    //get the actual value
    CosDpValueStruct[] values = new CosDpValueStruct[1];
    values[0] = new CosDpValueStruct();
    values[0].quality = CosDpQualityEnum.QualityGood;
    values[0].timestamp = 0;
    values[0].value = new CosDpValueUnion();
   
    //storage for error
    CosDpErrorSeqHolder errors = new CosDpErrorSeqHolder();
   
    if (isDigitalControl)
    {
      //for digital control, anything other than 0 is treated as true value
      //anyway we should never send digital control with value = false.
      if (datapointValue == 0)
      {
        values[0].value.boolValue(false);
      }
      else
      {
        values[0].value.boolValue(true);
      }
    }
    else
    {
      values[0].value.longValue(datapointValue);
    }
   
    //verbose
    logger.info("Sending control. Datapoint: " + items[0] + ". Value: " + datapointValue);

    //send the control
    try
    {
      dpServer.cosSetControlItem2(items, values, errors);
      //check the error code
      if (errors.value[0].value() != CosDpErrorEnum.ErrNoError.value())
      {
        logger.error("Fail to send control. Error: "
                + CorbaHelper.DpErrorCodeToString(errors.value[0]));
        return false;
      }
    }
    catch(Exception ex)
    {
      logger.error("Fail to send control. Exception: " + ex.getMessage());
      return false;
    }
   
    //check for return condition (only if it has return condition!)
    if (rccTimeoutSec > 0)
    {
      //rcc timeout in msec
      long timeoutMSec = (Calendar.getInstance().getTimeInMillis()) + (rccTimeoutSec * 1000);
     
      //storage for RCC status
      CosBooleanSeqHolder status = new CosBooleanSeqHolder();

      boolean rccStatus = false;
      int errorCounter = 0;
      while(timeoutMSec > Calendar.getInstance().getTimeInMillis())
      {
        //check the return condition status
        try
        {
          dpServer.cosGetItemReturnConditionStatus2(items, status, errors);
          //check the error code
          if (errors.value[0].value() != CosDpErrorEnum.ErrNoError.value())
          {
            logger.warn("Fail to get return condition status. Error: "
                    + CorbaHelper.DpErrorCodeToString(errors.value[0]));
View Full Code Here

Examples of tcg.scada.cos.ICosDataPointServer

    //build the corba server key
    String key = STR_DATAPOINT_SERVER.value + "-" + location;
   
    //try to get from the primary process manager
    ICosMonitoredThread  thread = null;
    ICosDataPointServer dpServer = null;
    if (instance.mgrRef1_ != null)
    {
      try
      {
        //try to get the active reference from this process manager
        thread = instance.mgrRef1_.cosGetActiveCorbaServer(key);
        dpServer = ICosDataPointServerHelper.narrow(thread);
        //make sure it is really in control
        if (dpServer != null)
        {
          dpServer.cosPollControl();
        }
      }
      catch (Exception ex)
      {
        logger_.error("Can not get reference to active dpserver for location " + location
                + " in primary Process Manager");
        logger_.error("Exception: " + ex.toString());
        //reset the reference
        dpServer = null;
      }
    }
   
    //try to get from the secondary process manager if we still did not get proper reference
    if (dpServer == null && instance.mgrRef2_ != null)
    {
      try
      {
        //try to get the active reference from this process manager
        thread = instance.mgrRef2_.cosGetActiveCorbaServer(key);
        dpServer = ICosDataPointServerHelper.narrow(thread);
        //make sure it is really in control
        if (dpServer != null)
        {
          dpServer.cosPollControl();
        }
      }
      catch (Exception ex)
      {
        logger_.error("Can not get reference to active dpserver for location " + location
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.