void createModelNodes(NodeLN ln, LogicalDevice ldevice) { LogicalNode lnode = new LogicalNode(ln.Name, ldevice); ln.SCLServerModelObject = lnode; foreach (NodeBase nb in ln.GetChildNodes()) { if (nb is NodeDO) { createData(nb, lnode); } else if (nb is NodeRCB) { IEC61850.Common.ReportOptions rptOptions = (IEC61850.Common.ReportOptions)(nb.FindChildNode("OptFlds") as NodeData).DataValue; IEC61850.Common.TriggerOptions trgOptions = (IEC61850.Common.TriggerOptions)(nb.FindChildNode("TrgOps") as NodeData).DataValue; string rptId = (string)(nb.FindChildNode("RptID") as NodeData).DataValue; string datSet = (string)(nb.FindChildNode("DatSet") as NodeData).DataValue; uint confRev = (uint)(nb.FindChildNode("ConfRev") as NodeData).DataValue; uint bufTm = (uint)(nb.FindChildNode("BufTm") as NodeData).DataValue; uint intgPd = (uint)(nb.FindChildNode("IntgPd") as NodeData).DataValue; datSet = datSet == "" ? null : datSet; IEC61850.Server.ReportControlBlock rcb = new IEC61850.Server.ReportControlBlock(nb.Name, lnode, rptId, (nb as NodeRCB).isBuffered, datSet, confRev, trgOptions, rptOptions, bufTm, intgPd); nb.SCLServerModelObject = rcb; } } }
private void TestServer(object obj) { SCLServer self = (SCLServer)obj; IedModel model = new IedModel("bubak"); LogicalDevice ldevice1 = new LogicalDevice("strasidlo", model); LogicalNode lln0 = new LogicalNode("LLN0", ldevice1); DataObject lln0_mod = CDCFactory.CDC_ENG("Mod", lln0, CDCOptions.NONE); DataObject lln0_health = CDCFactory.CDC_ENG("Health", lln0, CDCOptions.NONE); SettingGroupControlBlock sgcb = new SettingGroupControlBlock(lln0, 1, 1); /* Add a temperature sensor LN */ LogicalNode ttmp1 = new LogicalNode("TTMP1", ldevice1); DataObject ttmp1_tmpsv = CDCFactory.CDC_SAV("TmpSv", ttmp1, 0, false); DataAttribute temperatureValue = ttmp1_tmpsv.GetChild_DataAttribute("instMag.f"); DataAttribute temperatureTimestamp = ttmp1_tmpsv.GetChild_DataAttribute("t"); IEC61850.Server.DataSet dataSet = new IEC61850.Server.DataSet("events", lln0); DataSetEntry dse = new DataSetEntry(dataSet, "TTMP1$MX$TmpSv$instMag$f", -1, null); IEC61850.Common.ReportOptions rptOptions = IEC61850.Common.ReportOptions.SEQ_NUM | IEC61850.Common.ReportOptions.TIME_STAMP | IEC61850.Common.ReportOptions.REASON_FOR_INCLUSION; IEC61850.Server.ReportControlBlock rcb1 = new IEC61850.Server.ReportControlBlock("events01", lln0, "events01", false, null, 1, IEC61850.Common.TriggerOptions.DATA_CHANGED, rptOptions, 50, 0); IEC61850.Server.ReportControlBlock rcb2 = new IEC61850.Server.ReportControlBlock("events02", lln0, "events02", true, null, 1, IEC61850.Common.TriggerOptions.DATA_CHANGED | IEC61850.Common.TriggerOptions.GI, rptOptions, 50, 0); IedServer server = new IedServer(model); server.Start(tcpPort); logger.LogInfo(String.Format("SCL Server Started at port 102!!!")); float val = 0.0f; while (_run) { server.LockDataModel(); temperatureValue.MmsValue.SetFloat(val); temperatureTimestamp.MmsValue.SetUtcTimeMs(Util.GetTimeInMs()); server.UnlockDataModel(); val += 0.1f; int waitres = WaitHandle.WaitAny(_waitHandles, 500); switch (waitres) { case 0: // endthread self._run = false; break; case WaitHandle.WaitTimeout: break; } } logger.LogInfo(String.Format("SCL Server Finished!!!")); }