Package tcg.scada.sim.iecsim.datastore

Examples of tcg.scada.sim.iecsim.datastore.DataPoint


 

  //Set Chars data point value (n chars. Boolean) // TESTED
  public synchronized void SetCharPoint(String pointname, String value)
  {
    DataPoint dp = dsTable_.getDataPoint(pointname);
    if (dp == null) {
      logger_.error("Can not find datapoint " + pointname + " for datastore " + datastore_.getId());
      return;
    }

    try
    {
      dp.setStringValue(value);
    }
    catch (Exception ex)
    {
      //ignore
    }
View Full Code Here


  public synchronized void SetAllCharPoints(String value)
  {
    Collection<DataPoint> dpList = dsTable_.getAllCXPoints();
    Iterator<DataPoint> it = dpList.iterator();
   
    DataPoint dp = null;
    while(it.hasNext())
    {
      dp = it.next();
      if (dp == null) continue;
     
      try
      {
        dp.setStringValue(value);
      }
      catch (Exception ex)
      {
        //ignore
      }     
View Full Code Here

  }

  //Get Chars data point value (n chars) // TESTED
  public String GetCharPoint(String pointname) throws Exception
  {
    DataPoint dp = dsTable_.getDataPoint(pointname);
    if (dp == null) {
      logger_.error("Can not find datapoint " + pointname + " for datastore " + datastore_.getId());
      return "";
    }
    return dp.getStringValue();
  }
View Full Code Here

  }

  //Set a data point value (DI->1st bit; AI->1 word; MI->2 words; etc) // TESTED
  public synchronized void SetPoint(String pointname, long value)
  {
    DataPoint dp = dsTable_.getDataPoint(pointname);
    if (dp == null) {
      logger_.error("Can not find datapoint " + pointname + " for datastore " + datastore_.getId());
      return;
    }

    try
    {
      if (dp.getDataType() == ETypeDiscriminator.TYPE_BOOLEAN)
      {
        boolean boolVal = ((value & 0x01) != 0);
        dp.setBooleanValue(boolVal);
      }
      else if (dp.getDataType() == ETypeDiscriminator.TYPE_INTEGER)
      {
        int intVal = (int)(value & 0x00FFFF);
        dp.setIntValue(intVal);
      }
      else if (dp.getDataType() == ETypeDiscriminator.TYPE_LONG)
      {
        dp.setLongValue(value);
      }
      else
      {
        //unsupported conversion
        logger_.warn("Can not translate value of " + dp.getName() + " to LONG.");
      }
    }
    catch (Exception ex)
    {
      //ignore
View Full Code Here

  {
    Enumeration<String> dpList = dsTable_.getDatapointList();
    while(dpList.hasMoreElements())
    {
      String key = (String) dpList.nextElement();
      DataPoint dp = dsTable_.getDataPoint(key);
      if (dp == null) continue;
     
      try
      {
        //value translation
        if (dp.getDataType() == ETypeDiscriminator.TYPE_BOOLEAN)
        {
          boolean boolVal = ((value & 0x01) != 0);
          dp.setBooleanValue(boolVal);
        }
        else if (dp.getDataType() == ETypeDiscriminator.TYPE_INTEGER)
        {
          int intVal = (int)(value & 0x00FFFF);
          dp.setIntValue(intVal);
        }
        else if (dp.getDataType() == ETypeDiscriminator.TYPE_LONG)
        {
          dp.setLongValue(value);
        }
        else
        {
          //unsupported conversion
          logger_.warn("Can not translate value of " + dp.getName() + " to LONG.");
        }
      }
      catch (Exception ex)
      {
        //ignore
View Full Code Here

  }

  //Get a data point value (DI->1st bit; AI->1 word; MI->2 words; etc) // TESTED
  public long GetPoint(String pointname) throws Exception
  {
    DataPoint dp = dsTable_.getDataPoint(pointname);
    if (dp == null) {
      logger_.error("Can not find datapoint " + pointname + " for datastore " + datastore_.getId());
      return 0;
    }

    long retval = 0;
    if (dp.getDataType() == ETypeDiscriminator.TYPE_BOOLEAN)
    {
      if (dp.getBooleanValue())
      {
        retval = 1;
      }
    }
    else if (dp.getDataType() == ETypeDiscriminator.TYPE_INTEGER)
    {
      retval = dp.getIntValue();
    }
    else if (dp.getDataType() == ETypeDiscriminator.TYPE_LONG)
    {
      retval = dp.getLongValue();
    }
    else if (dp.getDataType() == ETypeDiscriminator.TYPE_STRING)
    {
      String str = dp.getStringValue();
      retval = 0;
      for (int i=0; i<str.length(); i++)
      {
        int val = (int)str.charAt(i);
        retval |= (long)(val << (8 * i));
      }
      return retval;
    }
    else
    {
      //unsupported conversion
      logger_.warn("Can not translate value of " + dp.getName() + " to LONG.");
    }

    return 0;
  }
View Full Code Here

TOP

Related Classes of tcg.scada.sim.iecsim.datastore.DataPoint

Copyright © 2018 www.massapicom. 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.