📄 o22siomm.cpp
字号:
// Read and clear the minimum value for the specified analog point//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_CLEAR_MIN_VALUE_BASE + (SIOMM_APOINT_READ_CLEAR_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::ReadClearAnaPtMaxValue(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Read and clear the maximum value for the specified analog point//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_CLEAR_MAX_VALUE_BASE + (SIOMM_APOINT_READ_CLEAR_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::ConfigurePoint(long nPoint, long nPointType)//-------------------------------------------------------------------------------------------------// Configure the specified point//-------------------------------------------------------------------------------------------------{ return WriteQuad(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), nPointType);}LONG O22SnapIoMemMap::GetModuleType(long nPoint, long * pnModuleType)//-------------------------------------------------------------------------------------------------// Get the module type at the specified point position//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_POINT_CONFIG_READ_MOD_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), (DWORD*)pnModuleType);}LONG O22SnapIoMemMap::SetDigPtConfiguration(long nPoint, long nPointType, long nFeature)//-------------------------------------------------------------------------------------------------// Configure a digital point//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[8]; // buffer for the data to be read // Build the data area O22FILL_ARRAY_FROM_LONG (arrbyData, 0, nPointType); O22FILL_ARRAY_FROM_LONG (arrbyData, 4, nFeature); // Write the data nResult = WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 8, (BYTE*)arrbyData); return nResult;}LONG O22SnapIoMemMap::SetAnaPtConfiguration(long nPoint, long nPointType, float fOffset, float fGain, float fHiScale, float fLoScale)//-------------------------------------------------------------------------------------------------// Configure an analog point//-------------------------------------------------------------------------------------------------{ BYTE arrbyData[24]; // buffer for the data to be read // Build the data area O22FILL_ARRAY_FROM_LONG (arrbyData, 0, nPointType); O22FILL_ARRAY_FROM_LONG (arrbyData, 4, 0); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 8, fOffset); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 12, fGain); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 16, fHiScale); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 20, fLoScale); // Write the data return WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 24, (BYTE*)arrbyData);}LONG O22SnapIoMemMap::SetPtConfigurationEx2(long nPoint, SIOMM_PointConfigArea2 PtConfigData)//-------------------------------------------------------------------------------------------------// Configure a digital or analog point//-------------------------------------------------------------------------------------------------{ BYTE arrbyData[SIOMM_POINT_CONFIG_BOUNDARY]; // buffer for the data to be read LONG nResult; // Build the data area O22FILL_ARRAY_FROM_LONG (arrbyData, 0, PtConfigData.nPointType); O22FILL_ARRAY_FROM_LONG (arrbyData, 4, PtConfigData.nFeature); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 8, PtConfigData.fOffset); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 12, PtConfigData.fGain); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 16, PtConfigData.fHiScale); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 20, PtConfigData.fLoScale); // Bytes 24-27 are not used at this time. O22FILL_ARRAY_FROM_FLOAT(arrbyData, 28, PtConfigData.fFilterWeight); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 32, PtConfigData.fWatchdogValue); O22FILL_ARRAY_FROM_LONG (arrbyData, 36, PtConfigData.nWatchdogEnabled); memcpy(arrbyData + 44, PtConfigData.byName, SIOMM_POINT_CONFIG_NAME_SIZE); // Write the first section nResult = WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 24, (BYTE*)arrbyData); // Check for error if (SIOMM_OK != nResult) return nResult; // Write the second section nResult = WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + 28 + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 12, (BYTE*)(&(arrbyData[28]))); // Check for error if (SIOMM_OK != nResult) return nResult; // Write the third section return WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + 44 + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), SIOMM_POINT_CONFIG_NAME_SIZE, (BYTE*)(&(arrbyData[44])));}LONG O22SnapIoMemMap::SetPtConfigurationEx(long nPoint, SIOMM_PointConfigArea PtConfigData)//-------------------------------------------------------------------------------------------------// Configure a digital or analog point//-------------------------------------------------------------------------------------------------{ BYTE arrbyData[40]; // buffer for the data to be read LONG nResult; // Build the data area O22FILL_ARRAY_FROM_LONG (arrbyData, 0, PtConfigData.nPointType); O22FILL_ARRAY_FROM_LONG (arrbyData, 4, PtConfigData.nFeature); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 8, PtConfigData.fOffset); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 12, PtConfigData.fGain); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 16, PtConfigData.fHiScale); O22FILL_ARRAY_FROM_FLOAT(arrbyData, 20, PtConfigData.fLoScale); // Bytes 24-31 are not used at this time. O22FILL_ARRAY_FROM_FLOAT(arrbyData, 32, PtConfigData.fWatchdogValue); O22FILL_ARRAY_FROM_LONG (arrbyData, 36, PtConfigData.nWatchdogEnabled); // Write the first section nResult = WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 24, (BYTE*)arrbyData); // Check for error if (SIOMM_OK != nResult) return nResult; // Write the second section return WriteBlock(SIOMM_POINT_CONFIG_WRITE_TYPE_BASE + 32 + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 8, (BYTE*)(&(arrbyData[32])));}LONG O22SnapIoMemMap::GetPtConfigurationEx2(long nPoint, SIOMM_PointConfigArea2 * pPtConfigData)//-------------------------------------------------------------------------------------------------// Get the configuration for a point//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[SIOMM_POINT_CONFIG_BOUNDARY]; // buffer for the data to be read // Read the data nResult = ReadBlock(SIOMM_POINT_CONFIG_READ_MOD_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), SIOMM_POINT_CONFIG_BOUNDARY, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pPtConfigData->nModuleType = O22MAKELONG2 (arrbyData, 0); pPtConfigData->nPointType = O22MAKELONG2 (arrbyData, 4); pPtConfigData->nFeature = O22MAKELONG2 (arrbyData, 8); pPtConfigData->fOffset = O22MAKEFLOAT2(arrbyData, 12); pPtConfigData->fGain = O22MAKEFLOAT2(arrbyData, 16); pPtConfigData->fHiScale = O22MAKEFLOAT2(arrbyData, 20); pPtConfigData->fLoScale = O22MAKEFLOAT2(arrbyData, 24); // Bytes 28-31 are not used at this time pPtConfigData->fFilterWeight = O22MAKEFLOAT2(arrbyData, 32); pPtConfigData->fWatchdogValue = O22MAKEFLOAT2(arrbyData, 36); pPtConfigData->nWatchdogEnabled = O22MAKELONG2 (arrbyData, 40); memcpy(pPtConfigData->byName, arrbyData + 48, 16); } return nResult;}LONG O22SnapIoMemMap::GetPtConfigurationEx(long nPoint, SIOMM_PointConfigArea * pPtConfigData)//-------------------------------------------------------------------------------------------------// Get the configuration for a point//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[44]; // buffer for the data to be read // Read the data nResult = ReadBlock(SIOMM_POINT_CONFIG_READ_MOD_TYPE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 44, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pPtConfigData->nModuleType = O22MAKELONG2(arrbyData, 0); pPtConfigData->nPointType = O22MAKELONG2(arrbyData, 4); pPtConfigData->nFeature = O22MAKELONG2 (arrbyData, 8); pPtConfigData->fOffset = O22MAKEFLOAT2(arrbyData, 12); pPtConfigData->fGain = O22MAKEFLOAT2(arrbyData, 16); pPtConfigData->fHiScale = O22MAKEFLOAT2(arrbyData, 20); pPtConfigData->fLoScale = O22MAKEFLOAT2(arrbyData, 24); // Bytes 28-35 are not used at this time pPtConfigData->fWatchdogValue = O22MAKEFLOAT2(arrbyData, 36); pPtConfigData->nWatchdogEnabled = O22MAKELONG2 (arrbyData, 40); } return nResult;}LONG O22SnapIoMemMap::SetPtWatchdog(long nPoint, float fValue, long nEnabled)//-------------------------------------------------------------------------------------------------// Set the watchdog values for a point.//-------------------------------------------------------------------------------------------------{ BYTE arrbyData[8]; // buffer for the data to be read // Build the data area O22FILL_ARRAY_FROM_FLOAT(arrbyData, 0, fValue); O22FILL_ARRAY_FROM_LONG (arrbyData, 4, nEnabled); // Write the data return WriteBlock(SIOMM_POINT_CONFIG_WRITE_WDOG_VALUE_BASE + (SIOMM_POINT_CONFIG_BOUNDARY * nPoint), 8, (BYTE*)arrbyData);}LONG O22SnapIoMemMap::CalcSetAnaPtOffset(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Calculate and set an analog point's offset//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_CALC_SET_OFFSET_BASE + (SIOMM_APOINT_READ_CALC_SET_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::CalcSetAnaPtGain(long nPoint, float *pfValue)//-------------------------------------------------------------------------------------------------// Calculate and set an analog point's gain//-------------------------------------------------------------------------------------------------{ return ReadFloat(SIOMM_APOINT_READ_CALC_SET_GAIN_BASE + (SIOMM_APOINT_READ_CALC_SET_BOUNDARY * nPoint), pfValue);}LONG O22SnapIoMemMap::GetStatusPUC(long *pnPUCFlag)//-------------------------------------------------------------------------------------------------// Get the Powerup Clear flag//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_STATUS_READ_PUC_FLAG, (DWORD*)pnPUCFlag);}LONG O22SnapIoMemMap::GetStatusLastError(long *pnErrorCode)//-------------------------------------------------------------------------------------------------// Get the last error//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_STATUS_READ_LAST_ERROR, (DWORD*)pnErrorCode);}LONG O22SnapIoMemMap::GetStatusBootpAlways(long *pnBootpAlways)//-------------------------------------------------------------------------------------------------// Get the "bootp always" flag//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_STATUS_READ_BOOTP_FLAG, (DWORD*)pnBootpAlways);}LONG O22SnapIoMemMap::GetStatusDegrees(long *pnDegrees)//-------------------------------------------------------------------------------------------------// Get the temperature unit.//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_STATUS_READ_DEGREES_FLAG, (DWORD*)pnDegrees);}LONG O22SnapIoMemMap::GetStatusWatchdogTime(long *pnTimeMS)//-------------------------------------------------------------------------------------------------// Get the watchdog time//-------------------------------------------------------------------------------------------------{ return ReadQuad(SIOMM_STATUS_READ_WATCHDOG_TIME, (DWORD*)pnTimeMS);}LONG O22SnapIoMemMap::GetStatusVersionEx(SIOMM_StatusVersion *pVersionData)//-------------------------------------------------------------------------------------------------// Get version information//-------------------------------------------------------------------------------------------------{ 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_STATUS_READ_BASE, 32, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pVersionData->nMapVer = O22MAKELONG2(arrbyData, 0 ); pVersionData->nLoaderVersion = O22MAKELONG2(arrbyData, 24); pVersionData->nKernelVersion = O22MAKELONG2(arrbyData, 28); } return nResult;}LONG O22SnapIoMemMap::GetStatusHardwareEx(SIOMM_StatusHardware *pHardwareData)//-------------------------------------------------------------------------------------------------// Get hardware information//-------------------------------------------------------------------------------------------------{ LONG nResult; // for checking the return values of functions BYTE arrbyData[44]; // buffer for the data to be read // Read the data nResult = ReadBlock(SIOMM_STATUS_READ_BASE, 44, (BYTE*)arrbyData); // Check for error if (SIOMM_OK == nResult) { // If everything is okay, go ahead and fill the structure pHardwareData->nIoUnitType = O22MAKELONG2(arrbyData, 32); pHardwareData->byHwdVerMonth = O22MAKEBYTE2(arrbyData, 36); pHardwareData->byHwdVerDay = O22MAKEBYTE2(arrbyData, 37); pHardwareData->wHwdVerYear = O22MAKEWORD2(arrbyData, 38); pHardwareData->nRamSize = O22MAKELONG2(arrbyData, 40); } return nResult;}LONG O22SnapIoMemMap::GetStatusHardwareEx2(SIOMM_StatusHardw
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -