📄 o22siomm.cpp
字号:
{ LONG nResult; // for checking the return values of functions BYTE arrbyData[20]; // buffer for the data to be read // Read the data nResult = ReadBlock(SIOMM_DPOINT_READ_AREA_BASE + (SIOMM_DPOINT_READ_BOUNDARY * nPoint), 20, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pData->nState = O22MAKELONG2(arrbyData, 0); pData->nOnLatch = O22MAKELONG2(arrbyData, 4); pData->nOffLatch = O22MAKELONG2(arrbyData, 8); pData->nCounterState = O22MAKELONG2(arrbyData, 12); pData->nCounts = O22MAKELONG2(arrbyData, 16); } return nResult;}LONG O22SnapIoMemMap::SetDigPtState(long nPoint, long nState)//-------------------------------------------------------------------------------------------------// Set the state of the specified digital point//-------------------------------------------------------------------------------------------------{ if (nState) return WriteQuad(SIOMM_DPOINT_WRITE_TURN_ON_BASE + (SIOMM_DPOINT_WRITE_BOUNDARY * nPoint), 1); else return WriteQuad(SIOMM_DPOINT_WRITE_TURN_OFF_BASE + (SIOMM_DPOINT_WRITE_BOUNDARY * nPoint), 1);}LONG O22SnapIoMemMap::SetDigPtCounterState(long nPoint, long nState)//-------------------------------------------------------------------------------------------------// Set the active counter state of the specified digital point//-------------------------------------------------------------------------------------------------{ if (nState) return WriteQuad(SIOMM_DPOINT_WRITE_ACTIVATE_COUNTER + (SIOMM_DPOINT_WRITE_BOUNDARY * nPoint), 1); else return WriteQuad(SIOMM_DPOINT_WRITE_DEACTIVATE_COUNTER + (SIOMM_DPOINT_WRITE_BOUNDARY * nPoint), 1);}LONG O22SnapIoMemMap::GetBitmask64(DWORD dwDestOffset, long *pnPts63to32, long *pnPts31to0)//-------------------------------------------------------------------------------------------------// Get a 64-bit bitmask from a location in the SNAP I/O memory map.//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[8]; // buffer for the data to be read // Read the data nResult = ReadBlock(dwDestOffset, 8, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and make the longs *pnPts63to32 = O22MAKELONG2(arrbyData, 0); *pnPts31to0 = O22MAKELONG2(arrbyData, 4); } return nResult;}LONG O22SnapIoMemMap::SetBitmask64(DWORD dwDestOffset, long nPts63to32, long nPts31to0)//-------------------------------------------------------------------------------------------------// Set a 64-bit bitmask to a location in the SNAP I/O memory map.//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[8]; // buffer for the data to be read // Unpack the bytes O22FILL_ARRAY_FROM_LONG(arrbyData, 0, nPts63to32); O22FILL_ARRAY_FROM_LONG(arrbyData, 4, nPts31to0); // Write the data nResult = WriteBlock(dwDestOffset, 8, (BYTE*)arrbyData); return nResult;}LONG O22SnapIoMemMap::GetDigBankPointStates(long *pnPts63to32, long *pnPts31to0)//-------------------------------------------------------------------------------------------------// Get the digital point states in the digital bank//-------------------------------------------------------------------------------------------------{ return GetBitmask64(SIOMM_DBANK_READ_POINT_STATES, pnPts63to32, pnPts31to0); }LONG O22SnapIoMemMap::GetDigBankOnLatchStates(long *pnPts63to32, long *pnPts31to0)//-------------------------------------------------------------------------------------------------// Get the digital point on-latch states in the digital bank//-------------------------------------------------------------------------------------------------{ return GetBitmask64(SIOMM_DBANK_READ_ON_LATCH_STATES, pnPts63to32, pnPts31to0); }LONG O22SnapIoMemMap::GetDigBankOffLatchStates(long *pnPts63to32, long *pnPts31to0)//-------------------------------------------------------------------------------------------------// Get the digital point off-latch states in the digital bank//-------------------------------------------------------------------------------------------------{ return GetBitmask64(SIOMM_DBANK_READ_OFF_LATCH_STATES, pnPts63to32, pnPts31to0); }LONG O22SnapIoMemMap::GetDigBankActCounterStates(long *pnPts63to32, long *pnPts31to0)//-------------------------------------------------------------------------------------------------// Get the digital point active counter states in the digital bank//-------------------------------------------------------------------------------------------------{ return GetBitmask64(SIOMM_DBANK_READ_ACTIVE_COUNTERS, pnPts63to32, pnPts31to0); }LONG O22SnapIoMemMap::SetDigBankPointStates(long nPts63to32, long nPts31to0, long nMask63to32, long nMask31to0)//-------------------------------------------------------------------------------------------------// Set the digital point states in the digital bank. Only those points set in the mask parameters// are set.//-------------------------------------------------------------------------------------------------{ long nOnMask63to32; long nOnMask31to0; long nOffMask63to32; long nOffMask31to0; LONG nResult; // for checking the return values of functions BYTE arrbyData[16]; // buffer for the data to be read // Figure out the On Mask nOnMask63to32 = nPts63to32 & nMask63to32; nOnMask31to0 = nPts31to0 & nMask31to0; // Figure out the Off Mask nOffMask63to32 = (nPts63to32 ^ 0xFFFFFFFF) & nMask63to32; nOffMask31to0 = (nPts31to0 ^ 0xFFFFFFFF) & nMask31to0; // Pack the bytes O22FILL_ARRAY_FROM_LONG(arrbyData, 0, nOnMask63to32); O22FILL_ARRAY_FROM_LONG(arrbyData, 4, nOnMask31to0); O22FILL_ARRAY_FROM_LONG(arrbyData, 8, nOffMask63to32); O22FILL_ARRAY_FROM_LONG(arrbyData, 12, nOffMask31to0); // Write the data nResult = WriteBlock(SIOMM_DBANK_WRITE_TURN_ON_MASK, 16, (BYTE*)arrbyData); return nResult;} LONG O22SnapIoMemMap::SetDigBankOnMask(long nPts63to32, long nPts31to0)//-------------------------------------------------------------------------------------------------// Turn on the given digital points//-------------------------------------------------------------------------------------------------{ return SetBitmask64(SIOMM_DBANK_WRITE_TURN_ON_MASK, nPts63to32, nPts31to0); }LONG O22SnapIoMemMap::SetDigBankOffMask(long nPts63to32, long nPts31to0)//-------------------------------------------------------------------------------------------------// Turn off the given digital points//-------------------------------------------------------------------------------------------------{ return SetBitmask64(SIOMM_DBANK_WRITE_TURN_OFF_MASK, nPts63to32, nPts31to0); }LONG O22SnapIoMemMap::SetDigBankActCounterMask(long nPts63to32, long nPts31to0)//-------------------------------------------------------------------------------------------------// Active counters for the given digital points//-------------------------------------------------------------------------------------------------{ return SetBitmask64(SIOMM_DBANK_WRITE_ACT_COUNTERS_MASK, nPts63to32, nPts31to0); }LONG O22SnapIoMemMap::SetDigBankDeactCounterMask(long nPts63to32, long nPts31to0)//-------------------------------------------------------------------------------------------------// Deactive counters for the given digital points//-------------------------------------------------------------------------------------------------{ return SetBitmask64(SIOMM_DBANK_WRITE_DEACT_COUNTERS_MASK, nPts63to32, nPts31to0); }LONG O22SnapIoMemMap::GetDigBankReadAreaEx(SIOMM_DigBankReadArea * pData)//-------------------------------------------------------------------------------------------------// Get the read area for the digital bank//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[32]; // buffer for the data to be read // Read the data nResult = ReadBlock(SIOMM_DBANK_READ_AREA_BASE, 32, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pData->nStatePts63to32 = O22MAKELONG2(arrbyData, 0); pData->nStatePts31to0 = O22MAKELONG2(arrbyData, 4); pData->nOnLatchStatePts63to32 = O22MAKELONG2(arrbyData, 8); pData->nOnLatchStatePts31to0 = O22MAKELONG2(arrbyData, 12); pData->nOffLatchStatePts63to32 = O22MAKELONG2(arrbyData, 16); pData->nOffLatchStatePts31to0 = O22MAKELONG2(arrbyData, 20); pData->nActiveCountersPts63to32 = O22MAKELONG2(arrbyData, 24); pData->nActiveCountersPts31to0 = O22MAKELONG2(arrbyData, 28); } return nResult;}LONG O22SnapIoMemMap::ReadClearDigPtCounts(long nPoint, long * pnState)//-------------------------------------------------------------------------------------------------// Read and clear counts for the specified digital point//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_DPOINT_READ_CLEAR_COUNTS_BASE + (SIOMM_DPOINT_READ_CLEAR_BOUNDARY * nPoint), (DWORD*)pnState);}LONG O22SnapIoMemMap::ReadClearDigPtOnLatch(long nPoint, long * pnState)//-------------------------------------------------------------------------------------------------// Read and clear the on-latch state for the specified digital point//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_DPOINT_READ_CLEAR_ON_LATCH_BASE + (SIOMM_DPOINT_READ_CLEAR_BOUNDARY * nPoint), (DWORD*)pnState);}LONG O22SnapIoMemMap::ReadClearDigPtOffLatch(long nPoint, long * pnState)//-------------------------------------------------------------------------------------------------// Read and clear the off-latch state for the specified digital point//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_DPOINT_READ_CLEAR_OFF_LATCH_BASE + (SIOMM_DPOINT_READ_CLEAR_BOUNDARY * nPoint), (DWORD*)pnState);}LONG O22SnapIoMemMap::GetAnaPtValue(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Get the value of the specified analog point.//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_VALUE_BASE + (SIOMM_APOINT_READ_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::GetAnaPtCounts(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Get the raw counts of the specified analog point.//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_COUNTS_BASE + (SIOMM_APOINT_READ_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::GetAnaPtMinValue(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Get the minimum value of the specified analog point.//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_MIN_VALUE_BASE + (SIOMM_APOINT_READ_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::GetAnaPtMaxValue(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Get the maximum value of the specified analog point.//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_MAX_VALUE_BASE + (SIOMM_APOINT_READ_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::GetAnaPtTpoPeriod(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Get the TPO period of the specified analog point.//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_TPO_PERIOD_BASE + (SIOMM_APOINT_READ_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::GetAnaPtReadAreaEx(long nPoint, SIOMM_AnaPointReadArea * pData)//-------------------------------------------------------------------------------------------------// Get the read area for the specified analog point//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[16]; // buffer for the data to be read // Read the data nResult = ReadBlock(SIOMM_APOINT_READ_AREA_BASE + (SIOMM_APOINT_READ_BOUNDARY * nPoint), 16, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pData->fValue = O22MAKEFLOAT2(arrbyData, 0); pData->fCounts = O22MAKEFLOAT2(arrbyData, 4); pData->fMinValue = O22MAKEFLOAT2(arrbyData, 8); pData->fMaxValue = O22MAKEFLOAT2(arrbyData, 12); } return nResult;}LONG O22SnapIoMemMap::SetAnaPtValue(long nPoint, float fValue)//-------------------------------------------------------------------------------------------------// Set the value for the specified analog point//-------------------------------------------------------------------------------------------------{ return WriteFloat(SIOMM_APOINT_WRITE_VALUE_BASE + (SIOMM_APOINT_WRITE_BOUNDARY * nPoint), fValue);}LONG O22SnapIoMemMap::SetAnaPtCounts(long nPoint, float fValue)//-------------------------------------------------------------------------------------------------// Set the raw counts for the specified analog point//-------------------------------------------------------------------------------------------------{ return WriteFloat(SIOMM_APOINT_WRITE_COUNTS_BASE + (SIOMM_APOINT_WRITE_BOUNDARY * nPoint), fValue);}LONG O22SnapIoMemMap::SetAnaPtTpoPeriod(long nPoint, float fValue)//-------------------------------------------------------------------------------------------------// Set the TPO period for the specified analog point//-------------------------------------------------------------------------------------------------{ return WriteFloat(SIOMM_APOINT_WRITE_TPO_PERIOD_BASE + (SIOMM_APOINT_WRITE_BOUNDARY * nPoint), fValue);}LONG O22SnapIoMemMap::ReadClearAnaPtMinValue(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -