Files
DT_BR_GUI/LFP_Manager/Controls/ucTargetControl.cs
2025-12-17 12:40:51 +09:00

120 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using LFP_Manager.Forms;
using LFP_Manager.DataStructure;
using LFP_Manager.Function;
namespace LFP_Manager.Controls
{
public partial class ucTargetControl : DevExpress.XtraEditors.XtraUserControl
{
public delegate void ButtonEvent(object sender, EventArgs e);
#region VARIABLES
public event ButtonEvent OnConfig = null;
public event ButtonEvent OnStart = null;
#endregion
#region CONSTRUCTORS
public ucTargetControl()
{
InitializeComponent();
lbStatus.Appearance.ForeColor = System.Drawing.Color.Red;
}
#endregion
#region UPDATE DATA
public void UpdateConfig(ref CommConfig Config)
{
string info = "";
switch (Config.CommType)
{
case csConstData.CommType.COMM_UART:
if (Config.UartModelIndex >= csConstData.MODEL_STR.Length)
{
Config.UartModelIndex = 0;
}
info = String.Format("INTERFACE: RS-232 - {0}, MODEL: {1}" //, M-QTY: {2}, PROTOCOL: {2}"
, Config.UartPort
, csConstData.MODEL_STR[Config.UartModelIndex]
);
break;
case csConstData.CommType.COMM_RS485:
if (Config.UartModelIndex >= csConstData.MODEL_STR.Length)
{
Config.UartModelIndex = 0;
}
info = String.Format("INTERFACE: RS-485 - {0}, MODEL: {1}" //, M-QTY: {2}, PROTOCOL: {2}"
, Config.UartPort
, csConstData.MODEL_STR[Config.UartModelIndex]
);
break;
case csConstData.CommType.COMM_SNMP:
if (Config.SnmpModelIndex >= csConstData.MODEL_STR.Length)
{
Config.SnmpModelIndex = 0;
}
info = String.Format("INTERFACE: SNMP - {0}, MODEL: {1}" //, M-QTY: {2}, PROTOCOL: {2}"
, Config.SnmpIP
, csConstData.MODEL_STR[Config.SnmpModelIndex]
);
break;
default:
break;
}
lbTargetInfo.Text = info;
}
public void UpdateStatus(bool flag)
{
if (flag)
{
btnConfig.Enabled = false;
btnStart.Text = "STOP";
lbStatus.Text = "RUN";
lbStatus.Appearance.ForeColor = System.Drawing.Color.Blue;
}
else
{
btnConfig.Enabled = true;
btnStart.Text = "START";
lbStatus.Text = "STOP";
lbStatus.Appearance.ForeColor = System.Drawing.Color.Red;
}
}
#endregion
#region BUTTON EVENT
private void btnConfig_Click(object sender, EventArgs e)
{
OnConfig?.Invoke(sender, e);
}
private void btnStart_Click(object sender, EventArgs e)
{
OnStart?.Invoke(sender, e);
}
#endregion
}
}