ITC81DB_2H/ITC81DB_0H/Controls/CenterSystem/ControlCenterSystemBLDCMoto...

220 lines
8.8 KiB
C#

using System;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SmartX;
using ITC81DB_0H.Forms;
using ITC81DB_0H.DialogForms;
using ITC81DB_0H_ImageDll;
namespace ITC81DB_0H.Controls
{
public partial class ControlCenterSystemBLDCMotorSetting : UserControl
{
#region Field
private FormMenu m_ParentForm;
#endregion
#region Constructor
public ControlCenterSystemBLDCMotorSetting(FormMenu parent)
{
InitializeComponent();
this.ParentForm = parent;
this.DefaultSetting();
this.InitializeDesign();
}
#endregion
#region Property
public FormMenu ParentForm
{
get { return this.m_ParentForm; }
private set { this.m_ParentForm = value; }
}
#endregion
#region Method
public void InitializeDesign()
{
Class1 images = new Class1();
if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.English)
{
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Chinese)
{
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Czech)
{
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.Russian)
{
}
else if (this.ParentForm.ParentForm.SystemConfig1.Language == DataStore.LanguageID.German)
{
}
else
{
}
}
private void DefaultSetting()
{
this.comboBoxMotorPoleNum.Items.Clear();
this.comboBoxMotorPoleNum.Items.Add("3");
this.comboBoxMotorPoleNum.Items.Add("6");
this.comboBoxMotorPoleNum.Items.Add("9");
this.comboBoxMotorPoleNum.Items.Add("12");
this.comboBoxMotorPoleNum.Items.Add("15");
}
public void UpdateParameter(BLDCMotorParameter item)
{
this.labelVersionMajor.Text = item.VersionMajor + ".";
this.labelVersionMinor.Text = item.VersionMinor + ".";
this.labelVersionBuild.Text = item.VersionBuild;
this.labelMotorRPM.Text = item.MotorRPM.ToString();
switch (item.MotorDirection)
{
case 0:
this.labelMotorDirectionRead.Text = "None";
break;
case 1:
this.labelMotorDirectionRead.Text = "CW";
break;
case 2:
this.labelMotorDirectionRead.Text = "CCW";
break;
default:
this.labelMotorDirectionRead.Text = "None";
break;
}
switch (item.SelectOperMode)
{
case 0:
this.labelSelectOperMode.Text = "MCU";
break;
case 1:
this.labelSelectOperMode.Text = "Manual";
break;
default:
this.labelMotorDirectionRead.Text = "MCU";
break;
}
}
public void DisplayRefresh(SystemStatus status)
{
this.ParentForm.ParentForm.CurrentSystemStatus.CurrentDisplay = DataStore.DisplayStore.SystemBLDCMotorSetting;
this.ParentForm.ParentForm.SetDisplayMode(DataStore.DisplayMode.Menu);
this.ParentForm.DisplayTitleRoot(this.ParentForm.ParentForm.CurrentSystemStatus);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.BLDCMotorParameterRead, "");
this.labelMotorSpeed.Text = this.ParentForm.ParentForm.BLDCParameter.MotorSpeed.ToString();
this.comboBoxMotorPoleNum.SelectedIndex = this.ParentForm.ParentForm.BLDCParameter.PoleNum;
this.labelAttenuatorRatio.Text = this.ParentForm.ParentForm.BLDCParameter.AttenuatorRatio.ToString();
if (this.ParentForm.ParentForm.BLDCParameter.OperDirection == 1)
this.buttonMotorDirectionWrite.ButtonDown();
else
this.buttonMotorDirectionWrite.ButtonUp();
}
#endregion
#region Event Handler
private void buttonRefresh_Click(object sender, EventArgs e)
{
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Read, CommunicationID.MainBoard, CommunicationAddress.BLDCMotorParameterRead, "");
}
private void labelMotorSpeed_Click(object sender, EventArgs e)
{
string value = "", message = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelMotorSpeed.Text, 3, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue < 0 || myKeyPad.IntValue > 100)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, message);
myMsg.ShowDialog();
}
else
{
this.labelMotorSpeed.Text = myKeyPad.StringValue;
this.ParentForm.ParentForm.BLDCParameter.MotorSpeed = myKeyPad.IntValue;
value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.BLDCParameter.MotorSpeed.ToString());
this.ParentForm.ParentForm.SaveBLDCMotorFile(this.ParentForm.ParentForm.BLDCParameter);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard,
CommunicationAddress.BLDCMotorSpeed, value);
}
}
}
private void comboBoxMotorPoleNum_SelectedIndexChanged(object sender, EventArgs e)
{
string value = "";
this.ParentForm.ParentForm.BLDCParameter.PoleNum = this.comboBoxMotorPoleNum.SelectedIndex;
value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.BLDCParameter.PoleNum.ToString());
this.ParentForm.ParentForm.SaveBLDCMotorFile(this.ParentForm.ParentForm.BLDCParameter);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.BLDCPoleNum, value);
}
private void labelAttenuatorRatio_Click(object sender, EventArgs e)
{
string value = "", message = "";
DialogFormNumKeyPad myKeyPad = new DialogFormNumKeyPad(this.labelAttenuatorRatio.Text, 4, 0, false, this.ParentForm.ParentForm.SystemConfig1.Language);
if (myKeyPad.ShowDialog() == DialogResult.OK)
{
if (myKeyPad.IntValue < 1 || myKeyPad.IntValue > 9999)
{
// 입력범위를 확인하세요
DialogFormMessage myMsg = new DialogFormMessage(1, this.ParentForm.ParentForm.SystemConfig1.Language, message);
myMsg.ShowDialog();
}
else
{
this.labelAttenuatorRatio.Text = myKeyPad.StringValue;
this.ParentForm.ParentForm.BLDCParameter.AttenuatorRatio = myKeyPad.IntValue;
value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.BLDCParameter.AttenuatorRatio.ToString());
this.ParentForm.ParentForm.SaveBLDCMotorFile(this.ParentForm.ParentForm.BLDCParameter);
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.BLDCAttenuatorRatio, value);
}
}
}
private void buttonMotorDirectionWrite_Click(object sender, EventArgs e)
{
string value = "";
if (this.buttonMotorDirectionWrite.ButtonStatus == SmartButton.BUTSTATUS.DOWN)
this.ParentForm.ParentForm.BLDCParameter.OperDirection = 1; // CCW
else
this.ParentForm.ParentForm.BLDCParameter.OperDirection = 0; // CW
this.ParentForm.ParentForm.SaveBLDCMotorFile(this.ParentForm.ParentForm.BLDCParameter);
value = Helper.StringZeroFillDigits4(this.ParentForm.ParentForm.BLDCParameter.OperDirection.ToString());
this.ParentForm.ParentForm.TransferDataStream(CommunicationCommand.Write, CommunicationID.MainBoard, CommunicationAddress.BLDCOperDirection, value);
}
#endregion
}
}