cml_io.h
来自「美国COPLEY驱动器,程序开发工具之一.」· C头文件 代码 · 共 1,236 行 · 第 1/5 页
H
1,236 行
/// is the period between node guarding request messages sent by the master
/// controller.
///
/// Note that both this parameter, and the life time factor must be non-zero for
/// node guarding to be used.
///
/// Default 0 (ms)
uint16 guardTime;
/// Node guarding life time factor
///
/// When the node guarding protocol is used, this parameter is used by the slave
/// device to determine how long to wait for a node guarding request from the
/// master controller before signaling an error condition.
///
/// The life time factor is treated as a multiple of the guard time.
///
/// If this parameter and the node guard time are both non-zero,
/// and the heartbeatTime is zero, then node guarding will be setup
/// for the amplifier.
///
/// Default 3 (multiples of the guard time)
uint8 lifeFactor;
/// Use the standard digital input PDO object. If true (default) then
/// a standard PDO object will be configured to read up to 64 digital
/// inputs any time one of them changes. If false, then this PDO
/// will not be configured.
bool useStandardDinPDO;
/// Use the standard digital output PDO object. If true (default) then
/// a standard PDO object will be configured to transmit updated settings
/// for the first 64 digital output pins when any of them are changed.
/// If false, no such PDO will be configured.
bool useStandardDoutPDO;
/// Use the standard analog input PDO objects. If true (default) then
/// up to three standard PDO objects will be configured to read the
/// first 12 16-bit analog input pins when they generate events.
/// If false, then these PDOs will not be configured.
bool useStandardAinPDO;
/// Use the standard analog output PDO objects. If true (default) then
/// up to three standard PDO objects will be configured to transmit the
/// analog output data for up to 12 16-bit analog outputs.
/// If false, then these PDOs will not be configured.
bool useStandardAoutPDO;
IOModuleSettings( void )
{
heartbeatPeriod = 0;
heartbeatTimeout = 100;
guardTime = 0;
lifeFactor = 3;
useStandardDinPDO = true;
useStandardDoutPDO = true;
useStandardAinPDO = true;
useStandardAoutPDO = true;
}
};
/***************************************************************************/
/**
Standard CANopen I/O module. This class represents and I/O module device
conforming to the DS401 CANopen specification. The class may be extended
to provide additional manufacturer specific features.
Note that the CANopen standard defines a very large number of parameters that
may be used with a standard I/O module. Of these, only a small subset are
requred by the spec. In practice, it seems that most of the major manufacturers
of CANopen I/O modules only implement the minimum required by the spec. The
result is that many of the optional functions have not been tested with real
hardware due to the lack of availability. Please contact Copley Controls if
you believe that you have found a problem with any of these functions.
For the typical I/O module, you can expect the following functionality to be
supported based on the type of I/O the module supports:
Digital Inputs: Reading the inputs via PDO or SDO in groups of 8 should be
supported. Other features are optional.
Digital Outputs: Writing to the outputs via PDO or SDO in groups of 8 should
be supported. Other features are optional.
Analog Inputs: Reading 16-bit analog inputs via PDO or SDO is normally supported.
Other input sizes and features are optional.
Analog Outputs: Writing 16-bit analog outputs via PDO or SDO is normally supported.
Other output sizes and features are optional.
*/
/***************************************************************************/
class IOModule: public Node
{
public:
IOModule( void );
IOModule( CanOpen &co, int16 nodeID );
IOModule( CanOpen &co, int16 nodeID, IOModuleSettings &settings );
virtual ~IOModule();
virtual const Error *Init( CanOpen &co, int16 nodeID );
virtual const Error *Init( CanOpen &co, int16 nodeID, IOModuleSettings &settings );
virtual const Error *WaitIOEvent( IOMODULE_EVENTS event, int32 timeout=-1 );
virtual const Error *WaitIOEvent( Event &e, int32 timeout, IOMODULE_EVENTS &match );
/***************************************************************************/
/** \name Digital input control
If the module contains digital inputs, these methods may be used to configure
and read those inputs. The inputs may be read and controlled individually,
or in groups of 8, 16 or 32 inputs.
All I/O modules should support access to digital inputs in groups of 8.
Support for individual access or different groupings is optional under the
spec. If a particular device does not support such groupings, an attempt
to use them should return an error code.
Each input pin or group of pins is assigned an ID number used to access it.
When single inputs are accessed, these ID numbers range from 0 (the first input)
to N-1 (the last input), where N is the total number of input pins available
on the module.
When groups of inputs are accessed as a unit, the group is assigned a number.
The first group of inputs will be assigned ID number 0, the second will be ID 1,
etc. The number of groups of a particular size will be the total number of inputs
divided by the group size.
For example, to access the fifty third input pin individually you would use id
number 52. To access it as part of a group of 8 inputs, you would access group
number 6 (52/8). Input 52 would be bit 4 (52%8) of that group.
*/
/***************************************************************************/
//@{
/// Get the current setting of the global interrupt enable for digital inputs.
/// A return value of true indicates that interrupts are enabled, false disabled.
/// @param value The current interrupt enable setting is returned here.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetIntEna( bool &value ){
uint8 v;
const Error *err = sdo.Upld8( IOOBJID_DIN_INTENA, 0, v );
value = (v!=0);
return err;
}
/// Set the current setting of the global interrupt enable for digital inputs.
/// Setting this parameter to true enables interrupts, false disables.
/// @param value The interrupt enable setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinSetIntEna( bool value ){
const Error *err = sdo.Dnld8( IOOBJID_DIN_INTENA, 0, (uint8)value );
if( !err ) dinIntEna = value;
return err;
}
/// Return the number of individual inputs available on this device.
/// @param ct The count is returned here. Zero is returned on error.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetCt( uint16 &ct ){
ct = 0;
return BitCount( IOOBJID_DIN_1_VALUE, ct );
}
virtual const Error *DinRead( uint16 id, bool &value, bool viaSDO=false );
/// Get the current polarity settings for a digital input.
/// Polarity inversion is enabled if true, disabled if false.
/// @param id Identifies the digital input.
/// @param value The current polarity setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetPol( uint16 id, bool &value ){
return BitUpld( IOOBJID_DIN_1_POL, id, value );
}
/// Set the current polarity setting for a digital input.
/// Polarity inversion is enabled if true, disabled if false.
/// @param id Identifies the digital input.
/// @param value The new polarity setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinSetPol( uint16 id, bool value ){
return BitDnld( IOOBJID_DIN_1_POL, id, value );
}
/// Get the current filter constant setting for a digital input.
/// The filter constant is enabled if true, disabled if false.
/// @param id Identifies the digital input.
/// @param value The current filter setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetFilt( uint16 id, bool &value ){
return BitUpld( IOOBJID_DIN_1_FILT, id, value );
}
/// Set the current filter constant setting for a digital input.
/// The filter constant is enabled if true, disabled if false.
/// @param id Identifies the digital input.
/// @param value The new filter setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinSetFilt( uint16 id, bool value ){
return BitDnld( IOOBJID_DIN_1_FILT, id, value );
}
/// Get the 'any transition' interrupt mask settings for a digital input.
/// If true, any transition on the input will generate an interrupt.
/// @param id Identifies the digital input.
/// @param value The current interrupt mask setting
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetMaskAny( uint16 id, bool &value ){
return BitUpld( IOOBJID_DIN_1_MASK_ANY, id, value );
}
/// Set the 'any transition' interrupt mask settings for a digital input.
/// If true, any transition on the input will generate an interrupt.
/// @param id Identifies the digital input.
/// @param value The new interrupt mask setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinSetMaskAny( uint16 id, bool value ){
return BitDnld( IOOBJID_DIN_1_MASK_ANY, id, value );
}
/// Get the 'low to high' interrupt mask settings for a digital input.
/// If true, a low to high transition on the input will generate an interrupt.
/// @param id Identifies the digital input.
/// @param value The current interrupt mask setting
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetMaskLow2High( uint16 id, bool &value ){
return BitUpld( IOOBJID_DIN_1_MASK_L2H, id, value );
}
/// Set the 'low to high' interrupt mask settings for a digital input.
/// If true, a low to high transition on the input will generate an interrupt.
/// @param id Identifies the digital input.
/// @param value The new interrupt mask setting.
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinSetMaskLow2High( uint16 id, bool value ){
return BitDnld( IOOBJID_DIN_1_MASK_L2H, id, value );
}
/// Get the 'high to low' interrupt mask settings for a digital input.
/// If true, a high to low transition on the input will generate an interrupt.
/// @param id Identifies the digital input.
/// @param value The current interrupt mask setting
/// @return A pointer to an error object, or NULL on success
virtual const Error *DinGetMaskHigh2Low( uint16 id, bool &value ){
return BitUpld( IOOBJID_DIN_1_MASK_H2L, id, value );
}
/// Set the 'high to low' interrupt mask settings for a digital input.
/// If true, a high to low transition on the input will generate an interrupt.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?