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!!!")); }
void createVL(NodeVL vl, LogicalNode ln) { IEC61850.Server.DataSet dataSet = new IEC61850.Server.DataSet(vl.Name, ln); vl.SCLServerModelObject = dataSet; foreach (NodeVLM vlm in vl.GetChildNodes()) { DataSetEntry dse = new DataSetEntry(dataSet, vlm.SCL_ServerLink, -1, null); vlm.SCLServerModelObject = dse; } }