| | |
| | | } |
| | | this.cmbSN.Items.Clear(); |
| | | this.cmbSN.Items.Add(strCameraSN); |
| | | this.cmbSN.SelectedIndex = 0; |
| | | onlinePictureBox = new UserPictureBox(uiGroupBoxImage); |
| | | this.uiGroupBoxImage.Controls.Clear(); |
| | | this.uiGroupBoxImage.Controls.Add(onlinePictureBox); |
| | |
| | | |
| | | private void btnAdd_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | using (var configForm = new ConfigForm(config, GlobalVar.allPlcSettingPath + "\\" + this.Name + ".json")) |
| | | config.CommunicatorsName = GlobalVar.currentCommunicators; |
| | | config.ProductName = GlobalVar.strProductName; |
| | | using (var configForm = new ConfigForm(config, GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json")) |
| | | { |
| | | if (configForm.ShowDialog() == DialogResult.OK) |
| | | { |
| | | config = S7ConfigService.LoadConfig(GlobalVar.allPlcSettingPath); |
| | | config = S7ConfigService.LoadConfig(GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json"); |
| | | LoadConfigAndSetupGrid(); |
| | | UpdateConnectionStatus(); |
| | | } |
| | |
| | | } |
| | | private void LoadConfigAndSetupGrid() |
| | | { |
| | | config = S7ConfigService.LoadConfig(GlobalVar.allPlcSettingPath + "\\" + this.Name + ".json"); |
| | | config = S7ConfigService.LoadConfig(GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json"); |
| | | |
| | | if (GlobalVar.allPlcSettings.Keys.Contains(Name)) |
| | | { |
| | |
| | | { |
| | | GlobalVar.allPlcSettings.TryAdd(Name, config); |
| | | } |
| | | ConfigManager<Dictionary<string, Dictionary<string, PlcConfig>>>.SaveConfig<Dictionary<string, Dictionary<string, PlcConfig>>>(GlobalVar.dicMPlcData, GlobalVar.allMPlcDataPath); |
| | | // 构建 DataTable 用于展示信号(支持编辑值列) |
| | | signalTable = new DataTable(); |
| | | signalTable.Columns.Add("SignalName", typeof(string)); |
| | |
| | | |
| | | private void btnSave_Click(object sender, EventArgs e) |
| | | { |
| | | LoadConfigAndSetupGrid(); |
| | | S7ConfigService.SaveConfig(config, GlobalVar.allMPlcDataPath + "\\" + this.cameraSN + ".json"); |
| | | if (GlobalVar.dicMPlcDatas.ContainsKey(config.ProductName)) |
| | | { |
| | | if (GlobalVar.dicMPlcDatas[config.ProductName].ContainsKey(this.cameraSN)) |
| | | { |
| | | GlobalVar.dicMPlcDatas[config.ProductName][this.cameraSN] = config; |
| | | } |
| | | else |
| | | { |
| | | GlobalVar.dicMPlcDatas[config.ProductName].TryAdd(this.cameraSN, config); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Dictionary<string, PlcConfig> keyValuePairs = new Dictionary<string, PlcConfig>(); |
| | | keyValuePairs.TryAdd(this.cameraSN, config); |
| | | GlobalVar.dicMPlcDatas.TryAdd(config.ProductName, keyValuePairs); |
| | | } |
| | | ConfigManager<Dictionary<string, Dictionary<string, PlcConfig>>>.SaveConfig<Dictionary<string, Dictionary<string, PlcConfig>>>(GlobalVar.dicMPlcDatas, GlobalVar.allMPlcDatasPath); |
| | | GlobalVar.dicMPlcDatas = ConfigManager<Dictionary<string, Dictionary<string, PlcConfig>>>.LoadConfig<Dictionary<string, Dictionary<string, PlcConfig>>>(GlobalVar.allMPlcDatasPath); |
| | | //LoadConfigAndSetupGrid(); |
| | | } |
| | | } |
| | | } |