}
//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;
}