XScript Manual · Chapter 20
title: "DIO — digital IO" chapter: 20 images:
- xscript-dio-example.png
DIO — digital IO
IO["name"] accesses a bit registered in the IO Editor. Assignment writes,
bool context reads.
캡처 대기
public/manual/gui/xscript-dio-example.pngBasic example
IO["O_Blow1"] = OFF;
IO["O_Blow2"] = ON;
IO["O_Blow2"].ToggleBit();
if (IO["I_IFReadyPrev"] == false)
{
return false;
}
if (IO["O_DigitalOutput"])
{
// ON
}
else
{
// OFF
}Real-world — continuous-ON wait
From Unit.xms: wait until the sensor is continuously ON for 2 seconds.
if (IO[cnvSensorName].CheckContiOn(2000) == false)
{
return false;
}
Log($"STEP_WaitOrder : {cnvSensorName} detected");Event function hook
FUNCTION LinkCheckFunction()
{
IO["I_U1CnvBowlDetect"].EventFunctionName = "IOEvent_CnvBowlSens";
IO["I_U2CnvBowlDetect"].EventFunctionName = "IOEvent_CnvBowlSens";
}
FUNCTION IOEvent_CnvBowlSens(string name)
{
if (IO[name] == ON)
{
// handle rising edge
}
return true;
}Methods
| Method | Description |
|---|---|
bool ReadBit(void) | Read current bit |
bool WriteBit(bool SetOn) | Write bit |
bool ToggleBit(void) | Flip current value |
bool Wait(bool waitOn, int TimeOut) | Wait for target state (ms) |
bool WaitConti(bool waitOn, int TimeOut, int ContiTime) | Wait until held for ContiTime |
bool CheckContiOn(int timeMsec) | Currently ON for at least timeMsec |
bool CheckContiOff(int timeMsec) | Currently OFF for at least timeMsec |
bool Contains(string keyword) | Name match |
bool InitBoard(void) | Initialize board |
void SetDelayOn(int delay) / void SetDelayOff(int delay) | Debounce delay (ms) |
void RunEventFunction(bool onoff) | Manually trigger event |
void ClearLinkFunction(void) | Detach event hook |
Properties
| Property | Type | Description |
|---|---|---|
Name · ID · Description | string | Identity |
BoardType · Module · Index | Physical | |
GroupName | string | Grouping |
Inverse | bool | Invert signal |
CheckFunctionName · EventFunctionName | string | Hooks |
Message | string | UI hint |
SubModel | string | Model code |
InitOk | bool | Init complete |
Info | string | Debug info |
Tips
- Prefer
Wait(true, timeout)over busy-loopingReadBit(). - Filter chatter with
WaitConti/CheckContiOn·CheckContiOff. - With
Inverse = true, the script already sees the inverted value. - Use
SetDelayOn/Offfor hardware-level debounce.