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; namespace Test_AzinMotion { public partial class Form1 : Form { arDev.AzinAxt.MOT mot; arUtil.Log log; Setting setting; public Form1() { InitializeComponent(); mot = new arDev.AzinAxt.MOT(); mot.Init(); log = new arUtil.Log(); setting = new Setting(); setting.Load(); log.RaiseMsg += Log_RaiseMsg; this.FormClosed += Form1_FormClosed; } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { log.Flush(); mot.Dispose(); } private void Log_RaiseMsg(DateTime LogTime, string TypeStr, string Message) { this.logTextBox1.AddMsg(LogTime, TypeStr, Message); } private void Form1_Load(object sender, EventArgs e) { log.Add("프로그램 시작"); if (mot.IsInit == false) log.AddE("모션 초기화 실패(" + mot.errorMessage + ")"); else log.Add("모션 초기화 성공"); this.jogController1.MotionObject = mot; this.jogController1.arAxis = 0; tmDisplay.Start(); tblFG.setItemEnable(true); } private void emulatorToolStripMenuItem_Click(object sender, EventArgs e) { var f = new arDev.AzinAxt.Emulator.fEmulatorM(5, this.mot); mot.Emulator(f.devM); f.Show(); } private void tmDisplay_Tick(object sender, EventArgs e) { lbInit.Text = mot.IsInit ? "Init:OK" : "Init:Error(" + mot.errorMessage + ")"; lbInit.ForeColor = mot.IsInit ? Color.Black : Color.Red; jogController1.UpdateInfo(); jogController1.Invalidate(); if (mot.IsInit == false) { //if (this.tblFG.Enabled == true) tblFG.Enabled = false; } else { //if (tblFG.Enabled == false) tblFG.Enabled = true; //각축별 기본 상태를 표시해준다. for (int axis = 0; axis < 5; axis++) { this.tblFG.setValue(axis + 1, 0, mot.isSERVOON[axis] ? "title" : "orange"); this.tblFG.setTitle(axis + 1, 1, string.Format("{0}mm", mot.dCMDPOS[axis])); this.tblFG.setTitle(axis + 1, 2, string.Format("{0}mm", mot.dACTPOS[axis])); this.tblFG.setValue(axis + 1, 3, mot.isOrg[axis] ? "blue" : "gray"); //MotStatus_Home[axis].BackColor = Pub.mot.isOrg[axis] ? Color.Lime : sbBackColor; this.tblFG.setValue(axis + 1, 4, mot.isLimitN[axis] ? "red" : "gray"); //MotStatus_NLIM[axis].BackColor = Pub.mot.isLimitN[axis] ? Color.Red : sbBackColor; this.tblFG.setValue(axis + 1, 5, mot.isLimitP[axis] ? "red" : "gray"); //MotStatus_PLIM[axis].BackColor = Pub.mot.isLimitP[axis] ? Color.Red : sbBackColor; this.tblFG.setValue(axis + 1, 6, mot.isINP[axis] ? "blue" : "gray"); //MotStatus_INP[axis].BackColor = Pub.mot.isINP[axis] ? Color.Lime : sbBackColor; this.tblFG.setValue(axis + 1, 7, mot.isSERVOAlarm[axis] ? "red" : "gray"); //MotStatus_ALM[axis].BackColor = Pub.mot.isSERVOAlarm[axis] ? Color.Lime : sbBackColor; this.tblFG.setValue(axis + 1, 8, mot.isHomeSet[axis] ? "green" : "gray"); //MotStatus_SVON[axis].BackColor = Pub.mot.isHomeSet[axis] ? Color.Lime : Color.Magenta; } } this.tblFG.Invalidate(); } private void tblFG_ItemClick(object sender, arDev.AzinAxt.GridView.ItemClickEventArgs e) { if(e.Item.row > 0) { jogController1.arAxis = e.Item.row - 1; jogController1.Invalidate(); } } } }