use of com.serotonin.m2m2.virtual.vo.VirtualDataSourceVO in project ma-modules-public by infiniteautomation.
the class VirtualEditDwr method saveVirtualDataSource.
@DwrPermission(user = true)
public ProcessResult saveVirtualDataSource(BasicDataSourceVO basic, int updatePeriods, int updatePeriodType, boolean polling) {
VirtualDataSourceVO ds = (VirtualDataSourceVO) Common.getUser().getEditDataSource();
setBasicProps(ds, basic);
ds.setUpdatePeriods(updatePeriods);
ds.setUpdatePeriodType(updatePeriodType);
ds.setPolling(polling);
return tryDataSourceSave(ds);
}
use of com.serotonin.m2m2.virtual.vo.VirtualDataSourceVO in project ma-modules-public by infiniteautomation.
the class VirtualEditDwr method createTestSource.
/**
* Test Method for debugging system.
*/
@DwrPermission(admin = true)
public void createTestSource() {
VirtualDataSourceVO ds = new VirtualDataSourceVO();
DataSourceDefinition def = ModuleRegistry.getDataSourceDefinition("VIRTUAL");
ds = (VirtualDataSourceVO) def.baseCreateDataSourceVO();
ds.setId(Common.NEW_ID);
ds.setXid(DataSourceDao.instance.generateUniqueXid());
ds.setName("Test Virtual");
ds.setEnabled(true);
ds.setUpdatePeriods(5);
ds.setUpdatePeriodType(TimePeriods.SECONDS);
ds.setPolling(true);
ProcessResult response = new ProcessResult();
ds.validate(response);
if (!response.getHasMessages())
Common.runtimeManager.saveDataSource(ds);
else
throw new RuntimeException("Invalid data!");
DataPointDao dpDao = DataPointDao.instance;
// Create Test Points
for (int i = 0; i < 10; i++) {
VirtualPointLocatorVO pointLocator = ds.createPointLocator();
// Create a Random Points
pointLocator.setDataTypeId(DataTypes.NUMERIC);
pointLocator.setChangeTypeId(ChangeTypeVO.Types.RANDOM_ANALOG);
pointLocator.getRandomAnalogChange().setMin(0);
pointLocator.getRandomAnalogChange().setMax(100);
pointLocator.getRandomAnalogChange().setStartValue("1");
pointLocator.setSettable(true);
DataPointVO dp = new DataPointVO();
dp.setXid(dpDao.generateUniqueXid());
dp.setName("Virtual Random " + i);
dp.setDataSourceId(ds.getId());
dp.setDataSourceTypeName(ds.getDefinition().getDataSourceTypeName());
dp.setDeviceName(ds.getName());
dp.setEventDetectors(new ArrayList<AbstractPointEventDetectorVO<?>>(0));
dp.defaultTextRenderer();
// Setup the Chart Renderer
ImageChartRenderer chartRenderer = new ImageChartRenderer(TimePeriods.DAYS, 5);
dp.setChartRenderer(chartRenderer);
dp.setPointLocator(pointLocator);
dp.setEnabled(true);
dp.setSettable(true);
dp.setDefaultCacheSize(0);
dp.validate(response);
if (!response.getHasMessages())
Common.runtimeManager.saveDataPoint(dp);
else
throw new RuntimeException("Invalid data!");
}
}
Aggregations