INT69DC_7C/INT69DC_7C/Forms/FormMotorSetting.cs

2440 lines
110 KiB
C#

using System;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using SmartX;
using INT69DC_ImageDll;
using INT69DC_7C.DialogForms;
namespace INT69DC_7C.Forms
{
public partial class FormMotorSetting : Form
{
#region Field
private FormMain m_ParentForm;
private ImpellerMotorItem CurrentImpellerMotorItem;
private static int SecondAddress = 100;
private string m_DeviceName;
private string m_DeviceAll;
private string m_DNValueForComm;
private int m_SelectImpellerNo;
private string m_SelectImpellerTag;
private bool IsAllDownload;
private string[] ArrayDeviceName;
private string[] ArrayMoonsDeviceName;
private string m_ValueLength;
private string m_CurrentAngle;
private int m_Time;
private int m_GetCountValue;
private int m_Value1Max;
private int m_Value2Max;
private int m_Value3Max;
private int m_Value4Max;
private int m_Value5Max;
private int m_Value6Max;
private string BeforeDirection;
private string AfterDirection;
private Collection<SmartButton> CollectionDirection;
private Collection<SmartButton> CollectionButtonLine;
#endregion
#region Constructor
public FormMotorSetting(FormMain parent)
{
InitializeComponent();
this.ParentForm = parent;
this.CurrentImpellerMotorItem = new ImpellerMotorItem();
}
#endregion
#region Property
public FormMain ParentForm
{
get { return this.m_ParentForm; }
private set { this.m_ParentForm = value; }
}
public string DeviceName
{
get { return this.m_DeviceName; }
set { this.m_DeviceName = value; }
}
public string DeviceAll
{
get { return this.m_DeviceAll; }
set { this.m_DeviceAll = value; }
}
public string DNValueForComm
{
get { return this.m_DNValueForComm; }
set { this.m_DNValueForComm = value; }
}
public int SelectImpellerNo
{
get { return this.m_SelectImpellerNo; }
set { this.m_SelectImpellerNo = value; }
}
public string SelectImpellerTag
{
get { return this.m_SelectImpellerTag; }
set { this.m_SelectImpellerTag = value; }
}
public string ValueLength
{
get { return this.m_ValueLength; }
set { this.m_ValueLength = value; }
}
public string CurrentAngle
{
get { return this.m_CurrentAngle; }
set { this.m_CurrentAngle = value; }
}
public int Time
{
get { return this.m_Time; }
set { this.m_Time = value; }
}
public int GetCountValue
{
get { return this.m_GetCountValue; }
set { this.m_GetCountValue = value; }
}
public int Value6Max
{
get { return this.m_Value6Max; }
set { this.m_Value6Max = value; }
}
public int Value5Max
{
get { return this.m_Value5Max; }
set { this.m_Value5Max = value; }
}
public int Value4Max
{
get { return this.m_Value4Max; }
set { this.m_Value4Max = value; }
}
public int Value3Max
{
get { return this.m_Value3Max; }
set { this.m_Value3Max = value; }
}
public int Value1Max
{
get { return this.m_Value1Max; }
set { this.m_Value1Max = value; }
}
public int Value2Max
{
get { return this.m_Value2Max; }
set { this.m_Value2Max = value; }
}
#endregion
#region Method
private void InitializeDesign()
{
ImageDll images = new ImageDll();
if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Korean)
{
}
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.English)
{
this.labelTitle.Text = "Motor settings";
this.groupBoxSelectImpeller.Text = "Select impeller";
this.groupBoxEachDownload.Text = "Individual motor program download";
this.groupBoxEach.Text = "Individual operation test";
this.groupBoxAll.Text = "Full motion test";
this.groupBoxMotorTest.Text = "Motor test(COM1, RS485)";
this.groupBoxInitialDownload.Text = "Motor program download(COM1, RS485)";
this.groupBoxSelectImpeller.Text = "Line";
this.groupBoxDirection.Text = "Individual motor direction(Default:Normal, Click:Reverse)";
this.groupBoxAngle.Text = "Rotation angle";
this.buttonInitialDownload.Text = "Program download";
this.labelStaticWarning1.Text = "※ Download the program AFTER connecting motor.";
this.labelStaticWarning2.Text = "※ Reset the power then settings will be reflected.";
this.labelStaticWarning3.Text = "※ Turn the power off and back on, proceed with the test.";
this.buttonAllForward.Text = this.buttonEachForward.Text = this.buttonCom1TestForward.Text = "Normal";
this.buttonAllReverse.Text = this.buttonEachReverse.Text = this.buttonCom1TestReverse.Text = "Reverse";
this.buttonAllContinue.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonEachContinue.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllContinue.Text = this.buttonEachContinue.Text = "Consecutively";
this.labelDiscription1.Text = this.labelDiscription2.Text = this.labelDiscription3.Text
= this.labelDiscription4.Text = this.labelDiscription5.Text = this.labelDiscription6.Text = "";
this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenDisable));
this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenDown));
this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engScreenUp));
this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSaveDisable));
this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSaveDown));
this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engSaveUp));
this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDisable));
this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackDown));
this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engBackUp));
this.buttonClearAlarm.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engClearAlarmDisable));
this.buttonClearAlarm.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engClearAlarmDown));
this.buttonClearAlarm.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.engClearAlarmUp));
}
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
{
this.labelTitle.Text = "设置电机";
this.groupBoxSelectImpeller.Text = "选择叶轮";
this.groupBoxEachDownload.Text = "下载已选叶轮个别程序";
this.groupBoxEach.Text = "单独操作测试";
this.groupBoxAll.Text = "整体操作测试";
this.groupBoxMotorTest.Text = "电机测试(COM1, RS485)";
this.groupBoxInitialDownload.Text = "下载的电机程序(COM1, RS485)";
this.groupBoxSelectImpeller.Text = "列";
this.groupBoxDirection.Text = "旋转方向(缺省:正向, 点击:反向)";
this.groupBoxAngle.Text = "旋转角度";
this.buttonInitialDownload.Text = "程序下载";
this.labelStaticWarning1.Text = "※ 请先连接电机后,再下载";
this.labelStaticWarning2.Text = "※ 电源重启后,设置会自动更新";
this.labelStaticWarning3.Text = "※ 关闭电源并重新打开,然后继续测试。";
this.smartLabel1.Text = this.smartLabel8.Text = "※ 点击按钮200ms";
this.buttonAllForward.Text = this.buttonEachForward.Text = this.buttonCom1TestForward.Text = "正向";
this.buttonAllReverse.Text = this.buttonEachReverse.Text = this.buttonCom1TestReverse.Text = "反向";
this.buttonAllContinue.Text = this.buttonEachContinue.Text = "连续旋转";
this.buttonAllUnlock.Text = this.buttonEachUnlock.Text = "解锁";
this.buttonDefault.Text = "缺省";
this.buttonDownloadExistingMotorEach.Text = "下载每个";
this.buttonDownloadExistingMotorAll.Text = "大量下载";
this.labelDiscription1.Text = this.labelDiscription2.Text = this.labelDiscription3.Text
= this.labelDiscription4.Text = this.labelDiscription5.Text = this.labelDiscription6.Text = "";
this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenDisable));
this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenDown));
this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnScreenUp));
this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSaveDisable));
this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSaveDown));
this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnSaveUp));
this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDisable));
this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackDown));
this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnBackUp));
this.buttonClearAlarm.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnClearAlarmDisable));
this.buttonClearAlarm.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnClearAlarmDown));
this.buttonClearAlarm.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.chnClearAlarmUp));
}
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
{
this.labelTitle.Text = "Nastavení motoru";
this.groupBoxSelectImpeller.Text = "Výběr pohonu";
this.groupBoxAll.Text = "Zkouška plného provozu";
this.groupBoxEach.Text = "Zkouška samostatného provozu";
this.groupBoxDirection.Text = "Individuální směr motoru(Standardní:Vpřed, Cvaknutí:Vzad)";
this.groupBoxInitialDownload.Text = "Stažení programu pro motor(COM1, RS485)";
this.groupBoxMotorTest.Text = "Test motoru(COM1, RS485)";
this.groupBoxEachDownload.Text = "Individuální Seřízení";
this.groupBoxSelectImpeller.Text = "Linka";
this.groupBoxAngle.Text = "Úhel natočení";
this.smartLabel1.Text = this.smartLabel8.Text = "※ Stiskněte tlačítko na dobu 200ms";
this.buttonInitialDownload.Text = "Stahování programu";
this.labelStaticWarning1.Text = "※ Program stáhněte AŽ PO připojení motoru.";
this.labelStaticWarning2.Text = "※ Resetujte napájení, poté se načte nastavení.";
this.labelStaticWarning3.Text = "※ Vypněte a znovu zapněte napájení a pokračujte v testování.";
this.buttonDownloadExistingMotorAll.Text = "Stažení(celý)";
this.buttonDownloadExistingMotorEach.Text = "Stažení(každý)";
this.buttonDefault.Text = "Standardní";
this.buttonAllForward.Text = this.buttonEachForward.Text = this.buttonCom1TestForward.Text = "Vpřed";
this.buttonAllReverse.Text = this.buttonEachReverse.Text = this.buttonCom1TestReverse.Text = "Vzad";
this.buttonEachUnlock.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllUnlock.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllUnlock.Text = this.buttonEachUnlock.Text = "Odemknout";
this.buttonAllContinue.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonEachContinue.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllContinue.Text = this.buttonEachContinue.Text = "Nepřetržitě";
this.labelDiscription1.Text = this.labelDiscription2.Text = this.labelDiscription3.Text
= this.labelDiscription4.Text = this.labelDiscription5.Text = this.labelDiscription6.Text = "";
this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenDisable));
this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenDown));
this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeScreenUp));
this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeSaveDisable));
this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeSaveDown));
this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeSaveUp));
this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDisable));
this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackDown));
this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeBackUp));
this.buttonClearAlarm.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeClearAlarmDisable));
this.buttonClearAlarm.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeClearAlarmDown));
this.buttonClearAlarm.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.czeClearAlarmUp));
}
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
{
this.labelTitle.Text = "Motoreinstellung";
this.groupBoxSelectImpeller.Text = "Laufrad wählen";
this.groupBoxEachDownload.Text = "Programmdownload für ausgewähltes Laufrad";
this.groupBoxEach.Text = "Einzelbetriebstest";
this.groupBoxAll.Text = "Gesamtbewegungstest";
this.groupBoxMotorTest.Text = "Motortest(COM1, RS485)";
this.groupBoxInitialDownload.Text = "Motor Programm-Download(COM1, RS485)";
this.buttonDefault.Text = "Standard";
this.buttonDownloadExistingMotorEach.Text = "Herunterladen(jeder)";
this.buttonDownloadExistingMotorAll.Text = "Herunterladen(alle)";
this.groupBoxSelectImpeller.Text = "Reihe";
this.groupBoxDirection.Text = "Drehrichtung(Standard:Vorwärts, Klicken:Rückwärts)";
this.groupBoxAngle.Text = "Drehwinkel";
this.smartLabel1.Text = this.smartLabel8.Text = "※ Taste 200ms gedrückt halten";
this.buttonInitialDownload.Text = "Herunterladen";
this.labelStaticWarning1.Text = "※ Programm lädt erst herunter, NACHDEM ein neuer Motor ANGESCHLOSSEN WURDE";
this.labelStaticWarning2.Text = "※ Damit die Änderungen wirksam werden, das Gerät bitte neu starten (OFF / ON)";
this.labelStaticWarning3.Text = "※ Schalten Sie das Gerät aus und wieder ein und fahren Sie mit dem Test fort.";
this.buttonAllForward.Text = this.buttonEachForward.Text = this.buttonCom1TestForward.Text = "Vorwärts";
this.buttonAllReverse.Text = this.buttonEachReverse.Text = this.buttonCom1TestReverse.Text = "Rückwärts";
this.buttonEachUnlock.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllUnlock.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllUnlock.Text = this.buttonEachUnlock.Text = "Aufsperren";
this.buttonAllContinue.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonEachContinue.Font = new Font("Arial", 9, FontStyle.Bold);
this.buttonAllContinue.Text = this.buttonEachContinue.Text = "Dauerhafter";
this.labelDiscription1.Text = this.labelDiscription2.Text = this.labelDiscription3.Text
= this.labelDiscription4.Text = this.labelDiscription5.Text = this.labelDiscription6.Text = "";
this.buttonScreen.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenDisable));
this.buttonScreen.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenDown));
this.buttonScreen.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerScreenUp));
this.buttonSave.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSaveDisable));
this.buttonSave.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSaveDown));
this.buttonSave.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerSaveUp));
this.buttonBack.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDisable));
this.buttonBack.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackDown));
this.buttonBack.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerBackUp));
this.buttonClearAlarm.DisableImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerClearAlarmDisable));
this.buttonClearAlarm.DownImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerClearAlarmDown));
this.buttonClearAlarm.UpImage = new Bitmap(images.GetImage(ImageDll.ButtonImages.gerClearAlarmUp));
}
else
{
}
}
private void InitializeControl()
{
this.panel1.Location = new Point(0, 211);
this.panel1.Visible = false;
switch (this.ParentForm.SystemConfig.EquipmentColumns)
{
case 7:
this.buttonLine8.Visible = false;
this.buttonLine9.Visible = false;
this.buttonLine10.Visible = false;
this.buttonLine11.Visible = false;
this.buttonLine12.Visible = false;
this.buttonDirectionLine8.Visible = false;
this.buttonDirectionLine9.Visible = false;
this.buttonDirectionLine10.Visible = false;
this.buttonDirectionLine11.Visible = false;
this.buttonDirectionLine12.Visible = false;
break;
case 8:
this.buttonLine9.Visible = false;
this.buttonLine10.Visible = false;
this.buttonLine11.Visible = false;
this.buttonLine12.Visible = false;
this.buttonDirectionLine9.Visible = false;
this.buttonDirectionLine10.Visible = false;
this.buttonDirectionLine11.Visible = false;
this.buttonDirectionLine12.Visible = false;
break;
case 10:
this.buttonLine11.Visible = false;
this.buttonLine12.Visible = false;
this.buttonDirectionLine11.Visible = false;
this.buttonDirectionLine12.Visible = false;
break;
case 12:
break;
default:
break;
}
this.comboBoxTwoStepPassAngle.Items.Clear();
this.comboBoxTwoStepPassAngle.SelectedIndexChanged -= new EventHandler(this.comboBoxTwoStepPassAngle_SelectedIndexChanged);
this.comboBoxTwoStepPassAngle.Items.Add("50");
this.comboBoxTwoStepPassAngle.Items.Add("60");
this.comboBoxTwoStepPassAngle.Items.Add("70");
this.comboBoxTwoStepPassAngle.Items.Add("80");
this.comboBoxTwoStepPassAngle.Items.Add("100");
this.comboBoxTwoStepPassAngle.Items.Add("110");
this.comboBoxTwoStepPassAngle.Items.Add("120");
this.comboBoxTwoStepPassAngle.Items.Add("130");
this.comboBoxTwoStepPassAngle.Items.Add("180");
this.comboBoxTwoStepPassAngle.SelectedIndexChanged += new EventHandler(this.comboBoxTwoStepPassAngle_SelectedIndexChanged);
this.comboBoxTwoStepNGAngle.Items.Clear();
this.comboBoxTwoStepNGAngle.SelectedIndexChanged -= new EventHandler(this.comboBoxTwoStepNGAngle_SelectedIndexChanged);
this.comboBoxTwoStepNGAngle.Items.Add("50");
this.comboBoxTwoStepNGAngle.Items.Add("60");
this.comboBoxTwoStepNGAngle.Items.Add("70");
this.comboBoxTwoStepNGAngle.Items.Add("80");
this.comboBoxTwoStepNGAngle.Items.Add("100");
this.comboBoxTwoStepNGAngle.Items.Add("110");
this.comboBoxTwoStepNGAngle.Items.Add("120");
this.comboBoxTwoStepNGAngle.Items.Add("130");
this.comboBoxTwoStepNGAngle.Items.Add("180");
this.comboBoxTwoStepNGAngle.SelectedIndexChanged += new EventHandler(this.comboBoxTwoStepNGAngle_SelectedIndexChanged);
// 이레텍 모터 + 모드1 + 개별NG 시, 2단회전 불가능
if (this.ParentForm.SystemConfig.StepMotorType == (int)DataStore.StepMotorType.EDB_ALL_P
&& this.ParentForm.SystemConfig.EquipmentMode == 1)
this.Visible2StepRotate(false);
else
this.Visible2StepRotate(true);
this.CurrentAngle = "180";
}
private void DefaultSetting()
{
this.ArrayDeviceName = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L" };
this.ArrayMoonsDeviceName = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<" };
this.CollectionButtonLine = new Collection<SmartButton>();
this.CollectionButtonLine.Clear();
this.CollectionButtonLine.Add(this.buttonLine1);
this.CollectionButtonLine.Add(this.buttonLine2);
this.CollectionButtonLine.Add(this.buttonLine3);
this.CollectionButtonLine.Add(this.buttonLine4);
this.CollectionButtonLine.Add(this.buttonLine5);
this.CollectionButtonLine.Add(this.buttonLine6);
this.CollectionButtonLine.Add(this.buttonLine7);
this.CollectionButtonLine.Add(this.buttonLine8);
this.CollectionButtonLine.Add(this.buttonLine9);
this.CollectionButtonLine.Add(this.buttonLine10);
this.CollectionButtonLine.Add(this.buttonLine11);
this.CollectionButtonLine.Add(this.buttonLine12);
this.CollectionDirection = new Collection<SmartButton>();
this.CollectionDirection.Clear();
this.CollectionDirection.Add(this.buttonDirectionLine1);
this.CollectionDirection.Add(this.buttonDirectionLine2);
this.CollectionDirection.Add(this.buttonDirectionLine3);
this.CollectionDirection.Add(this.buttonDirectionLine4);
this.CollectionDirection.Add(this.buttonDirectionLine5);
this.CollectionDirection.Add(this.buttonDirectionLine6);
this.CollectionDirection.Add(this.buttonDirectionLine7);
this.CollectionDirection.Add(this.buttonDirectionLine8);
this.CollectionDirection.Add(this.buttonDirectionLine9);
this.CollectionDirection.Add(this.buttonDirectionLine10);
this.CollectionDirection.Add(this.buttonDirectionLine11);
this.CollectionDirection.Add(this.buttonDirectionLine12);
}
private void ButtonEnable(bool enable)
{
switch (enable)
{
case true:
this.groupBoxSelectImpeller.Enabled = true;
this.groupBoxDirection.Enabled = true;
this.groupBoxAll.Enabled = true;
this.groupBoxEach.Enabled = true;
this.groupBoxInitialDownload.Enabled = true;
this.groupBoxEachDownload.Enabled = true;
this.groupBoxMotorTest.Enabled = true;
this.buttonScreen.Enabled = true;
this.buttonBack.Enabled = true;
break;
case false:
this.groupBoxSelectImpeller.Enabled = false;
this.groupBoxDirection.Enabled = false;
this.groupBoxAll.Enabled = false;
this.groupBoxEach.Enabled = false;
this.groupBoxInitialDownload.Enabled = false;
this.groupBoxEachDownload.Enabled = false;
this.groupBoxMotorTest.Enabled = false;
this.buttonScreen.Enabled = false;
this.buttonBack.Enabled = false;
break;
}
}
private void MotorAngleControlEnable(bool enable)
{
switch (enable)
{
case true:
this.labelTitlePass.ForeColor = Color.Black;
this.labelTitleNG.ForeColor = Color.Black;
this.labelTwoStepPassAngle.ForeColor = Color.Black;
this.labelTwoStepNGAngle.ForeColor = Color.Black;
this.labelTitleStep1.ForeColor = Color.Black;
this.labelTitleStep2.ForeColor = Color.Black;
this.comboBoxTwoStepPassAngle.ForeColor = Color.Black;
this.comboBoxTwoStepNGAngle.ForeColor = Color.Black;
this.comboBoxTwoStepPassAngle.Enabled = true;
this.comboBoxTwoStepNGAngle.Enabled = true;
break;
case false:
this.labelTitlePass.ForeColor = Color.Gray;
this.labelTitleNG.ForeColor = Color.Gray;
this.labelTwoStepPassAngle.ForeColor = Color.Gray;
this.labelTwoStepNGAngle.ForeColor = Color.Gray;
this.labelTitleStep1.ForeColor = Color.Gray;
this.labelTitleStep2.ForeColor = Color.Gray;
this.comboBoxTwoStepPassAngle.ForeColor = Color.LightGray;
this.comboBoxTwoStepNGAngle.ForeColor = Color.LightGray;
this.comboBoxTwoStepPassAngle.Enabled = false;
this.comboBoxTwoStepNGAngle.Enabled = false;
break;
default:
break;
}
}
private void CreateImpellerFile()
{
if (Directory.Exists(this.ParentForm.PathProgramSaveFolder) == false)
Directory.CreateDirectory(this.ParentForm.PathProgramSaveFolder);
if (File.Exists(this.ParentForm.smartFileIO.FilePathName) == false)
{
this.ParentForm.smartFileIO.Open();
this.ParentForm.smartFileIO.WriteString("PG 1", 0);
this.ParentForm.smartFileIO.WriteString("LB SU", 1);
this.ParentForm.smartFileIO.WriteString("Rc=65", 2);
this.ParentForm.smartFileIO.WriteString("Hc=30", 3);
this.ParentForm.smartFileIO.WriteString("Ms=180", 4);
this.ParentForm.smartFileIO.WriteString("Vi=1000", 5);
this.ParentForm.smartFileIO.WriteString("Vm=180000", 6);
this.ParentForm.smartFileIO.WriteString("A=900000", 7);
this.ParentForm.smartFileIO.WriteString("EM=2", 8);
this.ParentForm.smartFileIO.WriteString("D=A", 9);
this.ParentForm.smartFileIO.WriteString("E", 10);
this.ParentForm.smartFileIO.WriteString("PG", 11);
this.ParentForm.smartFileIO.WriteString("0.4", 12);
this.ParentForm.smartFileIO.WriteString("0.35", 13);
this.ParentForm.smartFileIO.WriteString("36000", 14);
this.ParentForm.smartFileIO.WriteString("10", 15);
this.ParentForm.smartFileIO.WriteString("55", 16);
this.ParentForm.smartFileIO.WriteString("55", 17);
this.ParentForm.smartFileIO.Close();
}
this.CurrentImpellerMotorItem.Initialization();
}
private void SaveImpellerFile(ImpellerMotorItem item)
{
bool fileCheck = false;
this.ParentForm.smartFileIO.FilePathName = this.ParentForm.PathProgramSaveFolder + "Impeller.txt";
FileInfo fileInfo = new FileInfo(this.ParentForm.smartFileIO.FilePathName);
fileCheck = fileInfo.Exists;
if (fileCheck == true)
this.ParentForm.smartFileIO.Open(this.ParentForm.BufferSmartUart);
else
{
this.CreateImpellerFile();
this.ParentForm.smartFileIO.Open(this.ParentForm.BufferSmartUart);
}
// MDrive 모터
this.ParentForm.smartFileIO.WriteString("Rc=" + item.Rc, 2);
this.ParentForm.smartFileIO.WriteString("Hc=" + item.Hc, 3);
this.ParentForm.smartFileIO.WriteString("Ms=" + item.Ms, 4);
this.ParentForm.smartFileIO.WriteString("Vi=" + item.Vi, 5);
this.ParentForm.smartFileIO.WriteString("Vm=" + item.Vm, 6);
this.ParentForm.smartFileIO.WriteString("A=" + item.A, 7);
// Moons 모터
this.ParentForm.smartFileIO.WriteString(item.CC, 12);
this.ParentForm.smartFileIO.WriteString(item.PI, 13);
this.ParentForm.smartFileIO.WriteString(item.EG, 14);
this.ParentForm.smartFileIO.WriteString(item.VE, 15);
this.ParentForm.smartFileIO.WriteString(item.AC, 16);
this.ParentForm.smartFileIO.WriteString(item.DE, 17);
this.ParentForm.smartFileIO.Close();
}
private void LoadImpellerFile()
{
bool fileCheck = false;
string str = "";
this.ParentForm.smartFileIO.FilePathName = this.ParentForm.PathProgramSaveFolder + "Impeller.txt";
FileInfo fileInfo = new FileInfo(this.ParentForm.smartFileIO.FilePathName);
fileCheck = fileInfo.Exists;
if (fileCheck == true)
this.ParentForm.smartFileIO.Open(this.ParentForm.BufferSmartUart);
else
{
this.CreateImpellerFile();
this.ParentForm.smartFileIO.Open(this.ParentForm.BufferSmartUart);
}
// MDrive 모터
str = this.ParentForm.smartFileIO.ReadString(2);
str = str.Substring(str.IndexOf("=") + 1, str.Length - str.IndexOf("=") - 1);
this.CurrentImpellerMotorItem.Rc = str;
str = this.ParentForm.smartFileIO.ReadString(3);
str = str.Substring(str.IndexOf("=") + 1, str.Length - str.IndexOf("=") - 1);
this.CurrentImpellerMotorItem.Hc = str;
str = this.ParentForm.smartFileIO.ReadString(4);
str = str.Substring(str.IndexOf("=") + 1, str.Length - str.IndexOf("=") - 1);
this.CurrentImpellerMotorItem.Ms = str;
str = this.ParentForm.smartFileIO.ReadString(5);
str = str.Substring(str.IndexOf("=") + 1, str.Length - str.IndexOf("=") - 1);
this.CurrentImpellerMotorItem.Vi = str;
str = this.ParentForm.smartFileIO.ReadString(6);
str = str.Substring(str.IndexOf("=") + 1, str.Length - str.IndexOf("=") - 1);
this.CurrentImpellerMotorItem.Vm = str;
str = this.ParentForm.smartFileIO.ReadString(7);
str = str.Substring(str.IndexOf("=") + 1, str.Length - str.IndexOf("=") - 1);
this.CurrentImpellerMotorItem.A = str;
// Moons 모터
try
{
str = this.ParentForm.smartFileIO.ReadString(12);
if (str.Trim() == "")
{
str = this.ParentForm.smartFileIO.ReadString(12);
this.CurrentImpellerMotorItem.CC = "0.4";
}
else
this.CurrentImpellerMotorItem.CC = str;
}
catch
{
this.ParentForm.smartFileIO.WriteString("0.4", 12);
this.CurrentImpellerMotorItem.CC = "0.4";
}
try
{
str = this.ParentForm.smartFileIO.ReadString(13);
if (str.Trim() == "")
{
this.ParentForm.smartFileIO.WriteString("0.35", 13);
this.CurrentImpellerMotorItem.PI = "0.35";
}
else
this.CurrentImpellerMotorItem.PI = str;
}
catch
{
this.ParentForm.smartFileIO.WriteString("0.35", 13);
this.CurrentImpellerMotorItem.PI = "0.35";
}
try
{
str = this.ParentForm.smartFileIO.ReadString(14);
if (str.Trim() == "")
{
this.ParentForm.smartFileIO.WriteString("36000", 14);
this.CurrentImpellerMotorItem.EG = "36000";
}
else
this.CurrentImpellerMotorItem.EG = str;
}
catch
{
this.ParentForm.smartFileIO.WriteString("36000", 14);
this.CurrentImpellerMotorItem.EG = "36000";
}
try
{
str = this.ParentForm.smartFileIO.ReadString(15);
if (str.Trim() == "")
{
this.ParentForm.smartFileIO.WriteString("10", 15);
this.CurrentImpellerMotorItem.VE = "10";
}
else
this.CurrentImpellerMotorItem.VE = str;
}
catch
{
this.ParentForm.smartFileIO.WriteString("10", 15);
this.CurrentImpellerMotorItem.VE = "10";
}
try
{
str = this.ParentForm.smartFileIO.ReadString(16);
if (str.Trim() == "")
{
this.ParentForm.smartFileIO.WriteString("55", 16);
this.CurrentImpellerMotorItem.AC = "55";
}
else
this.CurrentImpellerMotorItem.AC = str;
}
catch
{
this.ParentForm.smartFileIO.WriteString("55", 16);
this.CurrentImpellerMotorItem.AC = "55";
}
try
{
str = this.ParentForm.smartFileIO.ReadString(17);
if (str.Trim() == "")
{
this.ParentForm.smartFileIO.WriteString("55", 17);
this.CurrentImpellerMotorItem.DE = "55";
}
else
this.CurrentImpellerMotorItem.DE = str;
}
catch
{
this.ParentForm.smartFileIO.WriteString("55", 17);
this.CurrentImpellerMotorItem.DE = "55";
}
this.ParentForm.smartFileIO.Close();
}
private void SerialPort1OpenForMotor(int baudrate)
{
if (this.serialPort1.IsOpen == true)
this.serialPort1.Close();
this.serialPort1.BaudRate = baudrate;
this.serialPort1.Open();
}
private void MaxValueAsMotor(int type)
{
switch ((int)type)
{
case (int)DataStore.StepMotorType.MDrive:
this.Value1Max = 100;
this.Value2Max = 100;
this.Value3Max = 200;
this.Value4Max = 999999;
this.Value5Max = 999999;
this.Value6Max = 9999999;
break;
case (int)DataStore.StepMotorType.Moons:
this.Value1Max = 500;
this.Value2Max = 450;
this.Value3Max = 999999;
this.Value4Max = 100;
this.Value5Max = 100;
this.Value6Max = 100;
break;
default:
break;
}
}
private void DisplayAsMotor(int type)
{
this.LoadImpellerFile();
switch ((int)type)
{
case (int)DataStore.StepMotorType.MDrive:
this.buttonClearAlarm.Visible = false;
this.labelTitle1.Text = "Rc"; // Run Current
this.labelTitle2.Text = "Hc"; // Hold Current
this.labelTitle3.Text = "Ms"; // Resolution
this.labelTitle4.Text = "Vi"; // Initial Speed
this.labelTitle5.Text = "Vm"; // Speed
this.labelTitle6.Text = "A"; // Acceleration
this.label1.Text = this.CurrentImpellerMotorItem.Rc;
this.label2.Text = this.CurrentImpellerMotorItem.Hc;
this.label3.Text = this.CurrentImpellerMotorItem.Ms;
this.label4.Text = this.CurrentImpellerMotorItem.Vi;
this.label5.Text = this.CurrentImpellerMotorItem.Vm;
this.label6.Text = this.CurrentImpellerMotorItem.A;
this.buttonDeviceIDChange.Visible = false;
this.buttonInitialDownload.Location = new Point(156, 48);
break;
case (int)DataStore.StepMotorType.Moons:
this.buttonClearAlarm.Visible = true;
this.labelTitle1.Text = "CC"; // Run Current
this.labelTitle2.Text = "PI"; // Hold Current
this.labelTitle3.Text = "EG"; // Resolution
this.labelTitle4.Text = "VE"; // Speed
this.labelTitle5.Text = "AC"; // Acceleration
this.labelTitle6.Text = "DE"; // Deceleration
this.label1.Text = (double.Parse(this.CurrentImpellerMotorItem.CC) * 100).ToString();
this.label2.Text = (double.Parse(this.CurrentImpellerMotorItem.PI) * 100).ToString();
this.label3.Text = this.CurrentImpellerMotorItem.EG;
this.label4.Text = this.CurrentImpellerMotorItem.VE;
this.label5.Text = this.CurrentImpellerMotorItem.AC;
this.label6.Text = this.CurrentImpellerMotorItem.DE;
break;
default:
break;
}
}
private string ReturnAngle(int num)
{
string tempString = "";
switch (num)
{
case 1:
tempString = "60";
break;
case 2:
tempString = "90";
break;
case 3:
tempString = "120";
break;
case 4:
tempString = "180";
break;
case 5:
tempString = "50";
break;
case 6:
tempString = "60";
break;
case 7:
tempString = "70";
break;
case 8:
tempString = "80";
break;
case 9:
tempString = "100";
break;
case 10:
tempString = "110";
break;
case 11:
tempString = "120";
break;
case 12:
tempString = "130";
break;
default:
break;
}
return tempString;
}
public void Visible2StepRotate(bool bValue)
{
this.labelTitleStep1.Visible = bValue;
this.labelTitleStep2.Visible = bValue;
this.labelTitlePass.Visible = bValue;
this.labelTitleNG.Visible = bValue;
this.labelTwoStepPassAngle.Visible = bValue;
this.labelTwoStepNGAngle.Visible = bValue;
this.comboBoxTwoStepPassAngle.Visible = bValue;
this.comboBoxTwoStepNGAngle.Visible = bValue;
}
public void UpdateMotorDirectionDisplay(DataStore.EquipmentStatus status, Collection<string> values)
{
for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
{
this.CollectionDirection[i].Click -= new EventHandler(this.buttonDirection_Click);
if (values[i] == "0") this.CollectionDirection[i].ButtonUp(); else this.CollectionDirection[i].ButtonDown();
if (i == 0)
this.BeforeDirection = values[i];
else
this.BeforeDirection += values[i];
this.CollectionDirection[i].Click += new EventHandler(this.buttonDirection_Click);
}
this.buttonSave.Visible = false;
}
public byte[] SendCommand(Byte Address, Byte Command, Byte Type, Byte Motor, int iValue)
{
byte[] TxBuffer = new byte[9];
int i;
TxBuffer[0] = Address;
TxBuffer[1] = Command;
TxBuffer[2] = Type;
TxBuffer[3] = Motor;
TxBuffer[4] = (byte)((iValue >> 24) & 0xff);
TxBuffer[5] = (byte)((iValue >> 16) & 0xff);
TxBuffer[6] = (byte)((iValue >> 8) & 0xff);
TxBuffer[7] = (byte)(iValue & 0xff);
TxBuffer[8] = 0;
for (i = 0; i < 8; i++)
TxBuffer[8] += TxBuffer[i];
return TxBuffer;
}
/*
MDrive : ID 넣은 후 - 앞뒤 0x0A, ID 넣기 전 - 뒤 0x0D
Eratech : SendCommand로 만들어진 byte array를 바로 전송
Moons : 무조건 뒤 0x0D
*/
public void TransferDirectToEDBMotor(byte[] value)
{
byte[] byteArray = new byte[value.Length + 4];
byte[] length = new byte[4];
length = new UTF8Encoding().GetBytes(value.Length.ToString());
for (int i = 0; i < length.Length; i++)
{
byteArray[i] = length[i];
}
for (int i = 0; i < value.Length; i++)
{
byteArray[i + 4] = value[i];
}
this.ParentForm.TransferDataStream(CommunicationCommand.BypassToMotor, CommunicationID.MainBoard, CommunicationAddress.None, byteArray);
}
public void TransferDirectETX0x0D(string value)
{
string CR = ((char)0x0D).ToString();
string length = string.Format("{0,4}", value.Length + 1);
this.ParentForm.TransferDataStream(CommunicationCommand.BypassToMotor, CommunicationID.MainBoard, CommunicationAddress.None, length + value + CR);
}
public void TransferDirectSTXETX0x0A(string value)
{
string LF = ((char)0x0A).ToString();
string length = string.Format("{0,4}", value.Length + 2);
this.ParentForm.TransferDataStream(CommunicationCommand.BypassToMotor, CommunicationID.MainBoard, CommunicationAddress.None, length + LF + value + LF);
}
private void TransferDirectETX0x0DCOM1(string value)
{
byte[] byteArray = new byte[value.Length + 1];
byte[] bytes = new byte[value.Length];
bytes = new UTF8Encoding().GetBytes(value);
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i] = bytes[i];
}
byteArray[value.Length] = 0x0D;
if(this.serialPort1.IsOpen == true)
this.serialPort1.Write(byteArray, 0, value.Length + 1);
}
private void TransferDirectSTXETX0x0ACOM1(string value)
{
byte[] byteArray = new byte[value.Length + 2];
byte[] bytes = new byte[value.Length];
byteArray[0] = 0x0A;
bytes = new UTF8Encoding().GetBytes(value);
for (int i = 0; i < bytes.Length; i++)
{
byteArray[i + 1] = bytes[i];
}
byteArray[value.Length + 1] = 0x0A;
if (this.serialPort1.IsOpen == true)
this.serialPort1.Write(byteArray, 0, value.Length + 2);
}
public void DisplayRefresh()
{
this.ParentForm.SystemConfig.CurrentForm = DataStore.FormStore.FormMotorSetting;
this.ParentForm.TransferData(CommunicationCommand.ModeIOTest, CommunicationID.MainBoard);
this.ParentForm.smartFileIO.FilePathName = this.ParentForm.PathProgramSaveFolder + "Impeller.txt";
switch (this.ParentForm.SystemConfig.CurrentUser.Group)
{
case DataStore.UserGroup.Level3:
case DataStore.UserGroup.Developer:
this.buttonScreen.Visible = true;
break;
default:
this.buttonScreen.Visible = false;
break;
}
this.buttonLine1.ButtonDown();
this.buttonLine2.ButtonUp();
this.buttonLine3.ButtonUp();
this.buttonLine4.ButtonUp();
this.buttonLine5.ButtonUp();
this.buttonLine6.ButtonUp();
this.buttonLine7.ButtonUp();
this.buttonLine8.ButtonUp();
this.buttonLine9.ButtonUp();
this.buttonLine10.ButtonUp();
this.buttonLine11.ButtonUp();
this.buttonLine12.ButtonUp();
this.radioButtonImpellerMotorAngle60.Click -= new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.radioButtonImpellerMotorAngle90.Click -= new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.radioButtonImpellerMotorAngle120.Click -= new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.radioButtonImpellerMotorAngle180.Click -= new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.comboBoxTwoStepPassAngle.SelectedIndexChanged -= new EventHandler(this.comboBoxTwoStepPassAngle_SelectedIndexChanged);
this.comboBoxTwoStepNGAngle.SelectedIndexChanged -= new EventHandler(this.comboBoxTwoStepNGAngle_SelectedIndexChanged);
this.radioButtonImpellerMotorAngle60.Checked = false;
this.radioButtonImpellerMotorAngle90.Checked = false;
this.radioButtonImpellerMotorAngle120.Checked = false;
this.radioButtonImpellerMotorAngle180.Checked = false;
this.MotorAngleControlEnable(false);
this.comboBoxTwoStepPassAngle.SelectedIndex = 8;
this.comboBoxTwoStepNGAngle.SelectedIndex = 8;
if (this.ParentForm.SystemConfig.ImpellerMotorAnglePass > 0)
{
if (this.ParentForm.SystemConfig.ImpellerMotorAngleNG == 0)
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = this.ParentForm.SystemConfig.ImpellerMotorAnglePass;
if (this.ParentForm.SystemConfig.ImpellerMotorAnglePass == 1)
this.radioButtonImpellerMotorAngle60.Checked = true;
else if (this.ParentForm.SystemConfig.ImpellerMotorAnglePass == 2)
this.radioButtonImpellerMotorAngle90.Checked = true;
else if (this.ParentForm.SystemConfig.ImpellerMotorAnglePass == 3)
this.radioButtonImpellerMotorAngle120.Checked = true;
else
{
this.radioButtonImpellerMotorAngle180.Checked = true;
if (this.ParentForm.SystemConfig.ImpellerMotorAnglePass != 4)
this.comboBoxTwoStepPassAngle.SelectedIndex = this.ParentForm.SystemConfig.ImpellerMotorAnglePass - 5;
if (this.ParentForm.SystemConfig.ImpellerMotorAngleNG != 4)
this.comboBoxTwoStepNGAngle.SelectedIndex = this.ParentForm.SystemConfig.ImpellerMotorAngleNG - 5;
this.MotorAngleControlEnable(true);
}
}
else
{
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = 3;
this.ParentForm.SystemConfig.ImpellerMotorAnglePass = 3;
this.radioButtonImpellerMotorAngle120.Checked = true;
}
this.labelTwoStepPassAngle.Text = (180 - int.Parse(this.comboBoxTwoStepPassAngle.SelectedItem.ToString())).ToString();
this.labelTwoStepNGAngle.Text = (180 - int.Parse(this.comboBoxTwoStepNGAngle.SelectedItem.ToString())).ToString();
this.radioButtonImpellerMotorAngle60.Click += new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.radioButtonImpellerMotorAngle90.Click += new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.radioButtonImpellerMotorAngle120.Click += new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.radioButtonImpellerMotorAngle180.Click += new EventHandler(this.radioButtonImpellerMotorAngle_Click);
this.comboBoxTwoStepPassAngle.SelectedIndexChanged += new EventHandler(this.comboBoxTwoStepPassAngle_SelectedIndexChanged);
this.comboBoxTwoStepNGAngle.SelectedIndexChanged += new EventHandler(this.comboBoxTwoStepNGAngle_SelectedIndexChanged);
this.progressBarExistingDownload.Value = 0;
this.progressBarDownload.Value = 0;
this.progressBarExistingDownload.Value = 0;
this.DeviceName = "A";
this.DeviceAll = "*";
this.DNValueForComm = @"DN=""A""";
this.ValueLength = "";
this.SelectImpellerNo = 1;
this.SelectImpellerTag = "1";
switch (this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.EDB_ALL_P:
this.buttonScreen.Visible = false;
break;
default:
this.buttonScreen.Visible = true;
break;
}
this.Time = 0;
this.buttonSave.Visible = false;
}
#endregion
#region Override Member
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.InitializeDesign();
this.InitializeControl();
this.DefaultSetting();
this.MaxValueAsMotor((int)this.ParentForm.SystemConfig.StepMotorType);
this.DisplayAsMotor((int)this.ParentForm.SystemConfig.StepMotorType);
}
#endregion
#region Event Handler
private void buttonBack_Click(object sender, EventArgs e)
{
this.panel1.Visible = false;
this.buttonSave.Visible = false;
this.ParentForm.ChildFormMenu.DisplayRefresh();
((FormMain)(Owner)).smartForm.Show((int)DataStore.FormStore.FormMenu);
}
private void buttonSelectImpeller_Click(object sender, EventArgs e)
{
SmartX.SmartButton bt = sender as SmartX.SmartButton;
this.SelectImpellerNo = int.Parse(bt.Text.ToString());
this.SelectImpellerTag = bt.Tag.ToString();
if (bt == this.buttonLine1)
{
this.DeviceName = "A";
this.DNValueForComm = @"DN=""A""";
}
else if (bt == this.buttonLine2)
{
this.DeviceName = "B";
this.DNValueForComm = @"DN=""B""";
}
else if (bt == this.buttonLine3)
{
this.DeviceName = "C";
this.DNValueForComm = @"DN=""C""";
}
else if (bt == this.buttonLine4)
{
this.DeviceName = "D";
this.DNValueForComm = @"DN=""D""";
}
else if (bt == this.buttonLine5)
{
this.DeviceName = "E";
this.DNValueForComm = @"DN=""E""";
}
else if (bt == this.buttonLine6)
{
this.DeviceName = "F";
this.DNValueForComm = @"DN=""F""";
}
else if (bt == this.buttonLine7)
{
this.DeviceName = "G";
this.DNValueForComm = @"DN=""G""";
}
else if (bt == this.buttonLine8)
{
this.DeviceName = "H";
this.DNValueForComm = @"DN=""H""";
}
else if (bt == this.buttonLine9)
{
this.DeviceName = "I";
this.DNValueForComm = @"DN=""I""";
}
else if (bt == this.buttonLine10)
{
this.DeviceName = "J";
this.DNValueForComm = @"DN=""J""";
}
else if (bt == this.buttonLine11)
{
this.DeviceName = "K";
this.DNValueForComm = @"DN=""K""";
}
else if (bt == this.buttonLine12)
{
this.DeviceName = "L";
this.DNValueForComm = @"DN=""L""";
}
}
private void labelDownloadValue_Click(object sender, EventArgs e)
{
SmartX.SmartLabel lb = sender as SmartX.SmartLabel;
if (lb == this.label1)
{
#region Run Current, MDrive : 최대 100, Moons : 최대 1.2(표시는 120, 저장은 /100 한 값)
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label1.Text, this.Value1Max.ToString().Length, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0)
{
this.label1.Text = "0";
}
else if (myKeyPad.doubleValue > this.Value1Max)
{
this.label1.Text = this.Value1Max.ToString();
}
else
{
this.label1.Text = myKeyPad.StringValue;
}
}
#endregion
}
else if (lb == this.label2)
{
#region Hold Current, MDrive : 최대 100, Moons : Run Current 값의 90%
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label2.Text, this.Value2Max.ToString().Length, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0)
{
this.label2.Text = "0";
}
else if (myKeyPad.doubleValue > this.Value2Max)
{
this.label2.Text = this.Value2Max.ToString();
}
else
{
this.label2.Text = myKeyPad.StringValue;
}
}
#endregion
}
else if (lb == this.label3) // 마이크로스텝 분해능 제어
{
#region Resolution, MDrive : 최대 256
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label3.Text, this.Value3Max.ToString().Length, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0)
{
this.label3.Text = "0";
}
else if (myKeyPad.doubleValue > this.Value3Max)
{
this.label3.Text = this.Value3Max.ToString();
}
else
{
this.label3.Text = myKeyPad.StringValue;
}
}
#endregion
}
else if (lb == this.label4)
{
#region MDrive : Initial Speed/최대 999999, Moons : Speed/최대 100
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label4.Text, this.Value4Max.ToString().Length, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 1)
{
this.label4.Text = "1";
}
else if (myKeyPad.doubleValue > this.Value4Max)
{
this.label4.Text = this.Value4Max.ToString();
}
else
{
this.label4.Text = myKeyPad.StringValue;
}
}
#endregion
}
else if (lb == this.label5)
{
#region MDrive : Speed/최대 999999, Moons : Acceleration/최대 100
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label5.Text, this.Value5Max.ToString().Length, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 1)
{
this.label5.Text = "1";
}
else if (myKeyPad.doubleValue > this.Value5Max)
{
this.label5.Text = this.Value5Max.ToString();
}
else
{
this.label5.Text = myKeyPad.StringValue;
}
}
#endregion
}
else if (lb == this.label6)
{
#region MDrive : Acceleration/최대 9999999, Moons : Deceleration/최대 100
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.label6.Text, this.Value6Max.ToString().Length, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 0)
{
this.label6.Text = "0";
}
else if (myKeyPad.doubleValue > this.Value6Max)
{
this.label6.Text = this.Value6Max.ToString();
}
else
{
this.label6.Text = myKeyPad.StringValue;
}
}
#endregion
}
}
private void buttonProgramDownload_Click(object sender, EventArgs e)
{
SmartX.SmartButton bt = sender as SmartX.SmartButton;
if (bt == null)
return;
if (bt == this.buttonDownloadExistingMotorEach)
{
this.IsAllDownload = false;
#region 선택된 임펠러 개별 프로그램 다운로드-Each
DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 9);
DialogResult dr = myDlg.ShowDialog();
if (dr == DialogResult.Yes)
{
this.ButtonEnable(false);
this.progressBarExistingDownload.Value = 0;
this.progressBarExistingDownload.Value += 10;
this.timerEachProgramDownload.Enabled = true;
}
#endregion
}
else if (bt == this.buttonDownloadExistingMotorAll)
{
this.IsAllDownload = true;
#region 선택된 임펠러 개별 프로그램 다운로드-All
DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 10);
DialogResult dr = myDlg.ShowDialog();
if (dr == DialogResult.Yes)
{
this.ButtonEnable(false);
this.progressBarExistingDownload.Value = 0;
this.progressBarExistingDownload.Value += 10;
this.timerEachProgramDownload.Enabled = true;
}
#endregion
}
else if (bt == this.buttonDefault)
{
#region 선택된 임펠러 개별 프로그램 다운로드-Default
switch ((int)this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
this.label1.Text = "65";
this.label2.Text = "30";
this.label3.Text = "180";
this.label4.Text = "1000";
this.label5.Text = "180000";
this.label6.Text = "900000";
break;
case (int)DataStore.StepMotorType.Moons:
this.label1.Text = "40";
this.label2.Text = "35";
this.label3.Text = "36000";
this.label4.Text = "10";
this.label5.Text = "55";
this.label6.Text = "55";
break;
default:
break;
}
#endregion
}
else if (bt == this.buttonInitialDownload)
{
#region 프로그램 다운로드
DialogFormYesNo myDlg = new DialogFormYesNo(this.ParentForm.SystemConfig.Language, 11);
DialogResult dr = myDlg.ShowDialog();
if (dr == DialogResult.Yes)
{
this.ButtonEnable(false);
this.progressBarDownload.Value = 0;
this.timerInitialDownload.Enabled = true;
}
#endregion
}
}
private void buttonDeviceIDChange_Click(object sender, EventArgs e)
{
this.ButtonEnable(false);
this.progressBarDownload.Value = 0;
this.timerChangeDeviceNo.Enabled = true;
}
#region 개별동작 테스트
private void buttonEachForwardDirection_Click(object sender, EventArgs e)
{
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, this.DeviceName);
else
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, this.DeviceName);
}
private void buttonEachReverseDirection_Click(object sender, EventArgs e)
{
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, this.DeviceName);
else
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, this.DeviceName);
}
private void buttonEachUnlock_Click(object sender, EventArgs e)
{
string value = "";
if (this.buttonEachUnlock.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
{
if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
this.buttonEachUnlock.Text = "Zamknout";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
this.buttonEachUnlock.Text = "Sperren";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
this.buttonEachUnlock.Text = "锁住";
else
this.buttonEachUnlock.Text = "Lock";
this.buttonBack.Enabled = false;
this.labelIntervalEach.Enabled = false;
this.labelIntervalAll.Enabled = false;
this.buttonEachForward.Enabled = false;
this.buttonEachReverse.Enabled = false;
this.buttonEachContinue.Enabled = false;
this.buttonAllForward.Enabled = false;
this.buttonAllReverse.Enabled = false;
this.buttonAllUnlock.Enabled = false;
this.buttonAllContinue.Enabled = false;
this.buttonDefault.Enabled = false;
this.buttonDownloadExistingMotorEach.Enabled = false;
this.groupBoxEachDownload.Enabled = false;
this.groupBoxInitialDownload.Enabled = false;
this.groupBoxMotorTest.Enabled = false;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = false;
switch (this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
value = "Hc=0";
this.TransferDirectSTXETX0x0A(this.DeviceName + value);
break;
case (int)DataStore.StepMotorType.EDB_ALL_P:
this.TransferDirectToEDBMotor(this.SendCommand((byte)this.SelectImpellerNo, 5, 7, 0, 0));
break;
case (int)DataStore.StepMotorType.Moons:
this.TransferDirectETX0x0D(this.SelectImpellerTag + "PI0");
break;
default:
break;
}
}
else
{
if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
this.buttonEachUnlock.Text = "Odemknout";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
this.buttonEachUnlock.Text = "Aufsperren";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
this.buttonEachUnlock.Text = "解锁";
else
this.buttonEachUnlock.Text = "Unlock";
this.buttonBack.Enabled = true;
this.labelIntervalEach.Enabled = true;
this.labelIntervalAll.Enabled = true;
this.buttonEachForward.Enabled = true;
this.buttonEachReverse.Enabled = true;
this.buttonEachContinue.Enabled = true;
this.buttonAllForward.Enabled = true;
this.buttonAllReverse.Enabled = true;
this.buttonAllUnlock.Enabled = true;
this.buttonAllContinue.Enabled = true;
this.buttonDefault.Enabled = true;
this.buttonDownloadExistingMotorEach.Enabled = true;
this.groupBoxEachDownload.Enabled = true;
this.groupBoxInitialDownload.Enabled = true;
this.groupBoxMotorTest.Enabled = true;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = true;
switch (this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
value = "Hc=" + this.label2.Text.Trim();
this.TransferDirectSTXETX0x0A(this.DeviceName + value);
break;
case (int)DataStore.StepMotorType.EDB_ALL_P:
this.TransferDirectToEDBMotor(this.SendCommand((byte)this.SelectImpellerNo, 5, 7, 0, 20));
break;
case (int)DataStore.StepMotorType.Moons:
this.TransferDirectETX0x0D(this.SelectImpellerTag + "PI" + this.CurrentImpellerMotorItem.PI);
break;
default:
break;
}
}
}
private void buttonEachContinue_Click(object sender, EventArgs e)
{
if (this.buttonEachContinue.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
{
this.timerMotorContinuousEach.Interval = int.Parse(this.labelIntervalEach.Text);
this.timerMotorContinuousEach.Enabled = true;
this.buttonBack.Enabled = false;
this.buttonEachForward.Enabled = false;
this.buttonEachReverse.Enabled = false;
this.buttonEachUnlock.Enabled = false;
this.buttonAllForward.Enabled = false;
this.buttonAllReverse.Enabled = false;
this.buttonAllUnlock.Enabled = false;
this.buttonAllContinue.Enabled = false;
this.buttonDefault.Enabled = false;
this.buttonDownloadExistingMotorEach.Enabled = false;
this.buttonInitialDownload.Enabled = false;
this.groupBoxEachDownload.Enabled = false;
this.groupBoxInitialDownload.Enabled = false;
this.groupBoxMotorTest.Enabled = false;
this.labelIntervalAll.Enabled = false;
this.labelIntervalEach.Enabled = false;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = false;
}
else
{
this.timerMotorContinuousEach.Enabled = false;
this.buttonBack.Enabled = true;
this.buttonEachForward.Enabled = true;
this.buttonEachReverse.Enabled = true;
this.buttonEachUnlock.Enabled = true;
this.buttonAllForward.Enabled = true;
this.buttonAllReverse.Enabled = true;
this.buttonAllUnlock.Enabled = true;
this.buttonAllContinue.Enabled = true;
this.buttonDefault.Enabled = true;
this.buttonDownloadExistingMotorEach.Enabled = true;
this.buttonInitialDownload.Enabled = true;
this.groupBoxEachDownload.Enabled = true;
this.groupBoxInitialDownload.Enabled = true;
this.groupBoxMotorTest.Enabled = true;
this.labelIntervalAll.Enabled = true;
this.labelIntervalEach.Enabled = true;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = true;
}
}
private void labelIntervalEach_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelIntervalAll.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 1000 || myKeyPad.doubleValue > 9999)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
myMsg.ShowDialog();
}
else
{
this.labelIntervalEach.Text = myKeyPad.doubleValue.ToString();
}
}
}
#endregion
#region 전체동작 테스트
private void buttonAllForwardDirection_Click(object sender, EventArgs e)
{
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, CommunicationID.MainBoard);
else
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, CommunicationID.MainBoard);
}
private void buttonAllReverseDirection_Click(object sender, EventArgs e)
{
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, CommunicationID.MainBoard);
else
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, CommunicationID.MainBoard);
}
private void buttonAllUnlock_Click(object sender, EventArgs e)
{
string value = "";
if (this.buttonAllUnlock.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
{
if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
this.buttonAllUnlock.Text = "Zamknout";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
this.buttonAllUnlock.Text = "Sperren";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
this.buttonAllUnlock.Text = "锁住";
else
this.buttonAllUnlock.Text = "Lock";
this.buttonBack.Enabled = false;
this.labelIntervalEach.Enabled = false;
this.labelIntervalAll.Enabled = false;
this.buttonEachForward.Enabled = false;
this.buttonEachReverse.Enabled = false;
this.buttonEachUnlock.Enabled = false;
this.buttonEachContinue.Enabled = false;
this.buttonAllForward.Enabled = false;
this.buttonAllReverse.Enabled = false;
this.buttonAllContinue.Enabled = false;
this.buttonDefault.Enabled = false;
this.buttonDownloadExistingMotorEach.Enabled = false;
this.groupBoxEachDownload.Enabled = false;
this.groupBoxInitialDownload.Enabled = false;
this.groupBoxMotorTest.Enabled = false;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = false;
switch (this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
value = "Hc=0";
this.TransferDirectSTXETX0x0A(this.DeviceAll + value);
break;
case (int)DataStore.StepMotorType.EDB_ALL_P:
this.TransferDirectToEDBMotor(this.SendCommand((byte)this.SelectImpellerNo, 5, 7, 0, 0));
break;
case (int)DataStore.StepMotorType.Moons:
this.TransferDirectETX0x0D("PI0");
break;
default:
break;
}
}
else
{
if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Czech)
this.buttonAllUnlock.Text = "Odemknout";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.German)
this.buttonAllUnlock.Text = "Aufsperren";
else if (this.ParentForm.SystemConfig.Language == DataStore.LanguageID.Chinese)
this.buttonAllUnlock.Text = "解锁";
else
this.buttonAllUnlock.Text = "Unlock";
this.buttonBack.Enabled = true;
this.labelIntervalEach.Enabled = true;
this.labelIntervalAll.Enabled = true;
this.buttonEachForward.Enabled = true;
this.buttonEachReverse.Enabled = true;
this.buttonEachUnlock.Enabled = true;
this.buttonEachContinue.Enabled = true;
this.buttonAllForward.Enabled = true;
this.buttonAllReverse.Enabled = true;
this.buttonAllContinue.Enabled = true;
this.buttonDefault.Enabled = true;
this.buttonDownloadExistingMotorEach.Enabled = true;
this.groupBoxEachDownload.Enabled = true;
this.groupBoxInitialDownload.Enabled = true;
this.groupBoxMotorTest.Enabled = true;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = true;
switch (this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
value = "Hc=" + this.label2.Text.Trim();
this.TransferDirectSTXETX0x0A(this.DeviceAll + value);
break;
case (int)DataStore.StepMotorType.EDB_ALL_P:
this.TransferDirectToEDBMotor(this.SendCommand((byte)this.SelectImpellerNo, 5, 7, 0, 20));
break;
case (int)DataStore.StepMotorType.Moons:
this.TransferDirectETX0x0D("PI" + this.CurrentImpellerMotorItem.PI);
break;
default:
break;
}
}
}
private void buttonAllContinue_Click(object sender, EventArgs e)
{
if (this.buttonAllContinue.ButtonStatus == SmartX.SmartButton.BUTSTATUS.DOWN)
{
this.timerMotorContinuousAll.Interval = int.Parse(this.labelIntervalAll.Text);
this.timerMotorContinuousAll.Enabled = true;
this.buttonBack.Enabled = false;
this.buttonScreen.Enabled = false;
this.buttonEachForward.Enabled = false;
this.buttonEachReverse.Enabled = false;
this.buttonEachUnlock.Enabled = false;
this.buttonEachContinue.Enabled = false;
this.buttonAllForward.Enabled = false;
this.buttonAllReverse.Enabled = false;
this.buttonAllUnlock.Enabled = false;
this.buttonDefault.Enabled = false;
this.buttonDownloadExistingMotorEach.Enabled = false;
this.buttonInitialDownload.Enabled = false;
this.groupBoxEachDownload.Enabled = false;
this.groupBoxInitialDownload.Enabled = false;
this.groupBoxMotorTest.Enabled = false;
this.labelIntervalAll.Enabled = false;
this.labelIntervalEach.Enabled = false;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = false;
}
else
{
this.timerMotorContinuousAll.Enabled = false;
this.buttonBack.Enabled = true;
this.buttonScreen.Enabled = true;
this.buttonEachForward.Enabled = true;
this.buttonEachReverse.Enabled = true;
this.buttonEachUnlock.Enabled = true;
this.buttonEachContinue.Enabled = true;
this.buttonAllForward.Enabled = true;
this.buttonAllReverse.Enabled = true;
this.buttonAllUnlock.Enabled = true;
this.buttonDefault.Enabled = true;
this.buttonDownloadExistingMotorEach.Enabled = true;
this.buttonInitialDownload.Enabled = true;
this.groupBoxEachDownload.Enabled = true;
this.groupBoxInitialDownload.Enabled = true;
this.groupBoxMotorTest.Enabled = true;
this.labelIntervalAll.Enabled = true;
this.labelIntervalEach.Enabled = true;
foreach (SmartButton button in this.CollectionButtonLine)
button.Enabled = true;
}
}
private void labelIntervalAll_Click(object sender, EventArgs e)
{
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelIntervalAll.Text, 4, 0, false, this.ParentForm.SystemConfig.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.doubleValue < 1000 || myKeyPad.doubleValue > 9999)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.SystemConfig.Language);
myMsg.ShowDialog();
}
else
{
this.labelIntervalAll.Text = myKeyPad.doubleValue.ToString();
}
}
}
#endregion
#region Timer
private void timerMotorContinuousEach_Tick(object sender, EventArgs e)
{
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, this.DeviceName);
else
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, this.DeviceName);
}
private void timerMotorContinuousAll_Tick(object sender, EventArgs e)
{
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorReverse, CommunicationID.MainBoard);
else
this.ParentForm.TransferData(CommunicationCommand.ImpellerMotorForward, CommunicationID.MainBoard);
}
private void timerEachProgramDownload_Tick(object sender, EventArgs e)
{
string value = "", str = "";
this.timerEachProgramDownload.Enabled = false;
this.Time += 1;
this.progressBarExistingDownload.Value += 5;
switch ((int)this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
#region MDrive
if (this.Time == 1)
{
value = "CP";
}
else if (this.Time == 2)
{
value = "PG 1";
}
else if (this.Time == 3)
{
value = "LB SU";
}
else if (this.Time == 4) // Rc
{
this.CurrentImpellerMotorItem.Rc = this.label1.Text.Trim();
value = "Rc=" + this.CurrentImpellerMotorItem.Rc;
}
else if (this.Time == 5) // Hc
{
this.CurrentImpellerMotorItem.Hc = this.label2.Text.Trim();
value = "Hc=" + this.CurrentImpellerMotorItem.Hc;
}
else if (this.Time == 6) // Ms
{
//this.CurrentImpellerMotorItem.Ms = this.label3.Text.Trim();
//value = "Ms=" + this.CurrentImpellerMotorItem.Ms;
}
else if (this.Time == 7) // Vi
{
this.CurrentImpellerMotorItem.Vi = this.label4.Text.Trim();
value = "Vi=" + this.CurrentImpellerMotorItem.Vi;
}
else if (this.Time == 8) // Vm
{
this.CurrentImpellerMotorItem.Vm = this.label5.Text.Trim();
value = "Vm=" + this.CurrentImpellerMotorItem.Vm;
}
else if (this.Time == 9) // A
{
this.CurrentImpellerMotorItem.A = this.label6.Text.Trim();
value = "A=" + this.CurrentImpellerMotorItem.A;
}
else if (this.Time == 10)
{
value = "EM=2";
}
else if (this.Time == 11)
{
value = "D=A";
}
else if (this.Time == 12)
{
value = "E";
}
else if (this.Time == 13)
{
value = "PG";
}
else if (this.Time == 14)
{
value = "S";
}
else if (this.Time == 15)
{
value = "ex 1";
this.progressBarExistingDownload.Value = 100;
this.Time = 0;
this.SaveImpellerFile(this.CurrentImpellerMotorItem);
this.ButtonEnable(true);
}
if (value != "")
{
if (this.IsAllDownload == true)
{
for (int i = 0; i < this.ArrayDeviceName.Length; i++)
{
this.TransferDirectSTXETX0x0A(this.ArrayDeviceName[i] + value);
Thread.Sleep(100);
}
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorChangeValueAll, "MDrive" + "/" +
this.CurrentImpellerMotorItem.Rc + "," + this.CurrentImpellerMotorItem.Hc + "," + this.CurrentImpellerMotorItem.Ms + ","
+ this.CurrentImpellerMotorItem.Vi + "," + this.CurrentImpellerMotorItem.Vm + "," + this.CurrentImpellerMotorItem.A);
}
else
{
this.TransferDirectSTXETX0x0A(this.DeviceName + value);
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorChangeValueEach, "MDrive" + "/" + this.DeviceName + "/" +
this.CurrentImpellerMotorItem.Rc + "," + this.CurrentImpellerMotorItem.Hc + "," + this.CurrentImpellerMotorItem.Ms + ","
+ this.CurrentImpellerMotorItem.Vi + "," + this.CurrentImpellerMotorItem.Vm + "," + this.CurrentImpellerMotorItem.A);
}
}
#endregion
break;
case (int)DataStore.StepMotorType.Moons:
#region Moons
if (this.Time == 1)
{
this.CurrentImpellerMotorItem.CC = (double.Parse(this.label1.Text.Trim()) / 100).ToString();
value = "CC" + this.CurrentImpellerMotorItem.CC;
}
else if (this.Time == 2)
{
this.CurrentImpellerMotorItem.PI = (double.Parse(this.label2.Text.Trim()) / 100).ToString();
value = "PI" + this.CurrentImpellerMotorItem.PI;
}
else if (this.Time == 3)
{
//this.CurrentImpellerMotorItem.EG = "36000";
//value = "EG36000";
}
else if (this.Time == 4)
{
this.CurrentImpellerMotorItem.VE = this.label4.Text.Trim();
value = "VE" + this.CurrentImpellerMotorItem.VE;
}
else if (this.Time == 5)
{
this.CurrentImpellerMotorItem.AC = this.label5.Text.Trim();
value = "AC" + this.CurrentImpellerMotorItem.AC;
}
else if (this.Time == 6)
{
this.CurrentImpellerMotorItem.DE = this.label6.Text.Trim();
value = "DE" + this.CurrentImpellerMotorItem.DE;
}
else if (this.Time == 7)
{
value = "SA";
}
else if (this.Time == 8)
{
this.progressBarExistingDownload.Value = 100;
this.Time = 0;
this.SaveImpellerFile(this.CurrentImpellerMotorItem);
this.ButtonEnable(true);
}
if (value != "")
{
if (this.IsAllDownload == true)
{
this.TransferDirectETX0x0D(value);
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorChangeValueAll, "Moons" + "/" +
this.CurrentImpellerMotorItem.CC + "," + this.CurrentImpellerMotorItem.PI + "," + this.CurrentImpellerMotorItem.EG + ","
+ this.CurrentImpellerMotorItem.VE + "," + this.CurrentImpellerMotorItem.AC + "," + this.CurrentImpellerMotorItem.DE);
}
else
{
this.TransferDirectETX0x0D(this.SelectImpellerTag + value);
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorChangeValueEach, "Moons" +"/" + this.SelectImpellerTag + "/" +
this.CurrentImpellerMotorItem.CC + "," + this.CurrentImpellerMotorItem.PI + "," + this.CurrentImpellerMotorItem.EG + ","
+ this.CurrentImpellerMotorItem.VE + "," + this.CurrentImpellerMotorItem.AC + "," + this.CurrentImpellerMotorItem.DE);
}
}
#endregion
break;
default:
break;
}
if (this.Time != 0)
this.timerEachProgramDownload.Enabled = true;
}
private void timerInitialDownload_Tick(object sender, EventArgs e)
{
string value = "";
string str = "";
this.timerInitialDownload.Enabled = false;
this.Time += 1;
this.progressBarDownload.Value += 5;
switch ((int)this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
#region MDrive
switch (this.Time)
{
case 1:
this.SerialPort1OpenForMotor(115200);
value = "*FD";
this.TransferDirectSTXETX0x0ACOM1(value);
break;
case 2:
this.SerialPort1OpenForMotor(9600);
value = "ex 1";
this.TransferDirectETX0x0DCOM1(value);
break;
case 3:
value = "PG 1";
this.TransferDirectETX0x0DCOM1(value);
break;
case 4:
value = "LB SU";
this.TransferDirectETX0x0DCOM1(value);
break;
case 5:
this.CurrentImpellerMotorItem.Rc = this.label1.Text.Trim();
value = "Rc=" + this.label1.Text.Trim();
this.TransferDirectETX0x0DCOM1(value);
break;
case 6:
this.CurrentImpellerMotorItem.Hc = this.label2.Text.Trim();
value = "Hc=" + this.label2.Text.Trim();
this.TransferDirectETX0x0DCOM1(value);
break;
case 7:
this.CurrentImpellerMotorItem.Ms = this.label3.Text.Trim();
value = "Ms=" + this.label3.Text.Trim();
this.TransferDirectETX0x0DCOM1(value);
break;
case 8:
this.CurrentImpellerMotorItem.Vi = this.label4.Text.Trim();
value = "Vi=" + this.label4.Text.Trim();
this.TransferDirectETX0x0DCOM1(value);
break;
case 9:
this.CurrentImpellerMotorItem.Vm = this.label5.Text.Trim();
value = "Vm=" + this.label5.Text.Trim();
this.TransferDirectETX0x0DCOM1(value);
break;
case 10:
this.CurrentImpellerMotorItem.A = this.label6.Text.Trim();
value = "A=" + this.label6.Text.Trim();
this.TransferDirectETX0x0DCOM1(value);
break;
case 11:
value = "EM=2";
this.TransferDirectETX0x0DCOM1(value);
break;
case 12:
value = "D=A";
this.TransferDirectETX0x0DCOM1(value);
break;
case 13:
value = "E";
this.TransferDirectETX0x0DCOM1(value);
break;
case 14:
value = "PG";
this.TransferDirectETX0x0DCOM1(value);
break;
case 15:
value = this.DNValueForComm;
this.TransferDirectETX0x0DCOM1(value);
break;
case 16:
value = "PY=1";
this.TransferDirectETX0x0DCOM1(value);
break;
case 17:
value = this.DeviceName + "BD=11";
this.TransferDirectSTXETX0x0ACOM1(value);
break;
case 18:
value = this.DeviceName + "S";
this.TransferDirectSTXETX0x0ACOM1(value);
break;
case 19:
value = this.DeviceName + "ex 1";
this.TransferDirectSTXETX0x0ACOM1(value);
this.progressBarDownload.Value = 100;
this.SaveImpellerFile(this.CurrentImpellerMotorItem);
this.Time = 0;
this.serialPort1.Close();
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorInitDown, "MDrive");
this.ButtonEnable(true);
break;
default:
break;
}
#endregion
break;
case (int)DataStore.StepMotorType.Moons:
#region Moons
switch (this.Time)
{
case 1:
this.SerialPort1OpenForMotor(9600);
value = "DA" + this.SelectImpellerTag;
break;
case 2:
value = "EG36000";
break;
case 3:
this.CurrentImpellerMotorItem.CC = (double.Parse(this.label1.Text) / 100).ToString();
value = "CC" + this.CurrentImpellerMotorItem.CC;
break;
case 4:
this.CurrentImpellerMotorItem.PI = (double.Parse(this.label2.Text) / 100).ToString();
value = "PI" + this.CurrentImpellerMotorItem.PI;
break;
case 5:
this.CurrentImpellerMotorItem.VE = this.label4.Text.Trim();
value = "VE" + this.label4.Text.Trim();
break;
case 6:
this.CurrentImpellerMotorItem.AC = this.label5.Text.Trim();
value = "AC" + this.label5.Text;
break;
case 7:
this.CurrentImpellerMotorItem.DE = this.label6.Text.Trim();
value = "DE" + this.label6.Text;
break;
case 8:
value = "PR3";
break;
case 9:
value = "BR5";
break;
case 10:
this.SerialPort1OpenForMotor(115200);
value = "SA";
break;
case 11:
this.progressBarDownload.Value = 100;
this.SaveImpellerFile(this.CurrentImpellerMotorItem);
this.Time = 0;
this.serialPort1.Close();
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorInitDown, "Moons");
this.ButtonEnable(true);
break;
default:
break;
}
#endregion
this.TransferDirectETX0x0DCOM1(value);
break;
default:
break;
}
if (this.Time != 0)
this.timerInitialDownload.Enabled = true;
}
private void timerChangeDeviceNo_Tick(object sender, EventArgs e)
{
string value = "";
string str = "";
this.timerChangeDeviceNo.Enabled = false;
this.Time += 1;
this.progressBarDownload.Value += 30;
switch (this.Time)
{
case 1:
this.SerialPort1OpenForMotor(115200);
value = "DA" + this.SelectImpellerTag;
break;
case 2:
value = "SA";
break;
case 3:
this.progressBarDownload.Value = 100;
this.Time = 0;
this.serialPort1.Close();
// Part 11
if (this.ParentForm.SystemConfig.IsPart11 == true)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingOperation.MotorChangeID, "Moons" + "/" + this.SelectImpellerTag);
this.ButtonEnable(true);
break;
default:
break;
}
this.TransferDirectETX0x0DCOM1(value);
if (this.Time != 0)
this.timerChangeDeviceNo.Enabled = true;
}
#endregion
private void buttonCom1TestForward_Click(object sender, EventArgs e)
{
string value = "";
this.SerialPort1OpenForMotor(115200);
switch ((int)this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
value = "MR -" + this.CurrentAngle + "00";
else
value = "MR " + this.CurrentAngle + "00";
this.TransferDirectSTXETX0x0ACOM1(this.DeviceName + value);
break;
case (int)DataStore.StepMotorType.Moons:
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
value = "FL-" + this.CurrentAngle + "00";
else
value = "FL" + this.CurrentAngle + "00";
this.TransferDirectETX0x0DCOM1(this.SelectImpellerTag + value);
break;
default:
break;
}
this.serialPort1.Close();
}
private void buttonCom1TestReverse_Click(object sender, EventArgs e)
{
string value = "";
this.SerialPort1OpenForMotor(115200);
switch ((int)this.ParentForm.SystemConfig.StepMotorType)
{
case (int)DataStore.StepMotorType.MDrive:
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
value = "MR " + this.CurrentAngle + "00";
else
value = "MR -" + this.CurrentAngle + "00";
this.TransferDirectSTXETX0x0ACOM1(this.DeviceName + value);
break;
case (int)DataStore.StepMotorType.Moons:
if (this.ParentForm.SystemConfig.IsImpellerMotorDirectionCW == true)
value = "FL" + this.CurrentAngle + "00";
else
value = "FL-" + this.CurrentAngle + "00";
this.TransferDirectETX0x0D(this.SelectImpellerTag + value);
break;
default:
break;
}
this.serialPort1.Close();
}
private void radioButtonImpellerMotorAngle_Click(object sender, EventArgs e)
{
SmartX.SmartRadioButton rb = sender as SmartX.SmartRadioButton;
if (rb == null)
return;
if (rb == this.radioButtonImpellerMotorAngle180)
this.MotorAngleControlEnable(true);
else
this.MotorAngleControlEnable(false);
if (this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
private void comboBoxTwoStepPassAngle_SelectedIndexChanged(object sender, EventArgs e)
{
this.labelTwoStepPassAngle.Text = (180 - int.Parse(this.comboBoxTwoStepPassAngle.SelectedItem.ToString())).ToString();
if (this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
private void comboBoxTwoStepNGAngle_SelectedIndexChanged(object sender, EventArgs e)
{
this.labelTwoStepNGAngle.Text = (180 - int.Parse(this.comboBoxTwoStepNGAngle.SelectedItem.ToString())).ToString();
if (this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
private void buttonDirection_Click(object sender, EventArgs e)
{
if (this.buttonSave.Visible == false)
this.buttonSave.Visible = true;
}
private void smartForm1_OnSpecialFunctionClick(object sender, EventArgs e)
{
this.ButtonEnable(true);
}
private void buttonClearAlarm_Click(object sender, EventArgs e)
{
this.SerialPort1OpenForMotor(115200);
this.TransferDirectETX0x0D("AX");
this.serialPort1.Close();
}
private void buttonScreen_Click(object sender, EventArgs e)
{
this.progressBarDownload.Value = 0;
this.progressBarExistingDownload.Value = 0;
if (this.panel1.Visible == false)
this.panel1.Visible = true;
else
this.panel1.Visible = false;
}
private void buttonSave_Click(object sender, EventArgs e)
{
string beforeAnglePass = "", afterAnglePass = "";
string beforeAngleNG = "", afterAngleNG = "";
string value = "";
string[] tempArray = new string[12];
string[] array = new string[3];
if (this.buttonDirectionLine1.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[11] = "0"; else tempArray[11] = "1";
if (this.buttonDirectionLine2.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[10] = "0"; else tempArray[10] = "1";
if (this.buttonDirectionLine3.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[9] = "0"; else tempArray[9] = "1";
if (this.buttonDirectionLine4.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[8] = "0"; else tempArray[8] = "1";
if (this.buttonDirectionLine5.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[7] = "0"; else tempArray[7] = "1";
if (this.buttonDirectionLine6.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[6] = "0"; else tempArray[6] = "1";
if (this.buttonDirectionLine7.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[5] = "0"; else tempArray[5] = "1";
if (this.buttonDirectionLine8.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[4] = "0"; else tempArray[4] = "1";
if (this.buttonDirectionLine9.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[3] = "0"; else tempArray[3] = "1";
if (this.buttonDirectionLine10.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[2] = "0"; else tempArray[2] = "1";
if (this.buttonDirectionLine11.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[1] = "0"; else tempArray[1] = "1";
if (this.buttonDirectionLine12.ButtonStatus == SmartButton.BUTSTATUS.UP) tempArray[0] = "0"; else tempArray[0] = "1";
for (int i = 0; i < this.ParentForm.SystemConfig.EquipmentColumns; i++)
{
if (i == 0)
this.AfterDirection = tempArray[11 - i];
else
this.AfterDirection += tempArray[11 - i];
}
for (int i = 0; i < 3; i++)
{
int a = 0;
a = int.Parse(tempArray[i * 4]) * 8 + int.Parse(tempArray[i * 4 + 1]) * 4 + int.Parse(tempArray[i * 4 + 2]) * 2 + int.Parse(tempArray[i * 4 + 3]) * 1;
array[i] = string.Format("{0:00}", a);
}
value = "0" + array[0] + array[1] + array[2];
this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1104_ImpellerMotorIndividualDirection, value);
beforeAnglePass = this.ReturnAngle(this.ParentForm.SystemConfig.ImpellerMotorAnglePass);
beforeAngleNG = this.ReturnAngle(this.ParentForm.SystemConfig.ImpellerMotorAngleNG);
if (this.radioButtonImpellerMotorAngle60.Checked == true)
{
this.ParentForm.SystemConfig.ImpellerMotorAnglePass = 1;
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = 1;
}
else if (this.radioButtonImpellerMotorAngle90.Checked == true)
{
this.ParentForm.SystemConfig.ImpellerMotorAnglePass = 2;
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = 2;
}
else if (this.radioButtonImpellerMotorAngle120.Checked == true)
{
this.ParentForm.SystemConfig.ImpellerMotorAnglePass = 3;
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = 3;
}
else if (this.radioButtonImpellerMotorAngle180.Checked == true)
{
if (this.comboBoxTwoStepPassAngle.SelectedIndex == 8)
this.ParentForm.SystemConfig.ImpellerMotorAnglePass = 4;
else
this.ParentForm.SystemConfig.ImpellerMotorAnglePass = this.comboBoxTwoStepPassAngle.SelectedIndex + 5;
if (this.comboBoxTwoStepNGAngle.SelectedIndex == 8)
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = 4;
else
this.ParentForm.SystemConfig.ImpellerMotorAngleNG = this.comboBoxTwoStepNGAngle.SelectedIndex + 5;
}
afterAnglePass = this.ReturnAngle(this.ParentForm.SystemConfig.ImpellerMotorAnglePass);
afterAngleNG = this.ReturnAngle(this.ParentForm.SystemConfig.ImpellerMotorAngleNG);
// SystemConfig 파일 저장
this.ParentForm.SaveSystemConfigurationFile(this.ParentForm.SystemConfig);
value = Helper.StringZeroFillDigits4(this.ParentForm.SystemConfig.ImpellerMotorAnglePass.ToString());
this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1101_ImpellerMotorAnglePass, value);
value = Helper.StringZeroFillDigits4(this.ParentForm.SystemConfig.ImpellerMotorAngleNG.ToString());
this.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress._1105_ImpellerMotorAngleNG, value);
this.buttonSave.Visible = false;
if (this.BeforeDirection != this.AfterDirection)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.MotorDirection, "", this.BeforeDirection, this.AfterDirection);
if (beforeAnglePass != afterAnglePass)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.MotorAnglePass, "", beforeAnglePass, afterAnglePass);
if (beforeAngleNG != afterAngleNG)
this.ParentForm.SetTrackingHistoryData(DataStore.TrackingParameter.MotorAngleNG, "", beforeAngleNG, afterAngleNG);
}
#endregion
}
}