Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3035 Import all informations from the Bacnet Object list #3079

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/dwr.xml
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@
<convert converter="bean" match="com.serotonin.mango.vo.publish.persistent.*"/>
<convert converter="bean" match="com.serotonin.mango.vo.report.*"/>
<convert converter="xssDataPointVoConverter" match="com.serotonin.mango.vo.DataPointVO">
<param name="include" value="id,xid,name,extendedName,dataSourceId,enabled,dataTypeMessage,pointLocator"/>
<param name="include" value="id,xid,name,extendedName,dataSourceId,enabled,dataTypeMessage,pointLocator,engineeringUnits"/>
</convert>
<convert converter="xssDataPointBeanConverter" match="com.serotonin.mango.web.dwr.beans.DataPointBean">
<param name="include" value="id,xid,name,settable,dataType,dataTypeMessage,chartColour"/>
3 changes: 2 additions & 1 deletion WebContent/WEB-INF/jsp/dataSourceEdit/editBacnetIp.jsp
Original file line number Diff line number Diff line change
@@ -221,8 +221,9 @@
locator.settable = $get("settable");
locator.writePriority = $get("writePriority");
locator.dataTypeId = $get("dataTypeId");
console.log("point.engineeringUnits: " + currentPoint.engineeringUnits);

DataSourceEditDwr.saveBACnetIPPointLocator(currentPoint.id, $get("xid"), $get("name"), locator, savePointCB);
DataSourceEditDwr.saveBACnetIPPointLocator(currentPoint.id, $get("xid"), $get("name"), currentPoint.engineeringUnits, locator, savePointCB);
}

function objectTypeChanged() {
Original file line number Diff line number Diff line change
@@ -121,7 +121,7 @@ public BACnetIPDataSourceVO() {
// Create a local device object from which to get default values.
LocalDevice localDevice = new LocalDevice(0, null);
broadcastAddress = "255.255.255.255";
port = localDevice.getPort();
port = 0;
timeout = localDevice.getTimeout();
segTimeout = localDevice.getSegTimeout();
segWindow = localDevice.getSegWindow();
53 changes: 34 additions & 19 deletions src/com/serotonin/mango/web/dwr/DataSourceEditDwr.java
Original file line number Diff line number Diff line change
@@ -339,28 +339,13 @@ private DataPointVO getPoint(int pointId, DataPointDefaulter defaulter) {
private DwrResponseI18n validatePoint(int id, String xid, String name,
PointLocatorVO locator, DataPointDefaulter defaulter) {
Permissions.ensureAdmin();
DwrResponseI18n response = new DwrResponseI18n();

DataPointVO dp = getPoint(id, defaulter);
dp.setXid(xid);
dp.setName(name);
dp.setPointLocator(locator);

DataPointService dataPointService = new DataPointService();
validateXid(response, dataPointService::isXidUnique, xid, id);

if (StringUtils.isEmpty(name))
response.addContextualMessage("name", "dsEdit.validate.required");

locator.validate(response, dp.getId());

if (!response.getHasMessages()) {
Common.ctx.getRuntimeManager().saveDataPoint(dp);
response.addData("id", dp.getId());
response.addData("points", getPoints());
}

return response;
return validateAndSaveDataPoint(dp);
}

//
@@ -1237,9 +1222,17 @@ public DwrResponseI18n saveBACnetIpDataSource(String name, String xid,
}


public DwrResponseI18n saveBACnetIPPointLocator(int id, String xid,
String name, BACnetIPPointLocatorVO locator) {
return validatePoint(id, xid, name, locator, null);
public DwrResponseI18n saveBACnetIPPointLocator(int id, String xid, String name, int engineeringUnits,
BACnetIPPointLocatorVO locator) {
Permissions.ensureAdmin();

DataPointVO dp = getPoint(id, null);
dp.setXid(xid);
dp.setName(name);
dp.setPointLocator(locator);
dp.setEngineeringUnits(engineeringUnits);

return validateAndSaveDataPoint(dp);
}


@@ -1348,6 +1341,7 @@ public DataPointVO addBacnetPoint(String ip, int port, int networkNumber,
BACnetIPPointLocatorVO locator = dp.getPointLocator();

dp.setName(bean.getObjectName());
dp.setEngineeringUnits(bean.getEngineeringUnitValue());

// Default some of the locator values.
locator.setRemoteDeviceIp(ip);
@@ -3115,4 +3109,25 @@ private DwrResponseI18n validateMultipleOpcUaPoints(OpcUaPointLocatorVO[] locato
}
return response;
}

public DwrResponseI18n validateAndSaveDataPoint(DataPointVO dp) {
Permissions.ensureAdmin();
DwrResponseI18n response = new DwrResponseI18n();
DataPointService dataPointService = new DataPointService();
validateXid(response, dataPointService::isXidUnique, dp.getXid(), dp.getId());

if (StringUtils.isEmpty(dp.getName()))
response.addContextualMessage("name", "dsEdit.validate.required");

PointLocatorVO locator = dp.getPointLocator();
locator.validate(response, dp.getId());

if (!response.getHasMessages()) {
Common.ctx.getRuntimeManager().saveDataPoint(dp);
response.addData("id", dp.getId());
response.addData("points", getPoints());
}

return response;
}
}
10 changes: 9 additions & 1 deletion src/com/serotonin/mango/web/dwr/beans/BACnetDiscovery.java
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.ResourceBundle;

import com.serotonin.bacnet4j.type.enumerated.EngineeringUnits;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@@ -281,8 +282,15 @@ else if (ObjectType.multiStateInput.equals(oid.getObjectType())
bean.setObjectName(values.getString(oid, pid));
else if (pid.equals(PropertyIdentifier.presentValue))
bean.setPresentValue(values.getString(oid, pid));
else if (pid.equals(PropertyIdentifier.units))
else if (pid.equals(PropertyIdentifier.units)) {
bean.getUnitsDescription().add(values.getString(oid, pid));

Encodable e = values.getNullOnError(oid, pid);
if (e instanceof EngineeringUnits) {
EngineeringUnits engineeringUnits = (EngineeringUnits) e;
bean.setEngineeringUnitValue(engineeringUnits.intValue());
}
}
else if (pid.equals(PropertyIdentifier.inactiveText)) {
Encodable e = values.getNullOnError(oid, pid);
bean.getUnitsDescription().set(0, e == null ? "0" : e.toString());
10 changes: 10 additions & 0 deletions src/com/serotonin/mango/web/dwr/beans/BACnetObjectBean.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,8 @@ public class BACnetObjectBean {
private int dataTypeId;
private List<String> unitsDescription = new ArrayList<String>();

private int engineeringUnitValue;

public String getPrettyPresentValue() {
if (objectTypeId == ObjectType.binaryInput.intValue() || objectTypeId == ObjectType.binaryOutput.intValue()
|| objectTypeId == ObjectType.binaryValue.intValue()) {
@@ -138,4 +140,12 @@ public boolean isCov() {
public void setCov(boolean cov) {
this.cov = cov;
}

public int getEngineeringUnitValue() {
return engineeringUnitValue;
}

public void setEngineeringUnitValue(int engineeringUnitValue) {
this.engineeringUnitValue = engineeringUnitValue;
}
}