|
|
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 COTExecuteViewModule : ViewModelBase
|
|
|
{
|
|
|
#region base parameters
|
|
|
private int rows = 20;
|
|
|
private int pagenumber = 1;
|
|
|
public COTExecuteView View { get; set; }
|
|
|
private bool IsConfirm;
|
|
|
private bool isLoading;
|
|
|
private CancellationTokenSource cancellationTokenSource;
|
|
|
private List<HardFormulaCOTEntity> steps;
|
|
|
private System.Timers.Timer timer;
|
|
|
private DateTime dtStart;
|
|
|
private COTPrepareExecuter COTFlowExecuter;
|
|
|
private COTFormulaExecuter COTFormulaExecuter;
|
|
|
#endregion
|
|
|
|
|
|
#region constructor
|
|
|
public COTExecuteViewModule()
|
|
|
{
|
|
|
View = new COTExecuteView();
|
|
|
View.DataContext = this;
|
|
|
|
|
|
InitializeCommands();
|
|
|
InitializeParameters();
|
|
|
|
|
|
COTFlowExecuter = new COTPrepareExecuter();
|
|
|
COTFormulaExecuter = new COTFormulaExecuter();
|
|
|
}
|
|
|
|
|
|
private void InitializeCommands()
|
|
|
{
|
|
|
PrepareCommand = new DelegateCommand(OnPrepareCommand);
|
|
|
StartCommand = new DelegateCommand(OnStartCommand);
|
|
|
StopCommand = new DelegateCommand(OnStopCommand);
|
|
|
SelectedFormulaChangedCommand = new DelegateCommand(OnSelectedFormulaChangedCommand);
|
|
|
}
|
|
|
|
|
|
public override void InitializeParameters(object content = null)
|
|
|
{
|
|
|
IsConfirm = false;
|
|
|
WindowTitle = "";
|
|
|
ProgressEnabled = true;
|
|
|
if (timer == null)
|
|
|
{
|
|
|
timer = new System.Timers.Timer();
|
|
|
timer.Interval = 300;
|
|
|
timer.Elapsed += timer_Elapsed;
|
|
|
timer.Stop();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
~COTExecuteViewModule()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
public void LoadDefaultValue()
|
|
|
{
|
|
|
StartLoadTestItem();
|
|
|
}
|
|
|
#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 _StepMessage;
|
|
|
public string StepMessage
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _StepMessage;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_StepMessage = value;
|
|
|
OnPropertyChanged("StepMessage");
|
|
|
}
|
|
|
}
|
|
|
private string _DetailMessage;
|
|
|
public string DetailMessage
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _DetailMessage;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_DetailMessage = value;
|
|
|
OnPropertyChanged("DetailMessage");
|
|
|
}
|
|
|
}
|
|
|
private bool _IsBsr;
|
|
|
public bool IsBsr
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _IsBsr;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_IsBsr = value;
|
|
|
OnPropertyChanged("IsBsr");
|
|
|
}
|
|
|
}
|
|
|
private bool _IsEbr;
|
|
|
public bool IsEbr
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _IsEbr;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_IsEbr = value;
|
|
|
OnPropertyChanged("IsEbr");
|
|
|
}
|
|
|
}
|
|
|
private bool _IsPr1;
|
|
|
public bool IsPr1
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _IsPr1;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_IsPr1 = value;
|
|
|
OnPropertyChanged("IsPr1");
|
|
|
}
|
|
|
}
|
|
|
private bool _IsPr2;
|
|
|
public bool IsPr2
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _IsPr2;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_IsPr2 = value;
|
|
|
OnPropertyChanged("IsPr2");
|
|
|
}
|
|
|
}
|
|
|
private int _ProgressTime;
|
|
|
public int ProgressTime
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _ProgressTime;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_ProgressTime = value;
|
|
|
OnPropertyChanged("ProgressTime");
|
|
|
}
|
|
|
}
|
|
|
private decimal _TotalSecond;
|
|
|
public decimal TotalSecond
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _TotalSecond;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_TotalSecond = value;
|
|
|
OnPropertyChanged("TotalSecond");
|
|
|
}
|
|
|
}
|
|
|
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 bool _ProgressEnabled;
|
|
|
public bool ProgressEnabled
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _ProgressEnabled;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_ProgressEnabled = value;
|
|
|
OnPropertyChanged("ProgressEnabled");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ushort _EBRIOStatus;
|
|
|
public ushort EBRIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _EBRIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_EBRIOStatus = value;
|
|
|
OnPropertyChanged("EBRIOStatus");
|
|
|
}
|
|
|
}
|
|
|
private ushort _BSRIOStatus;
|
|
|
public ushort BSRIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _BSRIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_BSRIOStatus = value;
|
|
|
OnPropertyChanged("BSRIOStatus");
|
|
|
}
|
|
|
}
|
|
|
private ushort _Pr1IOStatus;
|
|
|
public ushort Pr1IOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _Pr1IOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_Pr1IOStatus = value;
|
|
|
OnPropertyChanged("Pr1IOStatus");
|
|
|
}
|
|
|
}
|
|
|
private ushort _Pr2IOStatus;
|
|
|
public ushort Pr2IOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _Pr2IOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_Pr2IOStatus = value;
|
|
|
OnPropertyChanged("Pr2IOStatus");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ushort _MainAxisIOStatus;
|
|
|
public ushort MainAxisIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _MainAxisIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_MainAxisIOStatus = value;
|
|
|
OnPropertyChanged("MainAxisIOStatus");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ushort _WindowStatus;
|
|
|
public ushort WindowStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _WindowStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_WindowStatus = value;
|
|
|
OnPropertyChanged("WindowStatus");
|
|
|
}
|
|
|
}
|
|
|
private ushort _AttractIOStatus;
|
|
|
public ushort AttractIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _AttractIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_AttractIOStatus = value;
|
|
|
OnPropertyChanged("AttractIOStatus");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ushort _PrArmIOStatus;
|
|
|
public ushort PrArmIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _PrArmIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_PrArmIOStatus = value;
|
|
|
OnPropertyChanged("PrArmIOStatus");
|
|
|
}
|
|
|
}
|
|
|
private ushort _EbrArmIOStatus;
|
|
|
public ushort EbrArmIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _EbrArmIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_EbrArmIOStatus = value;
|
|
|
OnPropertyChanged("EbrArmIOStatus");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private ushort _CCRIOStatus;
|
|
|
public ushort CCRIOStatus
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _CCRIOStatus;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_CCRIOStatus = value;
|
|
|
OnPropertyChanged("CCRIOStatus");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Binding Commands
|
|
|
private ICommand _PrepareCommand;
|
|
|
public ICommand PrepareCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _PrepareCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_PrepareCommand = value;
|
|
|
OnPropertyChanged("PrepareCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _StartCommand;
|
|
|
public ICommand StartCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _StartCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_StartCommand = value;
|
|
|
OnPropertyChanged("StartCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _StopCommand;
|
|
|
public ICommand StopCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _StopCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_StopCommand = value;
|
|
|
OnPropertyChanged("StopCommand");
|
|
|
}
|
|
|
}
|
|
|
private ICommand _SelectedFormulaChangedCommand;
|
|
|
public ICommand SelectedFormulaChangedCommand
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
return _SelectedFormulaChangedCommand;
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
_SelectedFormulaChangedCommand = value;
|
|
|
OnPropertyChanged("SelectedFormulaChangedCommand");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Private Methods
|
|
|
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
|
|
{
|
|
|
TimeSpan ts = DateTime.Now - dtStart;
|
|
|
ProgressTime = (int)ts.TotalSeconds;
|
|
|
}
|
|
|
private void StartLoadTestItem()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
isLoading = true;
|
|
|
if (HardFormulas == null)
|
|
|
{
|
|
|
HardFormulas = new ObservableCollection<HardFormulaEntity>();
|
|
|
}
|
|
|
HardFormulas.Clear();
|
|
|
var record = HardFormulaDA.Load(new PagerEntity() { PageIndex = pagenumber, Rows = rows, Conditions = " and StationCode='" + StationCode + "' " });
|
|
|
List<HardFormulaEntity> logs = (List<HardFormulaEntity>)record.rows;
|
|
|
View.Dispatcher.Invoke((Action)(() =>
|
|
|
{
|
|
|
foreach (var s in logs)
|
|
|
{
|
|
|
HardFormulas.Add(s);
|
|
|
}
|
|
|
OnPropertyChanged("HartFormula");
|
|
|
if (HardFormulas.Count > 0)//Ĭ<>ϼ<EFBFBD><CFBC>ص<EFBFBD>һ<EFBFBD><D2BB>
|
|
|
{
|
|
|
SelectedFormula = HardFormulas[0];
|
|
|
LoadFormulaSteps();
|
|
|
}
|
|
|
isLoading = false;
|
|
|
}));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogService.WriteErrorLog(ex);
|
|
|
ShowErrorBox("Error:" + ex.Message);
|
|
|
return;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
CloseProgressView();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnPrepareCommand(Object sender)
|
|
|
{
|
|
|
//if (!Global.InitializeSystemDone)
|
|
|
//{
|
|
|
// ProgressEnabled = true;
|
|
|
// ShowMessageBox("ϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC>δ<EFBFBD><CEB4><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD>ȴ<EFBFBD>");
|
|
|
// return;
|
|
|
//}
|
|
|
if (SelectedFormula == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD>мӹ<D0BC><D3B9><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
COTFlowExecuter.CallBack = (HardFormulaFlowEntity flow, FlowStatus fs, StationStatus stationStatus) =>
|
|
|
{
|
|
|
StepMessage = fs.Message;
|
|
|
if (!string.IsNullOrWhiteSpace(fs.DetailMessage))
|
|
|
{
|
|
|
DetailMessage = DetailMessage + "\r\n" + fs.DetailMessage;
|
|
|
}
|
|
|
};
|
|
|
HardFormulaEntity formula = HardFormulaDA.Load(SelectedFormula.RecId);
|
|
|
if (formula == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ч<EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD>мӹ<D0BC><D3B9><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
if (StationLockControl.StationIsLock(StationCode))
|
|
|
{
|
|
|
ShowMessageBox(HintMessage.StationLocked);
|
|
|
return;
|
|
|
}
|
|
|
StationLockControl.LockStation(StationCode, null);
|
|
|
ProgressEnabled = false;
|
|
|
List<HardFormulaFlowEntity> flows = Global.Flows.FindAll(q => q.StationCode == formula.StationCode && q.IsPrepare);
|
|
|
cancellationTokenSource = new CancellationTokenSource();
|
|
|
Task flowTask = new Task(() =>
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
COTFlowExecuter.Execute(cancellationTokenSource, flows, null, true, false);
|
|
|
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 OnStartCommand(Object sender)
|
|
|
{
|
|
|
//if (!Global.InitializeSystemDone)
|
|
|
//{
|
|
|
// ProgressEnabled = true;
|
|
|
// ShowMessageBox("ϵͳ<CFB5><CDB3>ʼ<EFBFBD><CABC>δ<EFBFBD><CEB4><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD>ȴ<EFBFBD>");
|
|
|
// return;
|
|
|
//}
|
|
|
if (SelectedFormula == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD>мӹ<D0BC><D3B9><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
var status = DeviceControl.GetCardStatus();
|
|
|
if (status != CardStatus.Prepared)
|
|
|
{
|
|
|
Helpering.ShowErrorBox(string.Format("<22><>ʼ<EFBFBD><CABC><EFBFBD>Ῠʧ<E1BFA8>ܣ<EFBFBD><DCA3><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>忨<EFBFBD><E5BFA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
|
|
|
return;
|
|
|
}
|
|
|
if (steps == null || steps.Count <= 0)
|
|
|
{
|
|
|
Helpering.ShowErrorBox(string.Format("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ч<EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD>мӹ<D0BC><D3B9><EFBFBD>"));
|
|
|
return;
|
|
|
}
|
|
|
if (StationLockControl.StationIsLock(StationCode))
|
|
|
{
|
|
|
ShowMessageBox(HintMessage.StationLocked);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
StationLockControl.LockStation(StationCode, null);
|
|
|
COTFormulaExecuter.CallBack = (HardFormulaCOTEntity step, StepStatus ss) =>
|
|
|
{
|
|
|
StepMessage = ss.Message;
|
|
|
if (!string.IsNullOrWhiteSpace(ss.DetailMessage))
|
|
|
{
|
|
|
DetailMessage = DetailMessage + "\r\n" + ss.DetailMessage;
|
|
|
}
|
|
|
if (ss.Status == ExecuteStatusEnum.Start)
|
|
|
{
|
|
|
dtStart = DateTime.Now;
|
|
|
}
|
|
|
if (step != null)
|
|
|
{
|
|
|
TotalSecond = step.StepTime;
|
|
|
|
|
|
IsBsr = step.IsBsr;
|
|
|
IsEbr = step.IsEbr;
|
|
|
IsPr1 = step.IsPr1;
|
|
|
IsPr2 = step.IsPr2;
|
|
|
|
|
|
BSRIOStatus = (ushort)(step.IsBsr ? 1 : 0);
|
|
|
EBRIOStatus = (ushort)(step.IsEbr ? 1 : 0);
|
|
|
Pr1IOStatus = (ushort)(step.IsPr1 ? 1 : 0);
|
|
|
Pr2IOStatus = (ushort)(step.IsPr2 ? 1 : 0);
|
|
|
//MainAxisIOStatus
|
|
|
//WindowStatus
|
|
|
//AttractIOStatus
|
|
|
//PrArmIOStatus
|
|
|
//EbrArmIOStatus
|
|
|
//CCRIOStatus
|
|
|
}
|
|
|
};
|
|
|
cancellationTokenSource = new CancellationTokenSource();
|
|
|
ProgressEnabled = false;
|
|
|
ProgressTime = 0;
|
|
|
dtStart = DateTime.Now;
|
|
|
timer.Start();
|
|
|
Task formulaTask = new Task(() =>
|
|
|
{
|
|
|
ProgressTime = 0;
|
|
|
try
|
|
|
{
|
|
|
//<2F>رճ<D8B1>Ƭ̨<C6AC><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
|
|
|
HardFormulaFlowEntity mapFlow = null;
|
|
|
var flow = HardParameters.GetCotMainAxisIO(StationCode, out mapFlow);
|
|
|
if (flow != null && mapFlow != null)
|
|
|
{
|
|
|
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(mapFlow.NodeId, mapFlow.SlotId, mapFlow.BitNum, 1));
|
|
|
ControlCheck.PMCInvoke(false, "SetPortStatus", null, () => DeviceControl.SetPortStatus(flow.NodeId, flow.SlotId, flow.BitNum, 0));
|
|
|
//<2F>ȴ<EFBFBD>IO<49><4F><EFBFBD><EFBFBD>λ
|
|
|
if ((IOHigh)flow.IsHigh == IOHigh.High || (IOHigh)flow.IsHigh == IOHigh.Low)
|
|
|
{
|
|
|
string refPort = (IOHigh)flow.IsHigh == IOHigh.High ? flow.RefPortHigh : flow.RefPortLow;
|
|
|
bool isTrue = true; // <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>źţ<C5BA><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|
|
if (flow.RefPortHigh == flow.RefPortLow)
|
|
|
{
|
|
|
isTrue = (flow.BitValue == 1);
|
|
|
}
|
|
|
//<2F><><EFBFBD><EFBFBD>false<73><65>ζ<EFBFBD>ų<EFBFBD>ʱ<EFBFBD>˳<EFBFBD>
|
|
|
ControlCheck.WaitDIDone(refPort, isTrue);
|
|
|
}
|
|
|
}
|
|
|
//<2F>ӹ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
|
|
|
List<HardFormulaFlowEntity> flows = Global.Flows.FindAll(q => q.StationCode == StationCode && q.StepCode == string.Format("F{0}52", StationCode));
|
|
|
COTFlowExecuter.Execute(cancellationTokenSource, flows, null, true, false);
|
|
|
COTFormulaExecuter.Execute(cancellationTokenSource, steps, null, false);
|
|
|
//<2F>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
|
|
flows = Global.Flows.FindAll(q => q.StationCode == StationCode && q.IsPrepare);
|
|
|
COTFlowExecuter.Execute(cancellationTokenSource, flows, null, true, true);
|
|
|
if (cancellationTokenSource.IsCancellationRequested)
|
|
|
{
|
|
|
StepMessage = "<22>ֹ<EFBFBD><D6B9><EFBFBD>ֹ!";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
StepMessage = "ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
|
|
}
|
|
|
IsBsr = false;
|
|
|
IsEbr = false;
|
|
|
IsPr1 = false;
|
|
|
IsPr2 = false;
|
|
|
StationLockControl.UnLockStation(StationCode);
|
|
|
ProgressEnabled = true;
|
|
|
timer.Stop();
|
|
|
TotalSecond = 0;
|
|
|
ProgressTime = 0;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
StepMessage = string.Format(" ִ<><D6B4><EFBFBD>쳣:{0}!", ex.Message);
|
|
|
ProgressEnabled = true;
|
|
|
StationLockControl.UnLockStation(StationCode);
|
|
|
}
|
|
|
}, cancellationTokenSource.Token, TaskCreationOptions.LongRunning);
|
|
|
formulaTask.Start();
|
|
|
}
|
|
|
|
|
|
private void OnStopCommand(Object sender)
|
|
|
{
|
|
|
if (cancellationTokenSource != null)
|
|
|
{
|
|
|
StepMessage = "<22><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD>!";
|
|
|
cancellationTokenSource.Cancel();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void OnSelectedFormulaChangedCommand(Object sender)
|
|
|
{
|
|
|
LoadFormulaSteps();
|
|
|
}
|
|
|
|
|
|
private void LoadFormulaSteps()
|
|
|
{
|
|
|
if (SelectedFormula != null)
|
|
|
{
|
|
|
HardFormulaEntity formula = HardFormulaDA.Load(SelectedFormula.RecId);
|
|
|
if (formula == null)
|
|
|
{
|
|
|
ShowMessageBox("<22><>ѡ<EFBFBD><D1A1>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ч<EFBFBD>䷽<EFBFBD>ٽ<EFBFBD><D9BD>мӹ<D0BC><D3B9><EFBFBD>");
|
|
|
return;
|
|
|
}
|
|
|
FlowStatus fs = new FlowStatus();
|
|
|
fs.FlowId = "COTTest";
|
|
|
fs.FlowCode = "COTTest";
|
|
|
fs.Status = ExecuteStatusEnum.Prepare;
|
|
|
fs.StepStatues = new List<StepStatus>();
|
|
|
var record = HardFormulaCOTDA.Load(new PagerEntity() { PageIndex = 1, Rows = 9999, Conditions = " and FormulaId='" + SelectedFormula.RecId + "' " });
|
|
|
steps = (List<HardFormulaCOTEntity>)record.rows;
|
|
|
foreach (var step in steps)
|
|
|
{
|
|
|
StepStatus sb = new StepStatus();
|
|
|
sb.StepId = step.RecId;
|
|
|
sb.StepCode = step.StepCode;
|
|
|
sb.Status = ExecuteStatusEnum.Prepare;
|
|
|
fs.StepStatues.Add(sb);
|
|
|
|
|
|
step.StationCode = formula.StationCode;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|