public void InitHardware() { Logger.DEFAULT.Info(LogCategory.CODE, this.GetType().Name, "InitHardware start"); Task.Factory.StartNew(() => { Machine.Instance.Valve1.Proportioner.Proportional.SetValue((ushort)this.RuntimeSettings.AirPressure); if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { Proportioner.Sleep(); Machine.Instance.Valve2.Proportioner.Proportional.SetValue((ushort)this.RuntimeSettings.AirPressure2); } //写入标准温度 if (SensorMgr.Instance.Heater.Vendor == HeaterControllerMgr.Vendor.Aika) { if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { Machine.Instance.HeaterController1.Fire(HeaterMsg.设置标准温度值, this.RuntimeSettings.Valve2Temperature, 1); } Machine.Instance.HeaterController1.Fire(HeaterMsg.设置标准温度值, this.RuntimeSettings.Valve1Temperature, 0); } else { if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { Machine.Instance.HeaterController2.Fire(HeaterMsg.设置标准温度值, this.RuntimeSettings.Valve2Temperature, 0); } Machine.Instance.HeaterController1.Fire(HeaterMsg.设置标准温度值, this.RuntimeSettings.Valve1Temperature, 0); } }); Logger.DEFAULT.Info(LogCategory.CODE, this.GetType().Name, "InitHardware end"); }
public void CloseHardware() { Machine.Instance.Valve1.Proportioner.Proportional.SetValue(0); if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { Proportioner.Sleep(); Machine.Instance.Valve2.Proportioner.Proportional.SetValue(0); } }
private void btnOk_Click(object sender, EventArgs e) { if ((double)this.nudSingleDotWt.Value <= 0) { this.tabControl1.SelectedTab = this.tabPage1; this.nudSingleDotWt.BackColor = Color.Red; return; } this.nudSingleDotWt.BackColor = System.Drawing.SystemColors.Window; this.fluidProgram.RuntimeSettings.SingleDropWeight = (double)this.nudSingleDotWt.Value; // 设置气压1 if (this.fluidProgram.RuntimeSettings.AirPressure != (int)this.nudAirPressure.Value) { this.fluidProgram.RuntimeSettings.AirPressure = (int)this.nudAirPressure.Value; Machine.Instance.Valve1.Proportioner.Proportional.SetValue((ushort)this.nudAirPressure.Value); } // 设置气压2 if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { if (this.fluidProgram.RuntimeSettings.AirPressure2 != (int)this.nudAirPressure2.Value) { this.fluidProgram.RuntimeSettings.AirPressure2 = (int)this.nudAirPressure2.Value; Proportioner.Sleep(); Machine.Instance.Valve2.Proportioner.Proportional.SetValue((ushort)this.nudAirPressure2.Value); } } //设置温度 if (this.fluidProgram.RuntimeSettings.Valve1Temperature != (double)this.nudValve1Temprature.Value) { this.fluidProgram.RuntimeSettings.Valve1Temperature = (double)this.nudValve1Temprature.Value; Machine.Instance.HeaterController1.HeaterPrm.Standard[0] = this.fluidProgram.RuntimeSettings.Valve1Temperature; Machine.Instance.HeaterController1.Fire(HeaterMsg.设置标准温度值, (double)this.nudValve1Temprature.Value, 0); } if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { if (this.fluidProgram.RuntimeSettings.Valve2Temperature != (double)this.nudValve2Temprature.Value) { this.fluidProgram.RuntimeSettings.Valve2Temperature = (double)this.nudValve2Temprature.Value; if (SensorMgr.Instance.Heater.Vendor == HeaterControllerMgr.Vendor.Aika) { Machine.Instance.HeaterController1.HeaterPrm.Standard[1] = this.fluidProgram.RuntimeSettings.Valve2Temperature; Machine.Instance.HeaterController1.Fire(HeaterMsg.设置标准温度值, (double)this.nudValve2Temprature.Value, 1); } else { Machine.Instance.HeaterController2.HeaterPrm.Standard[0] = this.fluidProgram.RuntimeSettings.Valve2Temperature; Machine.Instance.HeaterController2.Fire(HeaterMsg.设置标准温度值, (double)this.nudValve2Temprature.Value, 0); } } } this.fluidProgram.RuntimeSettings.isHalfAdjust = this.cbxHalfAdjust.Checked; this.fluidProgram.RuntimeSettings.MaxTolerance = (double)this.nudMaxHeight.Value; this.fluidProgram.RuntimeSettings.MinTolerance = (double)this.nudMinHeight.Value; this.fluidProgram.RuntimeSettings.SimulDistence = (double)this.nudSimulDistence.Value; this.fluidProgram.RuntimeSettings.SimulOffsetX = (double)this.nudSimulOffsetX.Value; this.fluidProgram.RuntimeSettings.SimulOffsetY = (double)this.nudSimulOffsetY.Value; #region 称重清洗吐液,浸泡 this.fluidProgram.RuntimeSettings.PurgeBeforeStart = this.cbxPurge.Checked; this.fluidProgram.RuntimeSettings.ScaleBeforeStart = this.cbxScale.Checked; this.fluidProgram.RuntimeSettings.IsAutoScaleSpan = this.chxAutoScaleSpan.Checked; this.fluidProgram.RuntimeSettings.IsAutoScaleCount = this.chxAutoScaleCount.Checked; this.fluidProgram.RuntimeSettings.AutoScaleCount = (int)this.nudAutoScaleCount.Value; this.fluidProgram.RuntimeSettings.AutoScaleSpan = new TimeSpan((int)this.nudAutoScaleHour.Value, (int)this.nudAutoScaleMinu.Value, (int)this.nudAutoScaleSeco.Value); this.fluidProgram.RuntimeSettings.IsAutoPurgeSpan = this.chxAutoPurgeSpan.Checked; this.fluidProgram.RuntimeSettings.IsAutoPurgeCount = this.chxAutoPurgeCount.Checked; this.fluidProgram.RuntimeSettings.AutoPurgeCount = (int)this.nudAutoPurgeCount.Value; this.fluidProgram.RuntimeSettings.AutoPurgeSpan = new TimeSpan((int)this.nudAutoPurgeHour.Value, (int)this.nudAutoPurgeMinu.Value, (int)this.nudAutoPurgeSeco.Value); this.fluidProgram.RuntimeSettings.IsSyncSingleDropWeight = this.ckbSync.Checked; this.fluidProgram.RuntimeSettings.AutoSoakSpan = new TimeSpan((int)this.nudDoSoakHour.Value, (int)this.nudDoSoakMin.Value, (int)this.nudDoSoakSec.Value); #endregion #region marks this.fluidProgram.RuntimeSettings.AutoSkipNgMarks = this.chxAutoSkipNgMark.Checked; this.fluidProgram.RuntimeSettings.SaveMarkImages = this.chxSaveMarkImages.Checked; this.fluidProgram.RuntimeSettings.SaveMeasureMentImages = this.ckbSaveMeasureImages.Checked; this.fluidProgram.RuntimeSettings.MarksSort = this.ckbMarkSort.Checked; this.fluidProgram.RuntimeSettings.Back2WorkpieceOrigin = this.chxBackToWorkpieceOrigin.Checked; this.fluidProgram.RuntimeSettings.MeasureCmdsSort = this.ckbMeasureHeightSort.Checked; #endregion #region 飞拍参数 this.fluidProgram.RuntimeSettings.isFlyMarks = this.cbxFlyEnable.Checked; this.fluidProgram.RuntimeSettings.FlyIsRowFirst = this.cbxIsRowFirst.Checked; //如果飞拍运动参数改动需要重新校对飞拍校正值 if (this.tbxFlySpeed.Value != this.fluidProgram.RuntimeSettings.FlySpeed || this.tbxCornerSpeed.Value != this.fluidProgram.RuntimeSettings.FlyCornerSpeed || this.tbxFlyAcc.Value != this.fluidProgram.RuntimeSettings.FlyAcc) { this.fluidProgram.RuntimeSettings.FlyOffsetIsValid = false; } this.fluidProgram.RuntimeSettings.FlySpeed = this.tbxFlySpeed.Value; this.fluidProgram.RuntimeSettings.FlyAcc = this.tbxFlyAcc.Value; this.fluidProgram.RuntimeSettings.FlyCornerSpeed = this.tbxCornerSpeed.Value; this.fluidProgram.RuntimeSettings.FlyPreDistance = this.tbxPreDistance.Value; this.fluidProgram.RuntimeSettings.isAdjustFlyOffset = this.cbxAdjustFlyOffset.Checked; this.fluidProgram.RuntimeSettings.IsNGReshoot = this.cbxNGReshoot.Checked; this.fluidProgram.RuntimeSettings.FlyOriginPos = this.cbxFlyOriginPos.Checked; this.fluidProgram.RuntimeSettings.DisposeThreadCount = this.tbxThreadCount.Value; if (this.fluidProgram.RuntimeSettings.DisposeThreadCount < 1) { this.fluidProgram.RuntimeSettings.DisposeThreadCount = 1; } else if (this.fluidProgram.RuntimeSettings.DisposeThreadCount > 5) { this.fluidProgram.RuntimeSettings.DisposeThreadCount = 5; } #endregion #region 连续前瞻 this.fluidProgram.RuntimeSettings.FluidMoveMode = rbnNormal.Checked ? FluidMoveMode.普通 : FluidMoveMode.连续; this.fluidProgram.RuntimeSettings.LookTime = (double)this.nudLookTime.Value; this.fluidProgram.RuntimeSettings.LookAccMax = (double)this.nudLookAccMax.Value; this.fluidProgram.RuntimeSettings.LookCount = (int)this.nudLookCount.Value; #endregion #region 浸泡 this.fluidProgram.RuntimeSettings.AutoSoakSpan = new TimeSpan((int)this.nudDoSoakHour.Value, (int)this.nudDoSoakMin.Value, (int)this.nudDoSoakSec.Value); this.fluidProgram.RuntimeSettings.IsAutoSoakSpan = this.chxAutoSoakSpan.Checked; #endregion // data 参数保存 this.dataControl.SetParam(this.fluidProgram); this.Close(); CompareObj.CompareProperty(this.fluidProgram.RuntimeSettings, this.runtimeSettingsBackUp, null, this.GetType().Name); CompareObj.CompareField(this.fluidProgram.RuntimeSettings, this.runtimeSettingsBackUp, null, this.GetType().Name); }