📄 objacces.c
字号:
/***************************************************************************
objacces.c - description
-------------------
begin : Fri May 17 2002
copyright : (C) 2002 by Raphael Zulliger
email : zulli@hsr.ch
***************************************************************************/
/********************F*******************************************************
* *
* This library is Copyright (c) Raphael Zulliger <zulli@gmx.net>. *
* It is licensed under the GNU Library General Public License (LGPL). *
* *
***************************************************************************/
#include <objdict.h>
#include <objacces.h>
BYTE setVariable( WORD wIndex,
BYTE bSubindex,
void XHUGE* XDATA* ppvLocation )
{
WORD offset;
if( ( wIndex >= (WORD)0x6000 ) && ( wIndex <= (WORD)0x9FFF ) )
{
if( wIndex == (WORD)0x6000 )
{ /* this is the digital input range... */
offset = wIndex - (WORD)0x6000;
/* be sure the requested memory is allocated... */
if( (BYTE)digitalInputTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
digitalInputTable[offset].pSubindex[bSubindex].pObject = ppvLocation;
return SUCCESSFUL;
}
else if( wIndex == (WORD)0x6200 )
{ /* this is the digital output range... */
offset = wIndex - (WORD)0x6200;
if( (BYTE)digitalOutputTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
digitalOutputTable[offset].pSubindex[bSubindex].pObject = ppvLocation;
return SUCCESSFUL;
}
}
else
{
return NO_SUCH_INDEX;
}
return NO_SUCH_INDEX;
}
BYTE getODEntry( WORD wIndex,
BYTE bSubindex,
void XHUGE* XDATA* ppbData,
DWORD XDATA* pdwSize )
{
WORD offset;
if( ( wIndex >= (WORD)0x1000 ) && ( wIndex <= (WORD)0x11FF ) )
{ /* we are in the commuication profile area... */
if( wIndex <= (WORD)COMM_PROFILE_LAST )
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1000;
if( CommunicationProfileArea[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*ppbData = CommunicationProfileArea[offset].pSubindex[bSubindex].pObject;
*pdwSize = CommunicationProfileArea[offset].pSubindex[bSubindex].size ;
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x6000 ) && ( wIndex <= (WORD)0x9FFF ) )
{
if( wIndex == (WORD)0x6000 )
{ /* this is the digital input range... */
offset = wIndex - (WORD)0x6000;
if( digitalInputTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*ppbData = *(UNSIGNED8**)digitalInputTable[offset].pSubindex[bSubindex].pObject;
*pdwSize = digitalInputTable[offset].pSubindex[bSubindex].size;
return SUCCESSFUL;
}
else if( wIndex == (WORD)0x6200 )
{ /* this is the digital output range... */
offset = wIndex - (WORD)0x6200;
if( digitalOutputTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*ppbData = *(UNSIGNED8**)digitalOutputTable[offset].pSubindex[bSubindex].pObject;
*pdwSize = digitalOutputTable[offset].pSubindex[bSubindex].size;
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x1800 ) && ( wIndex <= (WORD)0x19FF ) )
{ /* Transmit PDO Communication Parameter */
if( wIndex <= TRANSMIT_PDO_LAST ) // the beginning ( wIndex >= TRANSMIT_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1800;
if( transmitPDOParameter[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*pdwSize = transmitPDOParameter[offset].pSubindex[bSubindex].size;
*ppbData = transmitPDOParameter[offset].pSubindex[bSubindex].pObject;
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x1400 ) && ( wIndex <= (WORD)0x15FF ) )
{ /* Receive PDO Communication Parameter */
if( wIndex <= RECEIVE_PDO_LAST ) // the beginning ( wIndex >= RECEIVE_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1400;
if( receivePDOParameter[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*pdwSize = receivePDOParameter[offset].pSubindex[bSubindex].size;
*ppbData = receivePDOParameter[offset].pSubindex[bSubindex].pObject;
return SUCCESSFUL;
}
}
/**********************************************************************************************
* Mapping parameters...
************************************************************************************************/
else if( ( wIndex >= (WORD)0x1600 ) && ( wIndex <= (WORD)0x17FF ) )
{ /* Receive PDO Mapping Parameter */
if( wIndex <= RECEIVE_PDO_MAPPING_LAST ) // the beginning ( wIndex >= RECEIVE_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1600;
if( RxPDOMappingTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*pdwSize = RxPDOMappingTable[offset].pSubindex[bSubindex].size;
*ppbData = RxPDOMappingTable[offset].pSubindex[bSubindex].pObject;
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x1A00 ) && ( wIndex <= (WORD)0x1BFF ) )
{ /* Transmit PDO Mapping Parameter */
if( wIndex <= TRANSMIT_PDO_MAPPING_LAST ) // the beginning ( wIndex >= RECEIVE_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1A00;
if( TxPDOMappingTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
*pdwSize = TxPDOMappingTable[offset].pSubindex[bSubindex].size;
*ppbData = TxPDOMappingTable[offset].pSubindex[bSubindex].pObject;
return SUCCESSFUL;
}
}
else
{
return NO_SUCH_INDEX;
}
return NO_SUCH_INDEX;
}
BYTE setODEntry( WORD wIndex,
BYTE bSubindex,
void XHUGE* pbData,
DWORD dwSize )
{
WORD offset;
/* !!!!!!!!!!!!! the var bMode wird noch nicht beachtet.... */
if( ( wIndex >= (WORD)0x1000 ) && ( wIndex <= (WORD)0x11FF ) )
{ /* we are in the commuication profile area... */
if( wIndex <= COMM_PROFILE_LAST )
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1000;
if( CommunicationProfileArea[offset].bSubCount < bSubindex )
return NO_SUCH_INDEX;
CommunicationProfileArea[offset].pSubindex[bSubindex].size = dwSize;
memcpy( CommunicationProfileArea[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x1400 ) && ( wIndex <= (WORD)0x15FF ) )
{ /* Receive PDO Communication Parameter */
if( wIndex <= RECEIVE_PDO_LAST ) // the beginning ( wIndex >= RECEIVE_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1400;
if( receivePDOParameter[offset].bSubCount < bSubindex )
return NO_SUCH_INDEX;
receivePDOParameter[offset].pSubindex[bSubindex].size = dwSize;
memcpy( receivePDOParameter[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x1800 ) && ( wIndex <= (WORD)0x19FF ) )
{ /* Transmit PDO Communication Parameter */
if( wIndex <= TRANSMIT_PDO_LAST ) // the beginning ( wIndex >= RECEIVE_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1800;
if( transmitPDOParameter[offset].bSubCount < bSubindex )
return NO_SUCH_INDEX;
transmitPDOParameter[offset].pSubindex[bSubindex].size = dwSize;
memcpy( transmitPDOParameter[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
return SUCCESSFUL;
}
}
/************************************************************************************************
* Mapping parameters...
************************************************************************************************/
else if( ( wIndex >= (WORD)0x1600 ) && ( wIndex <= (WORD)0x17FF ) )
{ /* Receive PDO Mapping Parameter */
if( wIndex <= RECEIVE_PDO_MAPPING_LAST )
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1600;
// check if subindex exists...
if( RxPDOMappingTable[offset].bSubCount < bSubindex )
return NO_SUCH_INDEX;
RxPDOMappingTable[offset].pSubindex[bSubindex].size = dwSize;
memcpy( RxPDOMappingTable[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
return SUCCESSFUL;
}
}
else if( ( wIndex >= (WORD)0x1A00 ) && ( wIndex <= (WORD)0x1BFF ) )
{ /* Transmit PDO Mapping Parameter */
if( wIndex <= TRANSMIT_PDO_MAPPING_LAST ) // the beginning ( wIndex >= RECEIVE_PDO_FIRST ) has not to be checked, because the first entry always lies on 0x1400...
{ /* we are in the defined area */
offset = wIndex - (WORD)0x1A00;
// check if subindex exists...
if( TxPDOMappingTable[offset].bSubCount < bSubindex )
return NO_SUCH_INDEX;
TxPDOMappingTable[offset].pSubindex[bSubindex].size = dwSize;
memcpy( TxPDOMappingTable[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
return SUCCESSFUL;
}
}
/************************************************************************************************
* Digital I/O handling
************************************************************************************************/
else if( ( wIndex >= (WORD)0x6000 ) && ( wIndex <= (WORD)0x9FFF ) )
{
if( wIndex == (WORD)0x6000 )
{ /* this is the digital input range... */
offset = wIndex - (WORD)0x6000;
if( digitalInputTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
memcpy( digitalInputTable[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
digitalInputTable[offset].pSubindex[bSubindex].size = dwSize;
return SUCCESSFUL;
}
else if( wIndex == (WORD)0x6200 )
{ /* this is the digital output range... */
offset = wIndex - (WORD)0x6200;
if( digitalOutputTable[offset].bSubCount <= bSubindex )
return NO_SUCH_INDEX;
memcpy( digitalOutputTable[offset].pSubindex[bSubindex].pObject, pbData, dwSize );
digitalOutputTable[offset].pSubindex[bSubindex].size = dwSize;
return SUCCESSFUL;
}
}
else
{
return NO_SUCH_INDEX;
}
return NO_SUCH_INDEX;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -