using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using Aitex.Core.RT.Simulator; namespace Aitex.Core.Backend { public partial class DICtrl : UserControl { //public Action SetSimulatorValue; //private string _ioName; //private bool _rawValue; //private string _group; public string IOName { get; set; } public bool RawValue { get; private set; } public string LabelName { get => this.labelRaw.Text; set => this.labelRaw.Text = value; } public DICtrl() { InitializeComponent(); } //public void SetIoName(string group, string ioName) //{ // _ioName = ioName; // _group = group; //} //public void SetName(string name) //{ // this.labelRaw.Text = name; //} public void SetValue(bool latchedValue, bool rawValue) { RawValue = rawValue; //this.labelValue.BackColor = latchedValue ? Color.Lime : Color.LightGray; this.labelRaw.BackColor = rawValue ? Color.Lime : Color.LightGray; } /* public void SetValue(bool latchedValue, bool rawValue, bool force) { //if ((this.labelName.BackColor == Color.Lime) == value) // return; this.labelName.BackColor = latchedValue ? Color.Lime : Color.LightGray; this.labelName.ForeColor = (latchedValue != rawValue) ? Color.Red : Color.Black; if (!force) { this.rbtAuto.BackColor = Color.LightGray; this.rbt0.BackColor = Color.LightGray; this.rbt1.BackColor = Color.LightGray; } else { if (latchedValue) { this.rbtAuto.BackColor = Color.LightGray; this.rbt0.BackColor = Color.LightGray; this.rbt1.BackColor = Color.Red; } else { this.rbtAuto.BackColor = Color.LightGray; this.rbt0.BackColor = Color.Red; this.rbt1.BackColor = Color.LightGray; } } } public bool? GetValue() { if (rbtAuto.Checked) return null; else if (rbt0.Checked) return false; else if (rbt1.Checked) return true; return null; }*/ private void rbtAuto_CheckedChanged(object sender, EventArgs e) { //if (((RadioButton)sender).Checked) //{ // if (Reactor.IsSimulation) // Simulation.Sim_TcAdsClient.Instance.DI_Forced[(int)Tag] = false; //} } private void rbt1_CheckedChanged(object sender, EventArgs e) { //if (((RadioButton)sender).Checked) //{ // if (Reactor.IsSimulation) // { // Simulation.Sim_TcAdsClient.Instance.DI_Forced[(int)Tag] = true; // Simulation.Sim_TcAdsClient.Instance.INPUT.DI[(int)Tag] = 1; // } //} } private void rbt0_CheckedChanged(object sender, EventArgs e) { //if (((RadioButton)sender).Checked) //{ // if (Reactor.IsSimulation) // { // Simulation.Sim_TcAdsClient.Instance.DI_Forced[(int)Tag] = true; // Simulation.Sim_TcAdsClient.Instance.INPUT.DI[(int)Tag] = 0; // } //} } private void labelName_Click(object sender, EventArgs e) { } //private void ButtonSet_Click(object sender, EventArgs e) //{ // if (SetSimulatorValue != null) // SetSimulatorValue(_ioName, !_rawValue); //} private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (checkBox1.Checked) { checkBox2.Checked = RawValue; DiForce.Instance.Set(IOName, checkBox2.Checked); checkBox2.Enabled = true; this.BackColor = Color.DodgerBlue; } else { DiForce.Instance.Unset(IOName); checkBox2.Enabled = false; this.BackColor = Color.White; } } private void checkBox2_CheckedChanged(object sender, EventArgs e) { DiForce.Instance.Set(IOName, checkBox2.Checked); } } }