123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using SecsGem.Core;
- using SecsGem.Core.ItemModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace EapClientSimulator
- {
- /// <summary>
- /// ULpControl.xaml 的交互逻辑
- /// </summary>
- public partial class ULpControl : UserControl
- {
- private string sequence= System.Configuration.ConfigurationManager.AppSettings.Get("defaultSequence");
- public event EventHandler<string> OnSendMessage;
- public ULpControl()
- {
- InitializeComponent();
- }
- string portId = "";
- string jobId = "";
- string lotId = "";
- private void btnLoadId_Click(object sender, RoutedEventArgs e)
- {
- PortCommand("Load");
- }
- private void btnReadId_Click(object sender, RoutedEventArgs e)
- {
- PortCommand("ReadID");
- }
- FrmSequence frmSequence = null;
- private void btnPPSelect_Click(object sender, RoutedEventArgs e)
- {
- frmSequence = new FrmSequence(portId, jobId, lotId,sequence);
- frmSequence.OnUpdateSequence += FrmSequence_OnUpdateSequence;
- frmSequence.OnSendMessage += FrmSequence_OnSendMessage;
- frmSequence.ShowDialog();
- }
- private void FrmSequence_OnUpdateSequence(object sender, string e)
- {
- sequence = e;
- }
- private void FrmSequence_OnSendMessage(object sender, string e)
- {
- if(OnSendMessage!=null)
- {
- OnSendMessage(sender, e);
- }
- }
- private void btnStart_Click(object sender, RoutedEventArgs e)
- {
- JobCommand("StartJob");
- }
- private void btnStop_Click(object sender, RoutedEventArgs e)
- {
- JobCommand("StopJob");
- }
- private void btnAbort_Click(object sender, RoutedEventArgs e)
- {
- JobCommand("AbortJob");
- }
- private void btnResume_Click(object sender, RoutedEventArgs e)
- {
- JobCommand("ResumeJob");
- }
- private void btnPause_Click(object sender, RoutedEventArgs e)
- {
- JobCommand("PauseJob");
- }
- private void JobCommand(string command)
- {
- RemoteCommand remoteCommand = new RemoteCommand();
- remoteCommand.Command = command;
- RemoteParameter remoteParameter = new RemoteParameter();
- remoteParameter.Name = "JobID";
- remoteParameter.Value = new StringItem(SecsGem.Core.DataFormat.Ascii, jobId);
- remoteCommand.RemoteParameters.Add(remoteParameter);
- SecsGem.Core.SecsMessage secsMessage = SecsMessageSendUtil.CreateS2F49Message(remoteCommand);
- if (GlobalData.Client != null)
- {
- GlobalData.Client.SendMessage(secsMessage);
- }
- if (OnSendMessage != null)
- {
- OnSendMessage(this, SmlSerializationUtil.SerializeItemToString(secsMessage));
- }
- }
- private void UserControl_Loaded(object sender, RoutedEventArgs e)
- {
- portId = this.Name.Substring(this.Name.Length - 1);
- jobId = "Job_" + portId;
- lotId = "C00" + portId;
- }
- private void btnUnload_Click(object sender, RoutedEventArgs e)
- {
- PortCommand("UnLoad");
- }
- private void PortCommand(string command)
- {
- RemoteCommand remoteCommand = new RemoteCommand();
- remoteCommand.Command = command;
- RemoteParameter remoteParameter = new RemoteParameter();
- remoteParameter.Name = "PortID";
- remoteParameter.Value = new StringItem(SecsGem.Core.DataFormat.Ascii, portId);
- remoteCommand.RemoteParameters.Add(remoteParameter);
- SecsGem.Core.SecsMessage secsMessage = SecsMessageSendUtil.CreateS2F49Message(remoteCommand);
- if (GlobalData.Client != null)
- {
- GlobalData.Client.SendMessage(secsMessage);
- }
- if (OnSendMessage != null)
- {
- OnSendMessage(this, SmlSerializationUtil.SerializeItemToString(secsMessage));
- }
- }
- private void btnMapCassette_Click(object sender, RoutedEventArgs e)
- {
- PortCommand("MapCassette");
- }
- }
- }
|