Search in sources :

Example 11 with DataSourceRT

use of com.serotonin.m2m2.rt.dataSource.DataSourceRT in project ma-core-public by infiniteautomation.

the class RuntimeManagerScriptUtility method refreshDataPoint.

/**
 * Refresh a data point with the given XID.
 *
 * @param xid
 * @return status of operation
 * 0 - Point not enabled
 * -1 - Point does not exist
 * 1 - Refresh performed
 */
public int refreshDataPoint(String xid) {
    DataPointVO vo = DataPointDao.instance.getByXid(xid);
    if (vo != null) {
        if (!vo.isEnabled())
            return OPERATION_NO_CHANGE;
        DataSourceRT<?> dsRt = Common.runtimeManager.getRunningDataSource(vo.getDataSourceId());
        if (dsRt == null || !Permissions.hasDataSourcePermission(permissions.getDataSourcePermissions(), dsRt.getVo()))
            return OPERATION_NO_CHANGE;
        Common.runtimeManager.forcePointRead(vo.getId());
        return OPERATION_SUCCESSFUL;
    } else
        return DOES_NOT_EXIST;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO)

Aggregations

DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)6 ArrayList (java.util.ArrayList)4 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)3 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)3 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)3 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)3 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)3 DataSourceRT (com.serotonin.m2m2.rt.dataSource.DataSourceRT)2 PollingDataSource (com.serotonin.m2m2.rt.dataSource.PollingDataSource)2 GenericRestException (com.infiniteautomation.mango.rest.v2.exception.GenericRestException)1 NotFoundRestException (com.infiniteautomation.mango.rest.v2.exception.NotFoundRestException)1 LongLongPair (com.serotonin.db.pair.LongLongPair)1 StringStringPair (com.serotonin.db.pair.StringStringPair)1 EnhancedPointValueDao (com.serotonin.m2m2.db.dao.EnhancedPointValueDao)1 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)1 DataPointListener (com.serotonin.m2m2.rt.dataImage.DataPointListener)1 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1