圖片:
采用MX COMPONENT 界面監視軟元件狀態,用的entryDeviceStatus指令,通訊界面提醒"超出索引"
#region "監視元件狀態"
private void btn_EntryDeviceStatus_Click(object sender, EventArgs e)
{
int iReturnCode; //Return code
String szDeviceName = ""; //List data for 'DeviceName'
int iNumberOfData = 0; //Data for 'DeviceSize'
int iMonitorCycle = 0; //Data for 'MonitorCycle'
int[] arrDeviceValue; //Data for 'DeviceValue'
//Displayed output data is cleared.
ClearDisplay();
//Get the list of 'DeviceName'.
// Join each line(StringType array) of 'DeviceName' by the separator '\n',
// and create a joined string data.
szDeviceName = String.Join("\n", txt_DeviceNameStatus.Lines);
//Check the 'DeviceSize'.(If succeeded, the value is gotten.)
if (!GetIntValue(txt_DeviceSizeStatus, out iNumberOfData))
{
//If failed, this process is end.
return;
}
//Check the 'MonitorCycle'.(If succeeded, the value is gotten.)
if (!GetIntValue(txt_MonitorCycleStatus, out iMonitorCycle))
{
//If failed, this process is end.
return;
}
//Check the 'DeviceValue'.(If succeeded, the value is gotten.)
arrDeviceValue = new int[iNumberOfData];
if (!GetIntArray(txt_DeviceDataStatus, out arrDeviceValue))
{
//If failed, this process is end.
return;
}
//
//Processing of EntryDeviceStatus method
//
try
{
//When ActUtlType is selected by the radio button,
//The EntryDeviceStatus method is executed.
iReturnCode = axActUtlType1.EntryDeviceStatus(szDeviceName,
iNumberOfData,
iMonitorCycle,
ref arrDeviceValue[0]);
}
//Exception processing
catch (Exception exception)
{
MessageBox.Show(exception.Message, Name,
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
//The return code of the method is displayed by the hexadecimal.
txt_ReturnCode.Text = String.Format("0x{0:x8} [HEX]", iReturnCode);
}
#endregion