private void btnUploadConfig_Click(object sender, EventArgs e) { if (_edgeAgent == null) { return; } EdgeConfig config = new EdgeConfig(); for (int i = 1; i <= numDeviceCount.Value; i++) { EdgeConfig.DeviceConfig device = new EdgeConfig.DeviceConfig() { Id = "Device" + i, Name = "Device" + i, Type = "Smart Device", Description = "Device " + i, }; for (int j = 1; j <= numATagCount.Value; j++) { EdgeConfig.AnalogTagConfig analogTag = new EdgeConfig.AnalogTagConfig() { Name = "ATag" + j, Description = "ATag " + j, ReadOnly = false, ArraySize = 0, SpanHigh = 1000, SpanLow = 0, EngineerUnit = string.Empty, FractionDisplayFormat = 2, SendWhenValueChanged = false }; device.AnalogTagList.Add(analogTag); } for (int j = 1; j <= numDTagCount.Value; j++) { EdgeConfig.DiscreteTagConfig discreteTag = new EdgeConfig.DiscreteTagConfig() { Name = "DTag" + j, Description = "DTag " + j, ReadOnly = false, ArraySize = 0, State0 = "0", State1 = "1", State2 = string.Empty, State3 = string.Empty, State4 = string.Empty, State5 = string.Empty, State6 = string.Empty, State7 = string.Empty, SendWhenValueChanged = false }; device.DiscreteTagList.Add(discreteTag); } for (int j = 1; j <= numTTagCount.Value; j++) { EdgeConfig.TextTagConfig textTag = new EdgeConfig.TextTagConfig() { Name = "TTag" + j, Description = "TTag " + j, ReadOnly = false, ArraySize = 0, SendWhenValueChanged = true }; device.TextTagList.Add(textTag); } config.Node.DeviceList.Add(device); } bool result = _edgeAgent.UploadConfig(ActionType.Create, config).Result; }
private void buttonUploadConfig_Click(object sender, EventArgs e) { if (_edgeAgent == null) { return; } EdgeConfig config = new EdgeConfig(); config.Scada = new EdgeConfig.ScadaConfig() { Id = textBoxGroupId.Text.Trim(), Description = "descrp", PortNumber = (int)numericUpDownPort.Value, HeartBeat = 60, BackupDeviceId = 0 }; config.Scada.AnalogTagList = new List <EdgeConfig.AnalogTagConfig> (); config.Scada.DiscreteTagList = new List <EdgeConfig.DiscreteTagConfig>(); config.Scada.TextTagList = new List <EdgeConfig.TextTagConfig>(); for (int j = 1; j <= numATagCount.Value; j++) { EdgeConfig.AnalogTagConfig analogTag = new EdgeConfig.AnalogTagConfig() { Name = "ATag" + j, Description = "ATag " + j, ReadOnly = false, ArraySize = 2, NeedLog = true, SpanHigh = 1000, SpanLow = 0, EngineerUnit = string.Empty, DisplayFormat = "4.2", AlarmEnable = false, HHPriority = 0, HHAlarmLimit = 0, HighPriority = 0, HighAlarmLimit = 0, LowPriority = 0, LowAlarmLimit = 0, LLPriority = 0, LLAlarmLimit = 0 }; config.Scada.AnalogTagList.Add(analogTag); } for (int j = 1; j <= numDTagCount.Value; j++) { EdgeConfig.DiscreteTagConfig discreteTag = new EdgeConfig.DiscreteTagConfig() { Name = "DTag" + j, Description = "DTag " + j, ReadOnly = false, ArraySize = 0, AlarmEnable = false, State0 = "0", State1 = "1", State2 = string.Empty, State3 = string.Empty, State4 = string.Empty, State5 = string.Empty, State6 = string.Empty, State7 = string.Empty, State0AlarmPriority = 0, State1AlarmPriority = 0, State2AlarmPriority = 0, State3AlarmPriority = 0, State4AlarmPriority = 0, State5AlarmPriority = 0, State6AlarmPriority = 0, State7AlarmPriority = 0 }; config.Scada.DiscreteTagList.Add(discreteTag); } for (int j = 1; j <= numTTagCount.Value; j++) { EdgeConfig.TextTagConfig textTag = new EdgeConfig.TextTagConfig() { Name = "TTag" + j, Description = "TTag " + j, ReadOnly = false, ArraySize = 2, }; config.Scada.TextTagList.Add(textTag); } bool result = _edgeAgent.UploadConfig(ActionType.Create, config).Result; }