| | |
| | | using Bro.M071.DBManager; |
| | | using Bro.M071.Model; |
| | | using Bro.M071.Model.Model; |
| | | using Bro.M071.Process.UI; |
| | | using Bro.Process; |
| | | using HalconDotNet; |
| | | using Newtonsoft.Json; |
| | |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.Drawing; |
| | | using System.Drawing.Imaging; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Text; |
| | |
| | | |
| | | base.Open(); |
| | | |
| | | InitialMotionCardBaseAxisAlarm(); |
| | | |
| | | SwitchBeep(false); |
| | | SwitchLightGreen(false); |
| | | SwitchLightRed(false); |
| | |
| | | |
| | | Reset(null, null, null); |
| | | FullReset(null); |
| | | |
| | | } |
| | | |
| | | private void InitialMotionCardBaseAxisAlarm() |
| | | { |
| | | if (outputCtrlCard != null) |
| | | { |
| | | outputCtrlCard.OnAxisAlarmRaised -= MotionCard_OnAxisAlarmRaised; |
| | | outputCtrlCard.OnAxisAlarmRaised += MotionCard_OnAxisAlarmRaised; |
| | | } |
| | | } |
| | | |
| | | private void MotionCard_OnAxisAlarmRaised(int axisIndex, string alarmMsg) |
| | | { |
| | | RaisedAlarm(alarmMsg); |
| | | MachineState = MachineState.Alarm; |
| | | } |
| | | |
| | | private void InitialSetting() |
| | | { |
| | | //数据库迁移检查 |
| | | DatabaseInitialize.Initialize(); |
| | | //DatabaseInitialize.Initialize(); |
| | | |
| | | MotionCardSettingCheck(); |
| | | |
| | |
| | | [ProcessMethod("", "StartJob", "开始扫描", InvokeType.TestInvoke)] |
| | | public ProcessResponse StartJob(IOperationConfig opConfig, IDevice invokeDevice, IDevice sourceDevice) |
| | | { |
| | | if (!IsAllowedWork) |
| | | { |
| | | throw new ProcessException(SafetyMsg, null, ExceptionLevel.Fatal); |
| | | } |
| | | |
| | | if (MachineState != MachineState.Ready) |
| | | throw new ProcessException("机台未就绪,请勿开始测量", null, ExceptionLevel.Fatal); |
| | | |
| | |
| | | Config.SnapshotPointCollection.Where(u => u.IsEnabled).ToList().ForEach(s => |
| | | { |
| | | _pauseHandle.WaitHandle.WaitOne(); |
| | | |
| | | if (MachineState != MachineState.Running) |
| | | { |
| | | throw new ProcessException("机台状态不在运行中,退出检测"); |
| | | } |
| | | |
| | | IDevice device = DeviceCollection.FirstOrDefault(u => u.Id == s.MotionOp.Device); |
| | | if (device == null) |
| | |
| | | |
| | | LogAsync(DateTime.Now, $"{m.GetDisplayText()}检测结果", $"{((m.Spec.MeasureResult ?? false) ? "OK" : "NG")}"); |
| | | |
| | | IShapeElement indicator = null; |
| | | KeyIndicator indicator = new KeyIndicator(m.Id, m.DisplayLocation); |
| | | indicator.Text = (m.Spec.ActualValue == null || m.Spec.ActualValue == -999) ? "NA" : m.Spec.ActualValue.Value.ToString("f2"); |
| | | indicator.ResultState = m.Spec.MeasureResult; |
| | | pMeasure.ElementList.Add(indicator); |
| | | //输出图形基元到界面 |
| | | OnElementUpdated?.BeginInvoke(indicator, null, null); |
| | |
| | | |
| | | //MES输出 todo |
| | | if (Config.IsEnableMESUpload) |
| | | { |
| | | { |
| | | } |
| | | |
| | | //Excel报表输出 (单个产品的excel导出) |
| | | ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet); |
| | | //数据库保存 |
| | | SaveProductionData(measurementUnitResultAndKeyUnitDataSet); |
| | | ////Excel报表输出 (单个产品的excel导出) |
| | | //ExportProductionExcel(measurementUnitResultAndKeyUnitDataSet); |
| | | ////数据库保存 |
| | | //SaveProductionData(measurementUnitResultAndKeyUnitDataSet); |
| | | |
| | | SaveWholeImage(pMeasure); |
| | | |
| | |
| | | { |
| | | foreach (var keyValue in keyUnit.MeasureValueDict)//获取单个键的单个测量item 结果 |
| | | { |
| | | KeyUnitData keyUnitData = new KeyUnitData(); |
| | | keyUnitData.Key = keyUnit.Key; |
| | | keyUnitData.MeasurementItem = keyValue.Key; |
| | | keyUnitData.ItemValue = keyValue.Value.ToString(); |
| | | keyUnitDatas.Add(keyUnitData); |
| | | bool isExist = keyUnitDatas.Any(u => u.Key == keyUnit.Key && u.MeasurementItem == keyValue.Key); |
| | | if (!isExist)//已存在 不重复添加原始数据 |
| | | { |
| | | KeyUnitData keyUnitData = new KeyUnitData(); |
| | | keyUnitData.Key = keyUnit.Key; |
| | | keyUnitData.MeasurementItem = keyValue.Key; |
| | | keyUnitData.ItemValue = keyValue.Value.ToString(); |
| | | keyUnitDatas.Add(keyUnitData); |
| | | |
| | | MeasurementAndKeyDataRelation measurementAndKeyDataRelation = new MeasurementAndKeyDataRelation(); |
| | | measurementAndKeyDataRelation.MeasurementUnitResultId = measurementUnitResult.ID; |
| | | measurementAndKeyDataRelation.KeyUnitDataId = keyUnitData.ID; |
| | | measurementAndKeyDataRelationList.Add(measurementAndKeyDataRelation); |
| | | |
| | | MeasurementAndKeyDataRelation measurementAndKeyDataRelation = new MeasurementAndKeyDataRelation(); |
| | | measurementAndKeyDataRelation.MeasurementUnitResultId = measurementUnitResult.ID; |
| | | measurementAndKeyDataRelation.KeyUnitDataId = keyUnitData.ID; |
| | | measurementAndKeyDataRelationList.Add(measurementAndKeyDataRelation); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | private async void ExportProductionExcel(ProductionMeasurementUnitResultAndKeyUnitDataSet measurementUnitResultAndKeyUnitDataSet) |
| | | { |
| | | if (!Config.IsCSVOutputEnabled) |
| | | return; |
| | | |
| | | await Task.Run(() => |
| | | { |
| | | ExcelExportSet excelExportDto = new ExcelExportSet(); |
| | |
| | | Directory.CreateDirectory(dir); |
| | | } |
| | | |
| | | map.Save(Path.Combine(dir, $"{pMeasure.Barcode}_{DateTime.Now.ToString("HHmmss")}.bmp")); |
| | | map.Save(Path.Combine(dir, $"{pMeasure.Barcode}_{pMeasure.PResult}_{DateTime.Now.ToString("HHmmss")}.png"), ImageFormat.Png); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | { |
| | | _halconToolDict[keyToolKey].InputImageDic["INPUT_Image"] = image; |
| | | _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_X"] = scanParam.Resolution_X; |
| | | _halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z; |
| | | //_halconToolDict[keyToolKey].InputTupleDic["INPUT_Resolution_Z"] = scanParam.Resolution_Z; |
| | | if (!_halconToolDict[keyToolKey].RunProcedure(out string error)) |
| | | { |
| | | LogAsync(DateTime.Now, $"{k.AliasName}检测算法异常,{error}", ""); |