perf: 全量订阅,局部更新给服务端

dev
huangfeng 8 months ago
parent 318f9c8aa2
commit b7b76af5b6

@ -12,7 +12,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Optional;
@Slf4j @Slf4j
public class IecClient implements ClientEventListener { public class IecClient implements ClientEventListener {
@ -20,7 +19,6 @@ public class IecClient implements ClientEventListener {
ClientSap clientSap = new ClientSap(); ClientSap clientSap = new ClientSap();
ClientAssociation clientAssociation = null; ClientAssociation clientAssociation = null;
ServerModel serverModel; ServerModel serverModel;
Urcb urcb = null;
public void connect(String host, int port, String apTitle, String xml) throws Exception { public void connect(String host, int port, String apTitle, String xml) throws Exception {
InputStream in = IOUtils.toInputStream(xml, StandardCharsets.UTF_8); InputStream in = IOUtils.toInputStream(xml, StandardCharsets.UTF_8);
@ -66,16 +64,18 @@ public class IecClient implements ClientEventListener {
public void enableReporting() throws Exception { public void enableReporting() throws Exception {
if (!CollectionUtils.isEmpty(serverModel.getUrcbs())) { if (!CollectionUtils.isEmpty(serverModel.getUrcbs())) {
Optional<Urcb> optional = serverModel.getUrcbs().stream().findAny(); for (Urcb urcb : serverModel.getUrcbs()) {
urcb = optional.get(); clientAssociation.enableReporting(urcb);
clientAssociation.enableReporting(urcb); }
} }
} }
public void disableReporting() { public void disableReporting() {
if (urcb != null) { if (!CollectionUtils.isEmpty(serverModel.getUrcbs())) {
try { try {
clientAssociation.disableReporting(urcb); for (Urcb urcb : serverModel.getUrcbs()) {
clientAssociation.disableReporting(urcb);
}
} catch (Exception ignore) { } catch (Exception ignore) {
} }
} }

@ -38,10 +38,12 @@ public class IecServer implements ServerEventListener {
public void updateBda(BasicDataAttribute bda) { public void updateBda(BasicDataAttribute bda) {
BasicDataAttribute node = (BasicDataAttribute) serversServerModel.findModelNode(bda.getReference(), bda.getFc()); BasicDataAttribute node = (BasicDataAttribute) serversServerModel.findModelNode(bda.getReference(), bda.getFc());
node.setValueFrom(bda); if (node != null) {
List<BasicDataAttribute> bdas = new ArrayList<>(); node.setValueFrom(bda);
bdas.add(node); List<BasicDataAttribute> bdas = new ArrayList<>();
serverSap.setValues(bdas); bdas.add(node);
serverSap.setValues(bdas);
}
} }
@Override @Override

@ -45,9 +45,10 @@ public class RealTimeServiceImpl implements RealTimeService {
IecClient iecClient = new IecClient(); IecClient iecClient = new IecClient();
iecClient.connect(ied.getIp(), 102, ied.getApTitle(), icdFile.getXml()); iecClient.connect(ied.getIp(), 102, ied.getApTitle(), icdFile.getXml());
iecClient.enableReporting(); iecClient.enableReporting();
log.info("61850订阅成功, ied=" + ied.getName() + ", ip=" + ied.getIp());
clientMap.put(ied.getIp(), iecClient); clientMap.put(ied.getIp(), iecClient);
} catch (Exception ex) { } catch (Exception ex) {
log.error("61850连接异常, ied=" + ied.getName() + ", ip=" + ied.getIp(), ex); log.error("61850订阅异常, ied=" + ied.getName() + ", ip=" + ied.getIp(), ex);
} }
} }
} }

Loading…
Cancel
Save