Search in sources :

Example 1 with MBusResponseFramesContainer

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);
}
Also used : MBusResponseFramesContainer(net.sf.mbus4j.dataframes.MBusResponseFramesContainer) HashSet(java.util.HashSet)

Example 2 with MBusResponseFramesContainer

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);
}
Also used : MBusResponseFramesContainer(net.sf.mbus4j.dataframes.MBusResponseFramesContainer)

Example 3 with MBusResponseFramesContainer

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;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) UserDataResponse(net.sf.mbus4j.dataframes.UserDataResponse) MBusPointLocatorVO(com.serotonin.m2m2.mbus.MBusPointLocatorVO) MBusResponseFramesContainer(net.sf.mbus4j.dataframes.MBusResponseFramesContainer) DataBlock(net.sf.mbus4j.dataframes.datablocks.DataBlock) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

MBusResponseFramesContainer (net.sf.mbus4j.dataframes.MBusResponseFramesContainer)3 MBusPointLocatorVO (com.serotonin.m2m2.mbus.MBusPointLocatorVO)1 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)1 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1 HashSet (java.util.HashSet)1 UserDataResponse (net.sf.mbus4j.dataframes.UserDataResponse)1 DataBlock (net.sf.mbus4j.dataframes.datablocks.DataBlock)1