100 lines
3.1 KiB
C#
100 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Project.StateMachine;
|
|
using COMM;
|
|
using AR;
|
|
|
|
namespace Project.ViewForm
|
|
{
|
|
public partial class fAuto : Form
|
|
{
|
|
public fAuto()
|
|
{
|
|
InitializeComponent();
|
|
this.FormClosed += FAuto_FormClosed;
|
|
PUB.sm.StepChanged += Sm_StepChanged;
|
|
this.ctlAuto1.ButtonClick += CtlAuto1_ButtonClick;
|
|
if (PUB.sm.Step == eSMStep.INIT || PUB.sm.Step == eSMStep.SYNC)
|
|
this.ctlAuto1.Scean = CtlAuto.eScean.Progress;
|
|
else
|
|
this.ctlAuto1.Scean = CtlAuto.eScean.Normal;
|
|
}
|
|
private void fAuto_Load(object sender, EventArgs e)
|
|
{
|
|
ctlAuto1.dev_agv = PUB.AGV;
|
|
// ctlAuto1.dev_plc = PUB.PLC;
|
|
ctlAuto1.dev_bms = PUB.BMS;
|
|
ctlAuto1.dev_xbe = PUB.XBE;
|
|
this.timer1.Start();
|
|
}
|
|
|
|
private void CtlAuto1_ButtonClick(CtlAuto.UIButton idx)
|
|
{
|
|
if (idx.cmd.Equals("EMG"))
|
|
{
|
|
PUB.log.Add("ui reset click");
|
|
PUB.AGV.AGVErrorReset();
|
|
}
|
|
}
|
|
|
|
private void Sm_StepChanged(object sender, StateMachine.StateMachine.StepChangeEventArgs e)
|
|
{
|
|
if (e.New == eSMStep.INIT || e.New == eSMStep.SYNC)
|
|
this.ctlAuto1.Scean = CtlAuto.eScean.Progress;
|
|
else
|
|
this.ctlAuto1.Scean = CtlAuto.eScean.Normal;
|
|
}
|
|
|
|
private void FAuto_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
timer1.Stop();
|
|
PUB.sm.StepChanged -= Sm_StepChanged;
|
|
this.ctlAuto1.ButtonClick -= CtlAuto1_ButtonClick;
|
|
}
|
|
|
|
bool tmrun = false;
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
if (this.Visible == false) return;
|
|
if (tmrun == true) return;
|
|
tmrun = true;
|
|
|
|
this.ctlAuto1.OnUpdateMode = true;
|
|
|
|
if (this.ctlAuto1.Scean == CtlAuto.eScean.Progress)
|
|
{
|
|
ctlAuto1.ProgressVal = PUB.Result.SMSG_ProgressValue;
|
|
ctlAuto1.ProgressMax = PUB.Result.SMSG_ProgressMax;
|
|
ctlAuto1.StatusMessage = VAR.STR?.Get(eVarString.StatusMessage) ?? string.Empty;
|
|
}
|
|
this.ctlAuto1.StopMessage = string.Empty;
|
|
|
|
if (PUB.sm.Step == StateMachine.eSMStep.RUN)
|
|
{
|
|
this.ctlAuto1.runStep = PUB.sm.RunStep;
|
|
}
|
|
else
|
|
{
|
|
this.ctlAuto1.runStep = ERunStep.READY;
|
|
}
|
|
this.ctlAuto1.OnUpdateMode = false;
|
|
this.ctlAuto1.Invalidate();
|
|
tmrun = false;
|
|
}
|
|
|
|
private void fAuto_VisibleChanged(object sender, EventArgs e)
|
|
{
|
|
this.timer1.Enabled = this.Visible;
|
|
if (timer1.Enabled) timer1.Start();
|
|
else timer1.Stop();
|
|
}
|
|
}
|
|
}
|