Initial commit
This commit is contained in:
86
Handler/Project_form2/UIControl/CtlContainer.cs
Normal file
86
Handler/Project_form2/UIControl/CtlContainer.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
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.AzinAxt.Emulator.CEmuleDIO devIO;
|
||||
arDev.AzinAxt.Emulator.CEmulMOT devMOT;
|
||||
|
||||
public CtlContainer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void updateControl()
|
||||
{
|
||||
updateControl(this.Controls);
|
||||
}
|
||||
|
||||
public void setDevice(arDev.AzinAxt.Emulator.CEmuleDIO dio, arDev.AzinAxt.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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user