Search in sources :

Example 56 with DataPointRT

use of com.serotonin.m2m2.rt.dataImage.DataPointRT in project ma-core-public by infiniteautomation.

the class ScriptExecutor method convertScriptContext.

/**
 * @param context
 * @return
 * @throws DataPointStateException
 */
public static Map<String, IDataPointValueSource> convertScriptContext(List<ScriptContextVariable> context) throws DataPointStateException {
    Map<String, IDataPointValueSource> converted = new HashMap<String, IDataPointValueSource>();
    for (ScriptContextVariable contextEntry : context) {
        DataPointRT point = Common.runtimeManager.getDataPoint(contextEntry.getDataPointId());
        if (point == null) {
            DataPointVO vo = DataPointDao.instance.get(contextEntry.getDataPointId());
            if (vo == null)
                throw new DataPointStateException(contextEntry.getDataPointId(), new TranslatableMessage("event.script.contextPointMissing", contextEntry.getVariableName(), contextEntry.getDataPointId()));
            else
                throw new DataPointStateException(contextEntry.getDataPointId(), new TranslatableMessage("event.script.contextPointDisabled", contextEntry.getVariableName(), contextEntry.getDataPointId()));
        }
        converted.put(contextEntry.getVariableName(), point);
    }
    return converted;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) HashMap(java.util.HashMap) IDataPointValueSource(com.serotonin.m2m2.rt.dataImage.IDataPointValueSource) DataPointRT(com.serotonin.m2m2.rt.dataImage.DataPointRT) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage)

Example 57 with DataPointRT

use of com.serotonin.m2m2.rt.dataImage.DataPointRT in project ma-core-public by infiniteautomation.

the class DataPointTagsDao method saveDataPointTags.

/**
 * Only to be used when saving data point tags independently from the DataPointVO itself.
 * The DataPointVO tags must not be null.
 *
 * @param dataPoint
 */
public void saveDataPointTags(DataPointVO dataPoint) {
    Map<String, String> tags = dataPoint.getTags();
    if (tags == null)
        throw new IllegalArgumentException("Data point tags cannot be null");
    this.doInTransaction(txStatus -> {
        this.deleteTagsForDataPointId(dataPoint.getId());
        this.insertTagsForDataPoint(dataPoint, tags);
        DataPointRT rt = Common.runtimeManager.getDataPoint(dataPoint.getId());
        if (rt != null) {
            DataPointVO rtVo = rt.getVO();
            rtVo.setTags(tags);
        }
        DataPointDao.instance.notifyTagsUpdated(dataPoint);
    });
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointRT(com.serotonin.m2m2.rt.dataImage.DataPointRT)

Aggregations

DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)47 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)28 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)23 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)19 HashMap (java.util.HashMap)12 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)11 IDataPointValueSource (com.serotonin.m2m2.rt.dataImage.IDataPointValueSource)9 IOException (java.io.IOException)8 ResultTypeException (com.serotonin.m2m2.rt.script.ResultTypeException)7 ArrayList (java.util.ArrayList)7 ScriptException (javax.script.ScriptException)7 ScriptLog (com.serotonin.m2m2.rt.script.ScriptLog)6 ScriptPermissionsException (com.serotonin.m2m2.rt.script.ScriptPermissionsException)5 SerialPortException (com.infiniteautomation.mango.io.serial.SerialPortException)4 SerialPointLocatorVO (com.infiniteautomation.serial.vo.SerialPointLocatorVO)4 AnnotatedPointValueTime (com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime)4 DataPointListener (com.serotonin.m2m2.rt.dataImage.DataPointListener)4 DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)4 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)4 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)4