📄 excep.htm
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>CModbusException Class</title>
</head>
<body bgcolor="#FFFFFF">
<p><font size="5"><strong>CModbusException Class</strong></font></p>
<p><font size="3"><strong>class CModbusException : public </strong></font><a
href="mk:@ivt:vcmfc/D3/S455C.HTM"><strong>CException</strong></a></p>
<p>A CModbusException object represents an exception condition
related to a communication operation whith modbus slave device.
These exceptions include communications exceptions and modbus
functions exceptions, for instance , if you try to preset a
register and the address is invalid, the modbus slave return a
message indicating this invalid operation.</p>
<p>You do not need to create objects of this class, this creation
is intended to be made inside <a href="modbuimp.htm">CModbus
Class</a>.</p>
<p><strong>Constructor</strong> </p>
<p><strong>CModbusException(CString& sMessage,int nError);</strong></p>
<p>parameters </p>
<p>sMessage - String with error Description.</p>
<p>nError - Error number.</p>
<p><strong>example</strong></p>
<p> </p>
<p><font size="2">extern CModbus* pModbus; // this pointer is
created by a derived class. </font></p>
<p><font size="2">pModbus->ThrowException(TRUE);</font></p>
<p><font size="2">try {</font></p>
<blockquote>
<p><font size="2">//It's not needed to verify each call for
errors</font></p>
<p><font size="2">pModbus->ForceSingleCoil(17,172,TRUE) ;
//force coil 173 ON in slave device 17<br>
pModbus->PresetSingleRegister(17,1,3) ; //preset register
40002 to 03 in slave device 17 </font></p>
</blockquote>
<p><font size="2">}</font></p>
<p><font size="2">catch(CModbusException* pException) {</font></p>
<blockquote>
<p><font size="2">TCHAR szCause[255]; </font></p>
<p><font size="2">CString strFormatted; </font></p>
<p><font size="2">pException->GetErrorMessage(szCause,
255); <br>
strFormatted = _T("Modbus Function Error-");</font></p>
<p><font size="2">strFormatted += szCause;
AfxMessageBox(strFormatted);</font></p>
<p><font size="2">AfxMessageBox(strFormatted);</font></p>
<p><font size="2">pException->Delete();</font></p>
</blockquote>
<p><font size="2">}</font></p>
<p> </p>
<p><strong>See also:</strong> <a
href="mk:@ivt:vcmfc/D3/S455C.HTM">CException</a> in MCF library
help files.</p>
<p> </p>
<p> </p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -