123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- 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<string, bool> 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);
- }
- }
- }
|