You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4C/Gumming/Modules/Control/Manual/ControlDEVManualViewModule.cs

1167 lines
35 KiB

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
using GummingCommon;
using GummingEntity;
using GummingSupport;
using GummingControl;
using System.Text;
using GummingBusiness;
using Newtonsoft.Json;
using GummingLine;
using System.Threading.Tasks;
namespace Gumming
{
public class ControlDEVManualViewModule : ViewModelBase
{
#region base parameters
private int rows = 20;
private int pagenumber = 1;
public ControlDEVManualView View { get; set; }
private bool IsConfirm;
private bool isLoading;
private System.Timers.Timer timer;
private CancellationTokenSource cancellationTokenSource;
private DEVPrepareExecuter DEVFlowExecuter;
private bool Homing = false;
#endregion
#region constructor
public ControlDEVManualViewModule()
{
View = new ControlDEVManualView();
View.DataContext = this;
ProgressEnabled = true;
DEVFlowExecuter = new DEVPrepareExecuter();
InitializeCommands();
InitializeParameters();
}
private void InitializeCommands()
{
BSRIOCommand = new DelegateCommand(OnBSRIOCommand);
AttractCommand = new DelegateCommand(OnAttractCommand);
MainAxisIOCommand = new DelegateCommand(OnMainAxisIOCommand);
DIN2ArmCommand = new DelegateCommand(OnDIN2ArmCommand);
DevArmCommand = new DelegateCommand(OnDevArmCommand);
HOMECommand = new DelegateCommand(OnHOMECommand);
//RUNCommand = new DelegateCommand(OnRUNCommand);
SVONCommand = new DelegateCommand(OnSVONCommand);
DEVIO1Command = new DelegateCommand(OnDEVIO1Command);
DEVIO2Command = new DelegateCommand(OnDEVIO2Command);
DEVIO3Command = new DelegateCommand(OnDEVIO3Command);
DIIOCommand = new DelegateCommand(OnDIIOCommand);
N2IOCommand = new DelegateCommand(OnN2IOCommand);
WindowCommand = new DelegateCommand(OnWindowCommand);
CupCommand = new DelegateCommand(OnCupCommand);
PrepareCommand = new DelegateCommand(OnPrepareCommand);
TerminateCommand = new DelegateCommand(OnTerminateCommand);
}
public override void InitializeParameters(object content = null)
{
IsConfirm = false;
WindowTitle = "";
//*
if (timer == null)
{
timer = new System.Timers.Timer();
timer.Interval = 300;
timer.Elapsed += timer_Elapsed;
timer.Start();
}//*/
}
~ControlDEVManualViewModule()
{
}
public void LoadDefaultValue()
{
AxisSpeed = Common.ToInt(HardParameters.Read(StationCode + Constant.DEVMainAxisSpeed));
AxisAcc = Common.ToDouble(HardParameters.Read(StationCode + Constant.DEVMainAxisAcc));
AxisDec = Common.ToDouble(HardParameters.Read(StationCode + Constant.DEVMainAxisDec));
}
#endregion
#region Binding Properties
public string WindowTitle { get; private set; }
private string _ControlName;
public string ControlName
{
get
{
return _ControlName;
}
set
{
_ControlName = value;
OnPropertyChanged("ControlName");
}
}
private string _StationCode;
public string StationCode
{
get
{
return _StationCode;
}
set
{
_StationCode = value;
OnPropertyChanged("StationCode");
}
}
private string _MainAxisALM;
public string MainAxisALM
{
get
{
return _MainAxisALM;
}
set
{
_MainAxisALM = value;
OnPropertyChanged("MainAxisALM");
}
}
private double _MainAxisRPM;
public double MainAxisRPM
{
get
{
return _MainAxisRPM;
}
set
{
_MainAxisRPM = value;
OnPropertyChanged("MainAxisRPM");
}
}
private int _AxisSpeed;
public int AxisSpeed
{
get
{
return _AxisSpeed;
}
set
{
_AxisSpeed = value;
OnPropertyChanged("AxisSpeed");
}
}
private double _AxisAcc;
public double AxisAcc
{
get
{
return _AxisAcc;
}
set
{
_AxisAcc = value;
OnPropertyChanged("AxisAcc");
}
}
private double _AxisDec;
public double AxisDec
{
get
{
return _AxisDec;
}
set
{
_AxisDec = value;
OnPropertyChanged("AxisDec");
}
}
private ObservableCollection<HardFormulaEntity> _HardFormulas;
public ObservableCollection<HardFormulaEntity> HardFormulas
{
get
{
return _HardFormulas;
}
set
{
_HardFormulas = value;
OnPropertyChanged("HardFormulas");
}
}
private HardFormulaEntity _SelectedFormula;
public HardFormulaEntity SelectedFormula
{
get
{
return _SelectedFormula;
}
set
{
_SelectedFormula = value;
OnPropertyChanged("SelectedFormula");
}
}
private ushort _SVONStatus;
public ushort SVONStatus
{
get
{
return _SVONStatus;
}
set
{
_SVONStatus = value;
OnPropertyChanged("SVONStatus");
}
}
private ushort _RUNStatus;
public ushort RUNStatus
{
get
{
return _RUNStatus;
}
set
{
_RUNStatus = value;
OnPropertyChanged("RUNStatus");
}
}
private ushort _HOMEStatus;
public ushort HOMEStatus
{
get
{
return _HOMEStatus;
}
set
{
_HOMEStatus = value;
OnPropertyChanged("HOMEStatus");
}
}
private ushort _MainAxisIOStatus;
public ushort MainAxisIOStatus
{
get
{
return _MainAxisIOStatus;
}
set
{
_MainAxisIOStatus = value;
OnPropertyChanged("MainAxisIOStatus");
}
}
private ushort _AttractIOStatus;
public ushort AttractIOStatus
{
get
{
return _AttractIOStatus;
}
set
{
_AttractIOStatus = value;
OnPropertyChanged("AttractIOStatus");
}
}
private ushort _BSRIOStatus;
public ushort BSRIOStatus
{
get
{
return _BSRIOStatus;
}
set
{
_BSRIOStatus = value;
OnPropertyChanged("BSRIOStatus");
}
}
private ushort _DEVIO1Status;
public ushort DEVIO1Status
{
get
{
return _DEVIO1Status;
}
set
{
_DEVIO1Status = value;
OnPropertyChanged("DEVIO1Status");
}
}
private ushort _DEVIO2Status;
public ushort DEVIO2Status
{
get
{
return _DEVIO2Status;
}
set
{
_DEVIO2Status = value;
OnPropertyChanged("DEVIO2Status");
}
}
private ushort _DEVIO3Status;
public ushort DEVIO3Status
{
get
{
return _DEVIO3Status;
}
set
{
_DEVIO3Status = value;
OnPropertyChanged("DEVIO3Status");
}
}
private ushort _DIIOStatus;
public ushort DIIOStatus
{
get
{
return _DIIOStatus;
}
set
{
_DIIOStatus = value;
OnPropertyChanged("DIIOStatus");
}
}
private ushort _N2IOStatus;
public ushort N2IOStatus
{
get
{
return _N2IOStatus;
}
set
{
_N2IOStatus = value;
OnPropertyChanged("N2IOStatus");
}
}
private ushort _WindowStatus;
public ushort WindowStatus
{
get
{
return _WindowStatus;
}
set
{
_WindowStatus = value;
OnPropertyChanged("WindowStatus");
}
}
private ushort _CupStatus;
public ushort CupStatus
{
get
{
return _CupStatus;
}
set
{
_CupStatus = value;
OnPropertyChanged("CupStatus");
}
}
private ushort _MainAxisIOStatus2;
public ushort MainAxisIOStatus2
{
get
{
return _MainAxisIOStatus2;
}
set
{
_MainAxisIOStatus2 = value;
OnPropertyChanged("MainAxisIOStatus2");
}
}
private ushort _CupStatus2;
public ushort CupStatus2
{
get
{
return _CupStatus2;
}
set
{
_CupStatus2 = value;
OnPropertyChanged("CupStatus2");
}
}
private ushort _PrepareStatus;
public ushort PrepareStatus
{
get
{
return _PrepareStatus;
}
set
{
_PrepareStatus = value;
OnPropertyChanged("PrepareStatus");
}
}
private ushort _TerminateStatus;
public ushort TerminateStatus
{
get
{
return _TerminateStatus;
}
set
{
_TerminateStatus = value;
OnPropertyChanged("TerminateStatus");
}
}
private bool _ProgressEnabled;
public bool ProgressEnabled
{
get
{
return _ProgressEnabled;
}
set
{
_ProgressEnabled = value;
OnPropertyChanged("ProgressEnabled");
}
}
#endregion
#region Binding Commands
private ICommand _DevArmCommand;
public ICommand DevArmCommand
{
get
{
return _DevArmCommand;
}
set
{
_DevArmCommand = value;
OnPropertyChanged("DevArmCommand");
}
}
private ICommand _DIN2ArmCommand;
public ICommand DIN2ArmCommand
{
get
{
return _DIN2ArmCommand;
}
set
{
_DIN2ArmCommand = value;
OnPropertyChanged("DIN2ArmCommand");
}
}
private ICommand _MainAxisIOCommand;
public ICommand MainAxisIOCommand
{
get
{
return _MainAxisIOCommand;
}
set
{
_MainAxisIOCommand = value;
OnPropertyChanged("MainAxisIOCommand");
}
}
private ICommand _AttractCommand;
public ICommand AttractCommand
{
get
{
return _AttractCommand;
}
set
{
_AttractCommand = value;
OnPropertyChanged("AttractCommand");
}
}
private ICommand _BSRIOCommand;
public ICommand BSRIOCommand
{
get
{
return _BSRIOCommand;
}
set
{
_BSRIOCommand = value;
OnPropertyChanged("BSRIOCommand");
}
}
private ICommand _DEVIO1Command;
public ICommand DEVIO1Command
{
get
{
return _DEVIO1Command;
}
set
{
_DEVIO1Command = value;
OnPropertyChanged("DEVIO1Command");
}
}
private ICommand _DEVIO2Command;
public ICommand DEVIO2Command
{
get
{
return _DEVIO2Command;
}
set
{
_DEVIO2Command = value;
OnPropertyChanged("DEVIO2Command");
}
}
private ICommand _DEVIO3Command;
public ICommand DEVIO3Command
{
get
{
return _DEVIO3Command;
}
set
{
_DEVIO3Command = value;
OnPropertyChanged("DEVIO3Command");
}
}
private ICommand _DIIOCommand;
public ICommand DIIOCommand
{
get
{
return _DIIOCommand;
}
set
{
_DIIOCommand = value;
OnPropertyChanged("DIIOCommand");
}
}
private ICommand _N2IOCommand;
public ICommand N2IOCommand
{
get
{
return _N2IOCommand;
}
set
{
_N2IOCommand = value;
OnPropertyChanged("N2IOCommand");
}
}
private ICommand _SVONCommand;
public ICommand SVONCommand
{
get
{
return _SVONCommand;
}
set
{
_SVONCommand = value;
OnPropertyChanged("SVONCommand");
}
}
private ICommand _RUNCommand;
public ICommand RUNCommand
{
get
{
return _RUNCommand;
}
set
{
_RUNCommand = value;
OnPropertyChanged("RUNCommand");
}
}
private ICommand _HOMECommand;
public ICommand HOMECommand
{
get
{
return _HOMECommand;
}
set
{
_HOMECommand = value;
OnPropertyChanged("HOMECommand");
}
}
private ICommand _WindowCommand;
public ICommand WindowCommand
{
get
{
return _WindowCommand;
}
set
{
_WindowCommand = value;
OnPropertyChanged("WindowCommand");
}
}
private ICommand _CupCommand;
public ICommand CupCommand
{
get
{
return _CupCommand;
}
set
{
_CupCommand = value;
OnPropertyChanged("CupCommand");
}
}
private ICommand _PrepareCommand;
public ICommand PrepareCommand
{
get
{
return _PrepareCommand;
}
set
{
_PrepareCommand = value;
OnPropertyChanged("PrepareCommand");
}
}
private ICommand _TerminateCommand;
public ICommand TerminateCommand
{
get
{
return _TerminateCommand;
}
set
{
_TerminateCommand = value;
OnPropertyChanged("TerminateCommand");
}
}
#endregion
#region Private Methods
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (this.IsActiveChildPage && !Helpering.IsTerminate)
{
int position = 0;
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
int speed = 0;
var flow = HardParameters.GetDEVMainAxis(StationCode);
if (flow != null)
{
DeviceControl.GetSpeed(flow.NodeId, flow.SlotId, ref speed);
DeviceControl.GetPosition(flow.NodeId, flow.SlotId, ref position);
if (Homing && ControlCheck.IsHomeDone(flow.NodeId, flow.SlotId))//<2F>ָ<EFBFBD>Home״̬
{
HOMEStatus = 0;
Homing = false;
}
//<2F><>ȡ<EFBFBD><EFBFBD><E6BEAF>Ϣ
ushort Datasize = 4;
byte[] Data = new byte[4];
DeviceControl.ReadPDOParameter(flow.NodeId, 0, Global.AlmSign, 0, Datasize, ref Data[0]);
string code = TypeHelper.IntToHex(TypeHelper.ByteArrayToInt(Data));
View.Dispatcher.BeginInvoke(new Action(() =>
{
MainAxisALM = Convert.ToString(code);
MainAxisRPM = speed / 10.0;
}), null);
//ˢ<><CBA2>IO״̬
if (Global.GetInPortStatus(StationCode, "MainAxis") == 1)
{
MainAxisIOStatus2 = 1;
}
if (Global.GetInPortStatus(StationCode, "MainAxisLow") == 1)
{
MainAxisIOStatus2 = 0;
}
if (Global.GetInPortStatus(StationCode, "Cup") == 1)
{
CupStatus2 = 1;
}
if (Global.GetInPortStatus(StationCode, "CupLow") == 1)
{
CupStatus2 = 0;
}
}
}
}
private void RefreshIOStatus()
{
//״̬λˢ<CEBB><CBA2>
MainAxisIOStatus = Global.GetInPortStatus(StationCode, "MainAxis");
WindowStatus = Global.GetInPortStatus(StationCode, "Window");
CupStatus = Global.GetInPortStatus(StationCode, "Cup");
AttractIOStatus = Global.GetInPortStatus(StationCode, "Attract");
BSRIOStatus = Global.GetOutPortStatus(StationCode, "BSR");
DEVIO1Status = Global.GetOutPortStatus(StationCode, "DEV1");
DEVIO2Status = Global.GetOutPortStatus(StationCode, "DEV2");
DIIOStatus = Global.GetOutPortStatus(StationCode, "DI");
N2IOStatus = Global.GetOutPortStatus(StationCode, "N2");//*/
}
//<2F><>Ƭ<EFBFBD><C6AC><EFBFBD><EFBFBD>
private void OnAttractCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
AttractIOStatus = (ushort)(AttractIOStatus != 1 ? 1 : 0);
OnAttractCommand(AttractIOStatus);
}
private void OnAttractCommand(ushort value)
{
var flow = HardParameters.GetDEVAttractIO(StationCode);
if (flow != null)
{
AttractIOStatus = value;
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(flow.NodeId, flow.SlotId, flow.BitNum, AttractIOStatus));
}
}
// <20><><EFBFBD><EFBFBD>BSR,<2C><>Ӧ<EFBFBD>䷽BSR
private void OnBSRIOCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
BSRIOStatus = (ushort)(BSRIOStatus != 1 ? 1 : 0);
OnBSRIOCommand(BSRIOStatus);
}
private void OnBSRIOCommand(ushort value)
{
var action = HardParameters.GetDEVBSRIO(StationCode);
if (action != null)
{
BSRIOStatus = value;
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action.NodeId, action.SlotId, action.BitNo, BSRIOStatus));
}
}
private void OnMainAxisIOCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
MainAxisIOStatus = (ushort)(MainAxisIOStatus != 1 ? 1 : 0);
OnMainAxisIOCommand(MainAxisIOStatus, false);
}
private void OnMainAxisIOCommand(ushort value, bool wait)
{
HardFormulaFlowEntity mapFlow = null;
var flow = HardParameters.GetDEVMainAxisIO(StationCode, out mapFlow);
if (flow != null && mapFlow != null)
{
MainAxisIOStatus = value;
//<2F><>Ϊ˫<CEAA><CBAB>
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(mapFlow.NodeId, mapFlow.SlotId, mapFlow.BitNum, (ushort)(1 - MainAxisIOStatus)));
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(flow.NodeId, flow.SlotId, flow.BitNum, MainAxisIOStatus));
if (wait)//<2F>ȴ<EFBFBD><C8B4><EFBFBD>λ
{
ControlCheck.WaitDIDone(value == 0 ? flow.RefPortLow : flow.RefPortHigh, true);
}
}
}
private void CloseCup()
{
//<2F>رղ<D8B1>׽<EFBFBD><D7BD>
var action = HardParameters.GetDEVCUPIO(StationCode);
if (action != null)
{
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action.NodeId, action.SlotId, action.BitNo, 0));
}
CupStatus = 0;
}
private void OnDIN2ArmCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
//<2F>رճ<D8B1>Ƭ̨<C6AC><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
OnMainAxisIOCommand(0, false);
//<2F>رղ<D8B1>׽<EFBFBD><D7BD>
CloseCup();
ControlDEVArmViewModule ccvm = new ControlDEVArmViewModule();
ccvm.HeaderTitle = "Ưϴ<C6AF>ۿ<EFBFBD><DBBF><EFBFBD>";
ccvm.StationCode = StationCode;
ccvm.IsDevArm = false;
ccvm.LoadDefaultValue();
ViewModelLoad.SetActiveChildModel(ccvm);
ccvm.ShowDialog();
}
private void OnDevArmCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
//<2F>رճ<D8B1>Ƭ̨<C6AC><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
OnMainAxisIOCommand(0, false);
//<2F>رղ<D8B1>׽<EFBFBD><D7BD>
CloseCup();
ControlDEVArmViewModule ccvm = new ControlDEVArmViewModule();
ccvm.HeaderTitle = "<22><>Ӱ<EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD>";
ccvm.StationCode = StationCode;
ccvm.IsDevArm = true;
ccvm.LoadDefaultValue();
ViewModelLoad.SetActiveChildModel(ccvm);
ccvm.ShowDialog();
}
private void OnHOMECommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
var flow = HardParameters.GetDEVMainAxis(StationCode);
if (flow != null)
{
int axisSpeed = BusinessHelper.GetHomeRPMSpeed(flow.NodeId, (double)AxisSpeed);
SVONStatus = 1;
double acc = AxisAcc / 1000.0;
if (ControlCheck.PMCInvoke(false, "SetSvon", null, () => DeviceControl.SetSvon(flow.NodeId, flow.SlotId, SVONStatus)))
{
if (HOMEStatus != 1)
{
Homing = true;
HOMEStatus = 1;
RUNStatus = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>
ControlCheck.PMCInvoke(false, "GoHome", null, () => DeviceControl.GoHome(flow.NodeId, flow.SlotId, 0, (uint)axisSpeed, acc));
}
else
{
double dec = AxisDec / 1000.0;
HOMEStatus = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>
ControlCheck.PMCInvoke(false, "StopMove", null, () => DeviceControl.StopMove(flow.NodeId, flow.SlotId, dec));
}
}
}
}
public void OnRUNStart()
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
var flow = HardParameters.GetDEVMainAxis(StationCode);
if (flow != null)
{
int axisSpeed = BusinessHelper.GetRPMMapSpeed(flow.NodeId, (double)AxisSpeed);
SVONStatus = 1;
double acc = AxisAcc / 1000.0;
if (ControlCheck.PMCInvoke(false, "SetSvon", null, () => DeviceControl.SetSvon(flow.NodeId, flow.SlotId, SVONStatus)))
{
RUNStatus = 1;
//<2F><><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>
ControlCheck.PMCInvoke(false, "StartMove", null, () => DeviceControl.StartMove(flow.NodeId, flow.SlotId, 0, axisSpeed, axisSpeed, acc));
}
}
}
public void OnRUNStop()
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
var flow = HardParameters.GetDEVMainAxis(StationCode);
if (flow != null)
{
int axisSpeed = BusinessHelper.GetRPMMapSpeed(flow.NodeId, (double)AxisSpeed);
SVONStatus = 1;
double dec = AxisDec / 1000.0;
if (ControlCheck.PMCInvoke(false, "SetSvon", null, () => DeviceControl.SetSvon(flow.NodeId, flow.SlotId, SVONStatus)))
{
RUNStatus = 0;
//<2F><><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>
ControlCheck.PMCInvoke(false, "StopMove", null, () => DeviceControl.StopMove(flow.NodeId, flow.SlotId, dec));
}
}
}
private void OnSVONCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
var flow = HardParameters.GetDEVMainAxis(StationCode);
if (flow != null)
{
SVONStatus = (ushort)(SVONStatus != 1 ? 1 : 0);
DeviceControl.SetSvon(Common.ToUInt16(flow.NodeId), Common.ToUInt16(flow.SlotId), SVONStatus);
}
}
public void OnAxisSpeedTextChangedCommand(string value)
{
HardParameterDA.Save(StationCode + Constant.DEVMainAxisSpeed, value);
}
public void OnAxisAccTextChangedCommand(string value)
{
HardParameterDA.Save(StationCode + Constant.DEVMainAxisAcc, value);
}
public void OnAxisDecTextChangedCommand(string value)
{
HardParameterDA.Save(StationCode + Constant.DEVMainAxisDec, value);
}
private void OnDEVIO1Command(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
DEVIO1Status = (ushort)(DEVIO1Status != 1 ? 1 : 0);
OnDEVIO1Command(DEVIO1Status);
}
private void OnDEVIO1Command(ushort value)
{
DEVIO1Status = value;
HardActionEntity action1 = null;
HardActionEntity action2 = null;
HardParameters.GetDEVDEV1(StationCode, out action1, out action2);
if (action1 != null)
{
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action1.NodeId, action1.SlotId, action1.BitNo, DEVIO1Status));
}
if (action2 != null)
{
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action2.NodeId, action2.SlotId, action2.BitNo, DEVIO1Status));
}
}
private void OnDEVIO2Command(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
DEVIO2Status = (ushort)(DEVIO2Status != 1 ? 1 : 0);
OnDEVIO2Command(DEVIO2Status);
}
private void OnDEVIO2Command(ushort value)
{
DEVIO2Status = value;
HardActionEntity action1 = null;
HardActionEntity action2 = null;
HardParameters.GetDEVDEV2(StationCode, out action1, out action2);
if (action1 != null)
{
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action1.NodeId, action1.SlotId, action1.BitNo, DEVIO2Status));
}
if (action2 != null)
{
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action2.NodeId, action2.SlotId, action2.BitNo, DEVIO2Status));
}
}
private void OnDEVIO3Command(Object sender)
{
}
private void OnDIIOCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
DIIOStatus = (ushort)(DIIOStatus != 1 ? 1 : 0);
OnDIIOCommand(DIIOStatus);
}
private void OnDIIOCommand(ushort value)
{
var action = HardParameters.GetDEVDIIO(StationCode);
if (action != null)
{
DIIOStatus = value;
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action.NodeId, action.SlotId, action.BitNo, DIIOStatus));
}
}
private void OnN2IOCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
N2IOStatus = (ushort)(N2IOStatus != 1 ? 1 : 0);
OnN2IOCommand(N2IOStatus);
}
private void OnN2IOCommand(ushort value)
{
var action = HardParameters.GetDEVN2IO(StationCode);
if (action != null)
{
N2IOStatus = value;
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action.NodeId, action.SlotId, action.BitNo, N2IOStatus));
}
}
private void OnWindowCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
WindowStatus = (ushort)(WindowStatus != 1 ? 1 : 0);
OnWindowCommand(WindowStatus);
}
private void OnWindowCommand(ushort value)
{
var action = HardParameters.GetDEVWindowIO(StationCode);
if (action != null)
{
WindowStatus = value;
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action.NodeId, action.SlotId, action.BitNum, WindowStatus));
}
}
private void OnCupCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
var action = HardParameters.GetDEVCUPIO(StationCode);
if (action != null)
{
CupStatus = (ushort)(CupStatus != 1 ? 1 : 0);
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(action.NodeId, action.SlotId, action.BitNo, CupStatus));
}
}
private void OnPrepareCommand(Object sender)
{
if (StationLockControl.StationIsLock(StationCode))
{
ShowMessageBox(HintMessage.StationLocked);
return;
}
StationLockControl.LockStation(StationCode, null);
ProgressEnabled = false;
List<HardFormulaFlowEntity> flows = Global.Flows.FindAll(q => q.StationCode == StationCode && q.IsPrepare);
cancellationTokenSource = new CancellationTokenSource();
Task flowTask = new Task(() =>
{
try
{
Global.ClearErrorState(StationCode);
//<2F>رճ<D8B1>Ƭ̨<C6AC><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
OnMainAxisIOCommand(0, true);
//<2F>رղ<D8B1>׽<EFBFBD><D7BD>
CloseCup();
//<2F><><EFBFBD><EFBFBD>״̬
//OnWindowCommand(0);
OnAttractCommand(0);
OnBSRIOCommand(0);
OnDEVIO1Command(0);
OnDEVIO2Command(0);
OnDIIOCommand(0);
OnN2IOCommand(0);
DEVFlowExecuter.Execute(cancellationTokenSource, flows, null, true, false);
//RefreshIOStatus();
ProgressEnabled = true;
StationLockControl.UnLockStation(StationCode);
}
catch (Exception ex)
{
//StepMessage = string.Format(" ִ<><D6B4><EFBFBD>쳣:{0}!", ex.Message);
ProgressEnabled = true;
StationLockControl.UnLockStation(StationCode);
}
}, cancellationTokenSource.Token, TaskCreationOptions.LongRunning);
flowTask.Start();
}
private void OnTerminateCommand(Object sender)
{
if (cancellationTokenSource != null)
{
cancellationTokenSource.Cancel();
}
Helpering.Sleep(1000);
ProgressEnabled = true;
}
#endregion
}
}