Files
ATV_STDLabelAttach/Handler/Project/UIControl/CtlContainer.cs
2025-07-17 16:11:46 +09:00

87 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace UIControl
{
public partial class CtlContainer : GroupBox
{
arDev.AjinEXTEK.Emulator.CEmuleDIO devIO;
arDev.AjinEXTEK.Emulator.CEmulMOT devMOT;
public CtlContainer()
{
InitializeComponent();
}
public void updateControl()
{
updateControl(this.Controls);
}
public void setDevice(arDev.AjinEXTEK.Emulator.CEmuleDIO dio, arDev.AjinEXTEK.Emulator.CEmulMOT mot)
{
this.devIO = dio;
this.devMOT = mot;
}
public void updateControl(System.Windows.Forms.Control.ControlCollection ctl)
{
if (devIO == null && devMOT == null) throw new Exception("디바이스(IO/MOT)가 설정되지 않았습니다");
foreach (Control c in ctl)
{
if (c.HasChildren)
{
updateControl(c.Controls);
}
else if (c is UIControl.CtlBase)
{
var cc = c as UIControl.CtlBase;
foreach (var pin in cc.PinList)
{
if (pin.PinIndex != -1)
{
if (pin.ValueDirection == UIControl.eValueDirection.input)
{
//io의 값을 컨트롤에 적용해줘야한다
if (pin.Output)
{
pin.Raw = devIO.Output[pin.PinIndex];
}
else
{
pin.Raw = devIO.Input[pin.PinIndex];
}
}
else
{
//컨트롤의 값을 io에 적용해줘야 한다
if (pin.Output)
{
//devIO.Output[pin.PinIndex] = pin.Value;
devIO.SetOutput(pin.PinIndex, pin.Value);
}
else
{
// devIO.Input[pin.PinIndex] = pin.Value;
devIO.SetInput(pin.PinIndex, pin.Value);
}
}
}
}
cc.UpdateValue();
cc.Invalidate();
}
}
}
}
}