| | |
| | | } |
| | | } |
| | | |
| | | public void CreateNewConfig(IProcessConfig config, string newProductionCode) |
| | | { |
| | | try |
| | | { |
| | | if (config == null) |
| | | throw new ProcessException("保存的配置信息不能为空"); |
| | | ProductionCode = newProductionCode; |
| | | //生成config.json |
| | | string newConfig = JsonConvert.SerializeObject(config, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }); |
| | | using (StreamWriter writer = new StreamWriter(_configPath, false, System.Text.Encoding.UTF8)) |
| | | { |
| | | writer.Write(newConfig); |
| | | writer.Flush(); |
| | | writer.Close(); |
| | | } |
| | | |
| | | //添加到Setting.json |
| | | SettingHelper.AddNewProductionCode(ProductionCode); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new ProcessException(ex.Message, null); |
| | | } |
| | | } |
| | | |
| | | private void SaveBackupConfig() |
| | | { |
| | | string backPath = Path.GetDirectoryName(_configPath); |
| | |
| | | #endregion |
| | | |
| | | #region IMonitor监听 |
| | | protected virtual void OnMonitorInvoke(DateTime dt, string deviceId, IDevice sourceDevice, MonitorSet monitorSet) |
| | | protected virtual void OnMonitorInvoke(DateTime dt, string deviceId, IDevice sourceDevice, IMonitorSet monitorSet) |
| | | { |
| | | string methodCode = monitorSet.MethodCode; |
| | | |
| | |
| | | #region 图像处理 |
| | | protected HImage CollectHImage(CameraBase camera, IOperationConfig opConfig, out string imgSetId, [CallerMemberName]string methodCode = "") |
| | | { |
| | | ImageSet set = null; |
| | | IImageSet set = null; |
| | | |
| | | if (IConfig.IsImageOffline) |
| | | { |
| | |
| | | TimeRecordCSV(DateTime.Now, camera.Name, methodCode + "采图", (int)sw.ElapsedMilliseconds); |
| | | } |
| | | |
| | | imgSetId = set.Id; |
| | | imgSetId = set?.Id; |
| | | return set.HImage; |
| | | } |
| | | |
| | |
| | | #endregion |
| | | |
| | | #region 报警和DownTime |
| | | ObservableCollection<WarningSet> _warningRemains = new ObservableCollection<WarningSet>(); |
| | | ObservableCollection<IWarningSet> _warningRemains = new ObservableCollection<IWarningSet>(); |
| | | |
| | | protected virtual void OnMonitorAlarm(DateTime dt, IDevice device, WarningSet warning) |
| | | protected virtual void OnMonitorAlarm(DateTime dt, IDevice device, IWarningSet warning) |
| | | { |
| | | if (warning.CurrentStatus) |
| | | { |