use of net.sf.mbus4j.dataframes.MBusResponseFramesContainer in project ma-modules-public by infiniteautomation.
the class MBusDiscovery method addUpdateInfo.
public void addUpdateInfo(Map<String, Object> result) {
LOG.info("addUpdateInfo()");
autoShutOff.update();
Set<MBusDeviceBean> found = new HashSet<MBusDeviceBean>();
int deviceCount = master.deviceCount();
for (int i = 0; i < deviceCount; i++) {
MBusResponseFramesContainer dev = master.getDevice(i);
// Only keep newly found devices, unique set
MBusDeviceBean device = new MBusDeviceBean(i, dev);
if (foundDevices.add(device))
found.add(device);
}
result.put("devices", found);
result.put("message", message);
result.put("finished", finished);
}
use of net.sf.mbus4j.dataframes.MBusResponseFramesContainer in project ma-modules-public by infiniteautomation.
the class MBusDiscovery method getDeviceDetails.
public void getDeviceDetails(int deviceIndex, Map<String, Object> result) {
LOG.info("getDeviceDetails()");
MBusResponseFramesContainer dev = master.getDevice(deviceIndex);
result.put("deviceName", String.format("%s %s 0x%02X %08d @0x%02X", dev.getManufacturer(), dev.getMedium(), dev.getVersion(), dev.getIdentNumber(), dev.getAddress()));
result.put("deviceIndex", deviceIndex);
MBusResponseFrameBean[] responseFrames = new MBusResponseFrameBean[dev.getResponseFrameContainerCount()];
for (int i = 0; i < dev.getResponseFrameContainerCount(); i++) {
responseFrames[i] = new MBusResponseFrameBean(dev.getResponseFrameContainer(i).getResponseFrame(), deviceIndex, i, dev.getResponseFrameContainer(i).getName());
}
result.put("responseFrames", responseFrames);
}
use of net.sf.mbus4j.dataframes.MBusResponseFramesContainer in project ma-modules-public by infiniteautomation.
the class MBusEditDwr method addMBusPoint.
@DwrPermission(user = true)
public DataPointVO addMBusPoint(int deviceIndex, int rsIndex, int dbIndex) {
DataPointVO dp = getPoint(Common.NEW_ID, null);
MBusPointLocatorVO locator = (MBusPointLocatorVO) dp.getPointLocator();
MBusDiscovery test = Common.getUser().getTestingUtility(MBusDiscovery.class);
if (test == null) {
return null;
}
MBusResponseFramesContainer dev = test.getDevice(deviceIndex);
if (dev.getResponseFrameContainer(rsIndex).getResponseFrame() instanceof UserDataResponse) {
UserDataResponse udr = (UserDataResponse) dev.getResponseFrameContainer(rsIndex).getResponseFrame();
DataBlock db = udr.getDataBlock(dbIndex);
dp.setName(db.getParamDescr());
locator.setDbIndex(dbIndex);
locator.setAddressing(MBusAddressing.PRIMARY);
locator.setAddress(dev.getAddress());
locator.setMedium(dev.getMedium());
locator.setManufacturer(dev.getManufacturer());
locator.setVersion(dev.getVersion());
locator.setIdentNumber(dev.getIdentNumber());
locator.setResponseFrame(dev.getResponseFrameContainer(rsIndex).getName());
locator.setSubUnit(db.getSubUnit());
locator.setDifCode(db.getDataFieldCode().getLabel());
locator.setFunctionField(db.getFunctionField().getLabel());
locator.setStorageNumber(db.getStorageNumber());
locator.setTariff(db.getTariff());
locator.setSiPrefix(db.getSiPrefix().getLabel());
locator.setEffectiveSiPrefix(locator.getSiPrefix());
locator.setUnitOfMeasurement(db.getUnitOfMeasurement() != null ? db.getUnitOfMeasurement().getLabel() : null);
locator.setVifType(db.getVif().getVifType().getLabel());
locator.setVifLabel(db.getVif().getLabel());
locator.setExponent(db.getExponent());
if (db.getVifes() != null) {
final String[] vifeLabels = new String[db.getVifes().length];
final String[] vifeTypes = new String[db.getVifes().length];
for (int i = 0; i < vifeLabels.length; i++) {
vifeTypes[i] = db.getVifes()[i].getVifeType().getLabel();
vifeLabels[i] = db.getVifes()[i].getLabel();
}
locator.setVifeTypes(vifeTypes);
locator.setVifeLabels(vifeLabels);
} else {
locator.setVifeLabels(null);
}
}
return dp;
}
Aggregations