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

#2152 Can't activate more than 1 Bacnet IP datasource simultaneously #3045

Open
wants to merge 4 commits into
base: release/2.8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions WebContent/WEB-INF/dox/de/bacnetIpDS.htm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h1>Configuration</h1>
<p>Every data source requires a <b>Name</b>, which can be any description. The <b>Update period</b> determines how often the BACnet equipment is polled for data. Polling is only used if a desired object does not support COV subscriptions. The device is automatically queried for its supported services to make this determination.</p>
<p>The <b>Device ID</b> is the identifier that Mango will provide to other equipment in its IAm message. An IAm message is automatically sent upon startup of the data source to declare its presence to the network, and is also sent in response to appropriate WhoIs requests.</p>
<p>The <b>Broadcast address</b> is the IP address for broadcast messages. Your network administrator will provide you with an appropriate value to use. The <b>Port</b> is the port number upon which Mango will listen for incoming messages. Note that Mango supports situations where other equipment within the BACnet network listens on other ports, but broadcases messages will only be sent to the port number that Mango listens on.</p>
<p>By default, the port is set to <b>47808</b> (commonly represented as <b>0xBAC0</b>), which is the standard port for BACnet communication. However, in some cases, it may be necessary to set the port to <b>0</b>. Setting the port to <b>0</b> allows Mango to automatically detect the port used by devices in the network, which can be useful when the devices are configured to communicate on non-standard ports. This behavior can help resolve issues related to port mismatches in certain network configurations.</p>
<p>The <b>Timeout</b>, <b>Segment timeout</b>, <b>Segment window</b>, and <b>Retries</b> values are BACnet messaging attributes. In most cases the given default values should be appropriate. Consult the BACnet I/P documentation or your network administrator to determine if other values should be used for your network.</p>
<p>The <b>COV lease time</b> is the number of minutes that Mango will request to hold a COV lease. Mango will automatically attempt to refresh its COV subscriptions after half of the given time has elapsed. So, if the least time is 60 minutes, Mango will request the device honour the lease for 60 minutes, and will resubscribe after 30.</p>
<p>Where COV subscriptions are not available, polling at the given rate is used instead. Devices are polled individually. Devices that support ReadPropertyMultiple requests are sent this message, partitioned to contain no more than 200 properties in a single request if necessary. Otherwise, individual ReadProperty requests are sent.</p>
Expand Down
1 change: 1 addition & 0 deletions WebContent/WEB-INF/dox/en/bacnetIpDS.htm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ <h1>Configuration</h1>
<p>Every data source requires a <b>Name</b>, which can be any description. The <b>Update period</b> determines how often the BACnet equipment is polled for data. Polling is only used if a desired object does not support COV subscriptions. The device is automatically queried for its supported services to make this determination.</p>
<p>The <b>Device ID</b> is the identifier that Mango will provide to other equipment in its IAm message. An IAm message is automatically sent upon startup of the data source to declare its presence to the network, and is also sent in response to appropriate WhoIs requests.</p>
<p>The <b>Broadcast address</b> is the IP address for broadcast messages. Your network administrator will provide you with an appropriate value to use. The <b>Port</b> is the port number upon which Mango will listen for incoming messages. Note that Mango supports situations where other equipment within the BACnet network listens on other ports, but broadcases messages will only be sent to the port number that Mango listens on.</p>
<p>By default, the port is set to <b>47808</b> (commonly represented as <b>0xBAC0</b>), which is the standard port for BACnet communication. However, in some cases, it may be necessary to set the port to <b>0</b>. Setting the port to <b>0</b> allows Mango to automatically detect the port used by devices in the network, which can be useful when the devices are configured to communicate on non-standard ports. This behavior can help resolve issues related to port mismatches in certain network configurations.</p>
<p>The <b>Timeout</b>, <b>Segment timeout</b>, <b>Segment window</b>, and <b>Retries</b> values are BACnet messaging attributes. In most cases the given default values should be appropriate. Consult the BACnet I/P documentation or your network administrator to determine if other values should be used for your network.</p>
<p>The <b>COV lease time</b> is the number of minutes that Mango will request to hold a COV lease. Mango will automatically attempt to refresh its COV subscriptions after half of the given time has elapsed. So, if the least time is 60 minutes, Mango will request the device honour the lease for 60 minutes, and will resubscribe after 30.</p>
<p>Where COV subscriptions are not available, polling at the given rate is used instead. Devices are polled individually. Devices that support ReadPropertyMultiple requests are sent this message, partitioned to contain no more than 200 properties in a single request if necessary. Otherwise, individual ReadProperty requests are sent.</p>
Expand Down
2 changes: 2 additions & 0 deletions WebContent/WEB-INF/dox/es/bacnetIpDS.htm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ <h1>Visión general</h1>
<h1>Configuración</h1>
<p>Cada fuente de datos requiere un <b>Nombre</b>, que puede ser cualquier descripción. El <b>Período de Actualización</b> determina la frecuencia con la que el equipo de BACnet es encuestado para obtener datos. El sondeo sólo se usa si el objeto deseado no soporta suscripciones de COV. El dispositivo es consultado automáticamente por los servicios que soporta para hacer esta determinación.</p>
<p>El <b> ID del dispositivo </b> es el identificador que Mango proporcionará a otros dispositivos en su mensaje IAm. Se envía automáticamente un mensaje de IAm cuando la fuente de datos se pone en marcha para declarar su presencia en la red, y también se envía en respuesta a las solicitudes apropiadas del WhoIs.</p>
<p>La <b>dirección de difusión (Broadcast address)</b> es la dirección IP para los mensajes de difusión. Su administrador de red le proporcionará un valor adecuado para usar. El <b>Puerto</b> es el número de puerto en el que Mango escuchará los mensajes entrantes. Tenga en cuenta que Mango admite situaciones en las que otros equipos dentro de la red BACnet escuchan en otros puertos, pero los mensajes de difusión solo se enviarán al número de puerto en el que Mango escucha.</p>
<p>Por defecto, el puerto está configurado en <b>47808</b> (comúnmente representado como <b>0xBAC0</b>), que es el puerto estándar para la comunicación BACnet. Sin embargo, en algunos casos, puede ser necesario configurar el puerto en <b>0</b>. Configurar el puerto en <b>0</b> permite que Mango detecte automáticamente el puerto utilizado por los dispositivos en la red, lo cual puede ser útil cuando los dispositivos están configurados para comunicarse en puertos no estándar. Este comportamiento puede ayudar a resolver problemas relacionados con desajustes de puertos en ciertas configuraciones de red.</p>
<p>La <b>Dirección de emisión</b> es la dirección IP de los mensajes de emisión. El administrador de la red le proporcionará un valor apropiado para utilizarlo. El <b>Puerto</b> es el número de puerto en el que Mango escuchará los mensajes entrantes. Tengan en cuenta que Mango admite situaciones en las que otros equipos de la red BACnet están escuchando en otros puertos, pero los mensajes de difusión sólo se enviarán al número de puerto en el que Mango está escuchando.</p>
<p>Los valores <b>Tiempo de espera</b>, <b>Tempo de inactividade do segmento</b>, <b>Segmento de ventana</b>, y <b>Reintentos</b> son atributos de mensajería de BACnet. En la mayoría de los casos, los valores predeterminados dados deben ser apropiados. Consulte la documentación de BACnet I/P o su administrador de red para determinar si se deben utilizar otros valores para su red..</p>
<p>El <b>Tiempo de alquiler del COV</b> es el número de minutos que le tomará a Mango mantener un contrato de arrendamiento de VOC. Mango intentará renovar automáticamente sus suscripciones a los COV después de la mitad del tiempo dado. Por ejemplo, si el tiempo más corto es de 60 minutos, Mango pedirá al aparato que cumpla el contrato de arrendamiento durante 60 minutos, y se volverá a suscribir después de 30 minutos.</p>
Expand Down
3 changes: 3 additions & 0 deletions WebContent/WEB-INF/dox/fr/bacnetIpDS.htm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ <h1>Vue d'ensemble</h1>
<h1>Configuration</h1>
<p>Chaque source de données nécessite un <b>Nom</b>, qui peut être n'importe quelle description. La <b>période de mise à jour</b> détermine la fréquence à laquelle l'équipement BACnet est interrogé pour obtenir des données. L'interrogation n'est utilisée que si un objet souhaité ne prend pas en charge les abonnements COV. L'appareil est automatiquement interrogé sur les services qu'il prend en charge pour faire cette détermination.</p>
<p>Le <b>ID de l'appareil</b> est l'identifiant que Mango fournira aux autres équipements dans son message IAm. Un message IAm est automatiquement envoyé au démarrage de la source de données pour déclarer sa présence sur le réseau, et est également envoyé en réponse aux demandes WhoIs appropriées.</p>
<p>L'<b>adresse de diffusion (Broadcast address)</b> est l'adresse IP pour les messages de diffusion. Votre administrateur réseau vous fournira une valeur appropriée à utiliser. Le <b>port</b> est le numéro de port sur lequel Mango écoutera les messages entrants. Notez que Mango prend en charge les situations où d'autres équipements au sein du réseau BACnet écoutent sur d'autres ports, mais les messages de diffusion ne seront envoyés qu'au numéro de port sur lequel Mango écoute.</p>
<p>Par défaut, le port est réglé sur <b>47808</b> (souvent représenté sous la forme <b>0xBAC0</b>), qui est le port standard pour la communication BACnet. Cependant, dans certains cas, il peut être nécessaire de régler le port sur <b>0</b>. Régler le port sur <b>0</b> permet à Mango de détecter automatiquement le port utilisé par les appareils dans le réseau, ce qui peut être utile lorsque les appareils sont configurés pour communiquer sur des ports non standard. Ce comportement peut aider à résoudre les problèmes liés aux incompatibilités de ports dans certaines configurations de réseau.</p>

<p>Le <b>Adresse de diffusion</b> est l'adresse IP des messages diffusés. Votre administrateur réseau vous fournira une valeur appropriée à utiliser. Le <b>Port</b> est le numéro de port sur lequel Mango écoutera les messages entrants. Notez que Mango prend en charge les situations où d'autres équipements du réseau BACnet écoutent sur d'autres ports, mais les messages de diffusion ne seront envoyés qu'au numéro de port sur lequel Mango écoute.</p>
<p>Les valeurs <b>Timeout</b>, <b>Segment timeout</b>, <b>Segment window</b>, et <b>Retries</b> sont des attributs de messagerie BACnet. Dans la plupart des cas, les valeurs par défaut données devraient être appropriées. Consultez la documentation de BACnet I/P ou votre administrateur de réseau pour déterminer si d'autres valeurs doivent être utilisées pour votre réseau.</p>
<p>Le <b>COV lease time</b> est le nombre de minutes que Mango demandera pour détenir un COV lease. Mango tentera automatiquement de renouveler ses abonnements au COV après que la moitié du temps donné se soit écoulée. Ainsi, si le temps le plus court est de 60 minutes, Mango demandera au dispositif d'honorer la location pendant 60 minutes, et se réabonnera après 30.</p>
Expand Down
5 changes: 5 additions & 0 deletions WebContent/WEB-INF/jsp/dataSourceEdit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@
function toggleDataSourceCB(result) {
var imgNode = $("dsStatusImg");
stopImageFader(imgNode);

if (result.error) {
return;
}

setDataSourceStatusImg(result.enabled, imgNode);
getAlarms();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.serotonin.util.SerializationHelper;
import com.serotonin.web.dwr.DwrResponseI18n;
import com.serotonin.web.i18n.LocalizableMessage;
import org.scada_lts.mango.service.DataSourceService;

/**
* @author Matthew Lohbihler
Expand Down Expand Up @@ -248,6 +249,11 @@ public void validate(DwrResponseI18n response) {
response.addContextualMessage("broadcastAddress", "common.default", e.getMessage());
}

DataSourceService dataSourceService = new DataSourceService();
if(getPort()!=0 && dataSourceService.isBacNetDataSourcePortUsed(getId(), getPort())){
response.addContextualMessage("port", "Bacnet.invalid.port");
}

try {
new InetSocketAddress(broadcastAddress, port);
}
Expand Down
22 changes: 22 additions & 0 deletions src/org/scada_lts/dao/DAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
*/
package org.scada_lts.dao;

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

import javax.sql.DataSource;

import com.serotonin.mango.vo.dataSource.bacnet.BACnetIPDataSourceVO;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.scada_lts.web.beans.ApplicationBeans;
Expand Down Expand Up @@ -169,5 +173,23 @@ public boolean isTest() {
public void setTest(boolean test) {
this.test = test;
}

public boolean isBacNetDataSourcePortUsed(int excludeId, int port) {
String sql = "SELECT data FROM dataSources WHERE dataSourceType = 10 AND id <> ?";

List<byte[]> results = DAO.getInstance().getJdbcTemp().queryForList(sql, new Object[] { excludeId }, byte[].class);

for (byte[] data : results) {
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data))) {
BACnetIPDataSourceVO dataSource = (BACnetIPDataSourceVO) ois.readObject();
if (dataSource.getPort() == port) {
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}

}
4 changes: 4 additions & 0 deletions src/org/scada_lts/mango/service/DataSourceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,8 @@ private boolean toggleDataSource(DataSourceVO<?> vo) {
Common.ctx.getRuntimeManager().saveDataSource(vo);
return vo.isEnabled();
}

public boolean isBacNetDataSourcePortUsed(int excludeId, int port) {
return DAO.getInstance().isBacNetDataSourcePortUsed(excludeId, port);
}
}
3 changes: 2 additions & 1 deletion webapp-resources/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3365,4 +3365,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3368,4 +3368,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3408,4 +3408,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_fi.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3493,4 +3493,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3362,4 +3362,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_lu.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3381,4 +3381,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_nl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3483,4 +3483,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_pl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3505,4 +3505,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3520,4 +3520,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3516,4 +3516,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom Css has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
3 changes: 2 additions & 1 deletion webapp-resources/messages_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3468,4 +3468,5 @@ header.imageSets=Image sets
header.dynamicImages=Dynamic images
systemSettings.customCssSaved=Custom CSS has been saved
systemSettings.invalidCustomCss=Invalid custom CSS
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
systemsettings.reports.dataPointExtendedNameLengthLimit=Point name length limit in reports
Bacnet.invalid.port=Port already in use: cannot bind
Loading