use of org.openmuc.framework.driver.iec60870.settings.ChannelAddress in project OpenMUC by isc-konstanz.
the class Iec60870Connection method write.
@Override
public Object write(List<ChannelValueContainer> containers, Object containerListHandle) throws ConnectionException {
for (ChannelValueContainer channelValueContainer : containers) {
ChannelAddress channelAddress;
try {
channelAddress = new ChannelAddress(channelValueContainer.getChannelAddress());
Record record = new Record(channelValueContainer.getValue(), System.currentTimeMillis(), Flag.VALID);
Iec60870DataHandling.writeSingleCommand(record, channelAddress, clientConnection);
channelValueContainer.setFlag(Flag.VALID);
} catch (ArgumentSyntaxException e) {
channelValueContainer.setFlag(Flag.DRIVER_ERROR_CHANNEL_ADDRESS_SYNTAX_INVALID);
logger.error(e.getMessage());
throw new UnsupportedOperationException(e);
} catch (IOException e) {
channelValueContainer.setFlag(Flag.CONNECTION_EXCEPTION);
throw new ConnectionException(e);
} catch (TypeConversionException e) {
channelValueContainer.setFlag(Flag.DRIVER_ERROR_CHANNEL_VALUE_TYPE_CONVERSION_EXCEPTION);
logger.error(e.getMessage());
} catch (UnsupportedOperationException e) {
channelValueContainer.setFlag(Flag.DRIVER_ERROR_CHANNEL_ADDRESS_SYNTAX_INVALID);
logger.error(e.getMessage());
throw e;
}
}
return null;
}
use of org.openmuc.framework.driver.iec60870.settings.ChannelAddress in project OpenMUC by isc-konstanz.
the class Iec60870ReadListener method newASdu.
@Override
public synchronized void newASdu(ASdu aSdu) {
logger.debug("Got new ASdu");
if (logger.isTraceEnabled()) {
logger.trace(aSdu.toString());
}
long timestamp = System.currentTimeMillis();
if (!aSdu.isTestFrame()) {
Set<String> keySet = channelAddressMap.keySet();
Iterator<String> iterator = keySet.iterator();
while (iterator.hasNext()) {
String channelId = iterator.next();
ChannelAddress channelAddress = channelAddressMap.get(channelId);
if (aSdu.getCommonAddress() == channelAddress.commonAddress() && aSdu.getTypeIdentification().getId() == channelAddress.typeId()) {
processRecords(aSdu, timestamp, channelId, channelAddress);
}
}
isReadyReading = true;
}
}
use of org.openmuc.framework.driver.iec60870.settings.ChannelAddress in project OpenMUC by isc-konstanz.
the class Iec60870ReadListener method setContainer.
synchronized void setContainer(List<ChannelRecordContainer> containers) {
this.containers = containers;
Iterator<ChannelRecordContainer> containerIterator = containers.iterator();
while (containerIterator.hasNext()) {
ChannelRecordContainer channelRecordContainer = containerIterator.next();
try {
ChannelAddress channelAddress = new ChannelAddress(channelRecordContainer.getChannelAddress());
channelAddressMap.put(channelRecordContainer.getChannel().getId(), channelAddress);
} catch (ArgumentSyntaxException e) {
logger.error("ChannelId: " + channelRecordContainer.getChannel().getId() + "; Message: " + e.getMessage());
}
}
}
use of org.openmuc.framework.driver.iec60870.settings.ChannelAddress in project OpenMUC by isc-konstanz.
the class Iec60870Listener method newASdu.
@Override
public synchronized void newASdu(ASdu aSdu) {
logger.debug("Got new ASdu");
if (logger.isTraceEnabled()) {
logger.trace(aSdu.toString());
}
if (listener != null) {
long timestamp = System.currentTimeMillis();
if (!aSdu.isTestFrame()) {
Iterator<ChannelAddress> channelAddressIterator = channelAddresses.iterator();
int i = 0;
while (channelAddressIterator.hasNext()) {
ChannelAddress channelAddress = channelAddressIterator.next();
if (aSdu.getCommonAddress() == channelAddress.commonAddress() && aSdu.getTypeIdentification().getId() == channelAddress.typeId()) {
processRecords(aSdu, timestamp, i, channelAddress);
}
++i;
}
}
} else {
logger.warn("Listener object is null.");
}
}
use of org.openmuc.framework.driver.iec60870.settings.ChannelAddress in project OpenMUC by isc-konstanz.
the class Iec60870Listener method registerOpenMucListener.
public synchronized void registerOpenMucListener(List<ChannelRecordContainer> containers, RecordsReceivedListener listener, String driverId, Connection connection) throws ConnectionException {
this.containers = containers;
this.listener = listener;
this.driverId = driverId;
this.connection = connection;
Iterator<ChannelRecordContainer> containerIterator = containers.iterator();
while (containerIterator.hasNext()) {
ChannelRecordContainer channelRecordContainer = containerIterator.next();
try {
ChannelAddress channelAddress = new ChannelAddress(channelRecordContainer.getChannelAddress());
channelAddresses.add(channelAddress);
} catch (ArgumentSyntaxException e) {
logger.error("ChannelId: " + channelRecordContainer.getChannel().getId() + "; Message: " + e.getMessage());
}
}
}
Aggregations