ui 변경

This commit is contained in:
backuppc
2025-11-14 16:50:10 +09:00
parent ea3f7a5f2e
commit 0c2f00e79e
2 changed files with 404 additions and 345 deletions

View File

@@ -21,22 +21,9 @@ namespace Test_ACS
InitializeComponent();
InitializeProtocol();
LoadPortList();
InitializeComboBoxes();
}
private void InitializeComboBoxes()
{
// Direction combobox default
if (cmbDirection.Items.Count > 0) cmbDirection.SelectedIndex = 1; // 전진
// Speed combobox default
if (cmbSpeed.Items.Count > 0) cmbSpeed.SelectedIndex = 1; // 보통
cmbMotDirection.SelectedIndex = 0;
cmbMagDirection.SelectedIndex = 0;
cmbAutoSpeed.SelectedIndex = 0;
}
private void InitializeProtocol()
{
@@ -281,13 +268,18 @@ namespace Test_ACS
private void btnManual_Click(object sender, EventArgs e)
{
// Manual: data = TargetID(2 hex) + Direction(1 byte) + Speed(1 byte) + Runtime(1 byte)
var targetID = selectedAGV.ToString("X2");
var direction = (byte)cmbDirection.SelectedIndex;
var speed = (byte)cmbSpeed.SelectedIndex;
var runtime = (byte)numRuntime.Value;
var but = sender as Button;
if (but.Tag == null) return;
var tagstr = but.Tag.ToString();
var dataBytes = new byte[] { direction, speed, runtime };
var targetID = selectedAGV.ToString("X2");
var direction = byte.Parse(tagstr);// //back
var speed = (byte)0;// cmbSpeed.SelectedIndex;
if (radSpdM.Checked) speed = 1;
else if (radSpdH.Checked) speed = 2;
var dataBytes = new byte[] { direction, speed };
var dataStr = targetID + string.Join("", dataBytes.Select(b => b.ToString("X2")));
SendCommand(AGVCommandHE.Manual, dataStr);
}
@@ -544,15 +536,33 @@ namespace Test_ACS
private void btAMove_Click(object sender, EventArgs e)
{
// Manual: data = TargetID(2 hex) + Direction(1 byte) + Speed(1 byte) + Runtime(1 byte)
var targetID = selectedAGV.ToString("X2");
var Motdirection = (byte)cmbMotDirection.SelectedIndex;
var Magdirection = (byte)cmbMagDirection.SelectedIndex;
var speed = (byte)cmbAutoSpeed.SelectedIndex;
byte Motdirection = 0;// (byte)cmbMotDirection.SelectedIndex;
if (radForw.Checked) Motdirection = 1;
byte Magdirection = 0;
if (radLeft.Checked) Magdirection = 1;
else if (radRight.Checked) Magdirection = 2;
byte speed = 0;// (byte)cmbAutoSpeed.SelectedIndex;
if (radSpdM.Checked) speed = 1;
else if (radSpdH.Checked) speed = 2;
var dataBytes = new byte[] { Motdirection, Magdirection, speed };
var dataStr = targetID + string.Join("", dataBytes.Select(b => b.ToString("X2")));
SendCommand(AGVCommandHE.AutoMove, dataStr);
}
private void button2_Click(object sender, EventArgs e)
{
// Stop: data = TargetID(2 hex)
var targetID = selectedAGV.ToString("X2");
SendCommand(AGVCommandHE.Stop, targetID);
}
private void groupBox2_Enter(object sender, EventArgs e)
{
}
}
}