| | |
| | | using LB_SmartVision.Forms.Pages.SettingPage; |
| | | using LB_SmartVision.Forms.Pages.UserManagementPage; |
| | | using LB_SmartVision.ProcessRun; |
| | | using LB_SmartVision.SQL; |
| | | using LB_SmartVision.Tool; |
| | | using LB_SmartVisionCommon; |
| | | using LB_SmartVisionLoginUI; |
| | |
| | | { |
| | | LogInfo("全局变量加载失败", LogInfoType.ERROR); |
| | | } |
| | | |
| | | GlobalVar.dicMotionControlData.Clear(); |
| | | if (LoadMotionControlDatas(GlobalVar.allMotionControlDataPath)) |
| | | { |
| | | LogInfo("运动控制参数加载成功", LogInfoType.PASS); |
| | | } |
| | | else |
| | | { |
| | | LogInfo("运动控制参数加载失败", LogInfoType.ERROR); |
| | | } |
| | | //加载流程 |
| | | GlobalVar.dicProcesses.Clear(); |
| | | if (LoadAllProcess(GlobalVar.allProcessConnectionStringPath)) |
| | |
| | | com_ProductName.Items.Add("新增"); |
| | | com_ProductName.Text = GlobalVar.strProductName; |
| | | this.WindowState = FormWindowState.Maximized; |
| | | DatabaseRecordProductDataHelper.InitializeDatabase(); |
| | | } |
| | | |
| | | public void SaveAllSetting() |
| | |
| | | SaveAllProcessSetting(); |
| | | SaveAllLayout(); |
| | | SaveAllCsv(); |
| | | SaveMotionControlDatas(); |
| | | } |
| | | public bool LoadMotionControlDatas(string alMotionControlDataPath) |
| | | { |
| | | try |
| | | { |
| | | GlobalVar.dicMotionControlData = ConfigManager<ConcurrentDictionary<string, ConcurrentDictionary<string, RecordMotionControlData>>>.LoadConfig<ConcurrentDictionary<string, ConcurrentDictionary<string, RecordMotionControlData>>>(alMotionControlDataPath); |
| | | } |
| | | catch |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | public bool SaveMotionControlDatas() |
| | | { |
| | | try |
| | | { |
| | | ConcurrentDictionary<string, List<string>> removeCameraSN = new ConcurrentDictionary<string, List<string>>(); |
| | | foreach (var item in GlobalVar.dicMotionControlData.Keys) |
| | | { |
| | | List<string> list = new List<string>(); |
| | | foreach (var itemSN in GlobalVar.dicMotionControlData[item].Keys) |
| | | { |
| | | if (!GlobalVar.dicCameras.Keys.Contains(itemSN)) |
| | | { |
| | | list.Add(itemSN); |
| | | } |
| | | } |
| | | if (list.Count > 0) |
| | | { |
| | | removeCameraSN.TryAdd(item, list); |
| | | } |
| | | } |
| | | foreach (var item in removeCameraSN.Keys) |
| | | { |
| | | foreach (var itemSN in removeCameraSN[item]) |
| | | { |
| | | GlobalVar.dicMotionControlData[item].Keys.Remove(itemSN); |
| | | } |
| | | } |
| | | ConfigManager<ConcurrentDictionary<string, ConcurrentDictionary<string, RecordMotionControlData>>>.SaveConfig<ConcurrentDictionary<string, ConcurrentDictionary<string, RecordMotionControlData>>>(GlobalVar.dicMotionControlData, GlobalVar.allMotionControlDataPath); |
| | | } |
| | | catch |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public bool LoadAllCameras(string allCamerasConnectionStringPath) |
| | |
| | | string ClassName = match.Groups["ClassName"].Value; // "TCP" |
| | | string IP = match.Groups["IP"].Value; // "127.0.0.1" |
| | | string Slot = match.Groups["Slot"].Value; // "1111" |
| | | string CpuType= match.Groups["CpuType"].Value; |
| | | string CpuType = match.Groups["CpuType"].Value; |
| | | string PlcAddress = match.Groups["PlcAddress"].Value; |
| | | string DataType = match.Groups["DataType"].Success ? match.Groups["DataType"].Value : "String"; |
| | | |
| | |
| | | { |
| | | string strJson = string.Empty; |
| | | GlobalVar.allCommunicatorsConnectionString = new ConcurrentDictionary<string, string>(); |
| | | |
| | | foreach (var item in GlobalVar.dicCommunicators) |
| | | { |
| | | string ClassName = item.Value.GetType().FullName;// "TCP" |
| | |
| | | string CommunicatorConnectionString = $"({ClassName})[{IP}][{PORT}]"; |
| | | GlobalVar.allCommunicatorsConnectionString.TryAdd(item.Key, CommunicatorConnectionString); |
| | | } |
| | | GlobalVar.dicCommunicators[item.Key].ClassName = ClassName; |
| | | } |
| | | var settings = new JsonSerializerSettings |
| | | { |
| | |
| | | { } |
| | | } |
| | | File.WriteAllText(GlobalVar.allCommunicatorsConnectionStringPath, strJson, Encoding.UTF8); |
| | | foreach (var item in GlobalVar.dicCommunicators) |
| | | { |
| | | string ClassName = item.Value.GetType().FullName;// "TCP" |
| | | } |
| | | ConfigManager<ObservableConcurrentDictionary<string, BaseCommunicator>>.SaveConfig<ObservableConcurrentDictionary<string, BaseCommunicator>>(GlobalVar.dicCommunicators, GlobalVar.strApplicationPath + "\\所有产品\\" + GlobalVar.strProductName + "\\dicCommunicators.json"); |
| | | return true; |
| | | } |
| | | catch { return false; } |
| | |
| | | GlobalVar.strProductName = com_ProductName.SelectedItem?.ToString(); |
| | | foreach (BaseCamera camera in GlobalVar.dicCameras.Values) |
| | | { |
| | | camera.TriggerRunMessageReceived -= TriggerRunMessageReceived; |
| | | camera.Dispose(); |
| | | } |
| | | GlobalVar.dicCameras.Clear(); |