Home > Net >  Try the return catch the following code, master to help explain, more detailed, the better! Thank yo
Try the return catch the following code, master to help explain, more detailed, the better! Thank yo

Time:11-17

Private ushort [] DeviceReadWords (string device_name, int device_number)
{
Try
{
//デ バ イ ス 読 込 results を そ の ま ま リ タ ー ン す る
Return the App. PlcInOut. DeviceReadWords (device_name, device_number);
}
The catch (Exception ex)
{
//読 込 failed は communication エ ラ ー と し て 処 Richard す る,
LblPLCInterface. BackColor=Color. Red;
LblIPaddress. Text=msSysMsg [4];
MiPLCconnect=false;

Throw new Exception (" Error occurred in the PLC comunication. "+" is \ r \ n "+ ex. Message +" is \ r \ n "+ ex. StackTrace);
}
}

CodePudding user response:

This is a read PLC
App. PlcInOut. DeviceReadWords (device_name, device_number);
To name and number, will return a ushort array, the array should be, the state of the input and output.
As to the calling failure
The background color of the lblPLCInterface red
The test, a line of words showed
And will PLCconnect closed
And returns an error

CodePudding user response:

Agree with above, in addition to "and returns an error", should be if the call fails, throw an abnormal communication

CodePudding user response:

Annotation is not tell you yet, right to be obtained directly back, throw an exception error,

CodePudding user response:

Error when 読 込 failed は communication エ ラ ー と し て 処 Richard す る,
  •  Tags:  
  • C#
  • Related