/******************************************************************************* ******************************************************************************** ** ** ** ABCC Starter Kit version 3.05.02 (2018-08-30) ** ** ** ** Delivered with: ** ** ABP 7.59.01 (2018-05-17) ** ** ABCC Driver 5.05.02 (2018-08-30) ** ** */ /******************************************************************************* ******************************************************************************** ** COPYRIGHT NOTIFICATION (c) 2015 HMS Industrial Networks AB ** ** ** ** This code is the property of HMS Industrial Networks AB. ** ** The source code may not be reproduced, distributed, or used without ** ** permission. When used together with a product from HMS, permission is ** ** granted to modify, reproduce and distribute the code in binary form ** ** without any restrictions. ** ** ** ** THE CODE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. HMS DOES NOT ** ** WARRANT THAT THE FUNCTIONS OF THE CODE WILL MEET YOUR REQUIREMENTS, OR ** ** THAT THE OPERATION OF THE CODE WILL BE UNINTERRUPTED OR ERROR-FREE, OR ** ** THAT DEFECTS IN IT CAN BE CORRECTED. ** ******************************************************************************** ******************************************************************************** ** Example of an ADI setup with 11 ADIs covering all data types and structures. ** ** In abcc_drv_cfg.h make sure that the following definitions are set to: ** ABCC_CFG_STRUCT_DATA_TYPE ( TRUE ) ** ABCC_CFG_ADI_GET_SET_CALLBACK ( FALSE ) ******************************************************************************** ******************************************************************************** */ #include "appl_adi_config.h" #include #include "definitions.h" #include "defaults.h" #include "../SonarTrac/DeviceParams.h" #include "../SonarTrac/CmdResp.h" #include "../SonarTrac/Totalizer.h" #include "appl_adimap_cidra.h" #if ( APPL_ACTIVE_ADI_SETUP == APPL_ADI_SETUP_CIDRA_TEST ) #if( ABCC_CFG_STRUCT_DATA_TYPE || !ABCC_CFG_ADI_GET_SET_CALLBACK ) #error ABCC_CFG_ADI_GET_SET_CALLBACK must be set to TRUE and ABCC_CFG_STRUCT_DATA_TYPE set to FALSE in order to run this example #endif /******************************************************************************* ** Constants ******************************************************************************** */ /*------------------------------------------------------------------------------ ** Access descriptor for the ADIs **------------------------------------------------------------------------------ */ #define APPL_READ_MAP_READ_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \ ABP_APPD_DESCR_MAPPABLE_READ_PD ) #define APPL_READ_MAP_WRITE_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \ ABP_APPD_DESCR_SET_ACCESS | \ ABP_APPD_DESCR_MAPPABLE_READ_PD ) #define APPL_WRITE_MAP_READ_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \ ABP_APPD_DESCR_MAPPABLE_WRITE_PD ) #define APPL_NOT_MAP_READ_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS ) #define APPL_NOT_MAP_WRITE_ACCESS_DESC ( ABP_APPD_DESCR_GET_ACCESS | \ ABP_APPD_DESCR_SET_ACCESS ) /******************************************************************************* ** Typedefs ******************************************************************************** */ /*------------------------------------------------------------------------------ ** Forward declarations **------------------------------------------------------------------------------ */ static void SetAdiValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static void GetAdiValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static void SetAdiPipeDiamValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static void SetAdiMapValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static void GetAdiMapValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static void SetAdiInputValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static void SetAdiControlValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ); static bool bSetSuccess; AD_FLOAT32Type g_stFloatRange; AD_UINT8Type g_stU8Range; AD_CHARType g_stCharRange; /* * ADI = slot * 255 + index + 1 * slot = (ADI - 1) / 255 * index = (ADI - 1) MOD 255 * */ // 255 slots max int g_nPhyBlk[20]; /*------------------------------------------------------------------------------ ** ADI variables **------------------------------------------------------------------------------ */ /*----------------------------------------------------------------------------------------------------------------------- ** iInstance | DictID | pabName | bDataType | bNumOfElements | bDesc | pxValuePtr | pxValuePropPtr| pnGetAdiValue | pnSetAdiValue **----------------------------------------------------------------------------------------------------------------------- */ const AD_AdiEntryType APPL_asAdiEntryList[] = { { 1, "PhyBlkInd", ABP_UINT8, 20, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_nPhyBlk ,NULL } }, NULL, NULL }, //********************************** // Listed in GSD File // outputs { Slot1_Index0, "VFFiltered", ABP_FLOAT, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &g_stDSPDiagnostics.fVFFiltered ,NULL } }, NULL, NULL }, { Slot1_Index1, "SOSFiltered", ABP_FLOAT, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &g_stDSPDiagnostics.fSOSFiltered ,NULL } }, NULL, NULL }, { Slot1_Index2, "GVFFiltered", ABP_FLOAT, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &g_stDSPDiagnostics.fGVFFiltered ,NULL } }, NULL, NULL }, { Slot1_Index3, "VFQuality", ABP_FLOAT, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &g_stDSPDiagnostics.fVFQuality ,NULL } }, NULL, NULL }, { Slot1_Index4, "SOSQuality", ABP_FLOAT, 1, APPL_WRITE_MAP_READ_ACCESS_DESC, { { &g_stDSPDiagnostics.fSOSQuality ,NULL } }, NULL, NULL }, // inputs { Slot2_Index0, "Pressure", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stExternalInputs.fPressure ,NULL } }, NULL, SetAdiInputValue }, { Slot2_Index1, "Temperature", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stExternalInputs.fTemperature ,NULL } }, NULL, SetAdiInputValue }, //********************************** // Control { Slot3_Index0, "TotalizerReset", ABP_CHAR, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_nTotalizerReset ,NULL } }, NULL, SetAdiControlValue}, // device info { Slot4_Index0, "SerialNumber", ABP_CHAR, STR_LEN, APPL_READ_MAP_READ_ACCESS_DESC, { { &g_stConfig.Sec.bSerialNumber ,&g_stCharRange } }, GetAdiValue, NULL}, { Slot4_Index1, "ModelNumber", ABP_CHAR, MODEL_NUM_LEN, APPL_READ_MAP_READ_ACCESS_DESC, { { &g_stConfig.Sec.bModelNumber ,&g_stCharRange } }, GetAdiValue, NULL}, { Slot4_Index2, "SoftwareRevision", ABP_CHAR, SOFTWARE_REV_LEN, APPL_READ_MAP_READ_ACCESS_DESC, { { &SOFTWARE_REVISION ,&g_stCharRange } }, GetAdiValue, NULL}, //{ Slot4_Index3, "SensorheadSerial", ABP_CHAR, MODEL_NUM_LEN, APPL_READ_MAP_READ_ACCESS_DESC, { { &g_stConfig.Sec.bSensorheadSerial ,&g_stCharRange } }, GetAdiValue, NULL}, // pipe information { Slot5_Index0, "PipeDiamType", ABP_UINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.nPipeDiamType ,&g_stU8Range } }, GetAdiValue, SetAdiValue }, { Slot5_Index1, "PipeDiamUnit", ABP_UINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.nPipeDiamUnit ,&g_stU8Range } }, GetAdiValue, SetAdiValue }, //{ Slot5_Index2, "PipeID", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fPipeID ,&g_stFloatRange } }, GetAdiValue, SetAdiValue }, //{ Slot5_Index3, "PipeOD", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fPipeOD ,&g_stFloatRange } }, GetAdiValue, SetAdiValue }, //{ Slot5_Index4, "PipeSizeSched", ABP_UINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.nPipeSizeSched ,&appl_sUCProp[UC_NORange] } }, GetAdiValue, SetAdiValue }, { Slot5_Index5, "SOSPipeWallThick", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSPipeWallThick ,&g_stFloatRange} }, GetAdiValue, SetAdiValue }, { Slot5_Index6, "PipeLinerThickness", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fPipeLinerThickness ,NULL } }, GetAdiValue, SetAdiValue }, { Slot5_Index7, "SOSPipeModulus", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSPipeModulus ,NULL } }, GetAdiValue, SetAdiValue }, // fluid properties { Slot6_Index0, "Viscosity", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fViscosity ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, { Slot6_Index1, "SOSGasConstant", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSGasConstant ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, { Slot6_Index2, "SOSSpecificGravity", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSSpecificGravity ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, { Slot6_Index3, "SOSLiquidSOS", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSLiquidSOS ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, { Slot6_Index4, "SOSSpecficHeatRatio", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSSpecficHeatRatio ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, { Slot6_Index5, "SOSLiquidDensity", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Alg.fSOSLiquidDensity ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, //{ Slot4_Index2, "ReynoldsC0", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fReynoldsC0 ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, //{ Slot4_Index3, "ReynoldsC1", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fReynoldsC1 ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, //{ Slot4_Index4, "ReynoldsC2", ABP_FLOAT, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stConfig.Usr.fReynoldsC2 ,&g_stFloatRange } }, GetAdiValue, SetAdiValue}, //{ Slot4_Index5, "VolUnits", ABP_UINT8, 1, APPL_READ_MAP_WRITE_ACCESS_DESC, { { &g_stMapConfig.ucVolUnits ,&appl_sUCProp[UC_VolUnits] } }, GetAdiMapValue, SetAdiMapValue}, }; // cyclic data const AD_MapType APPL_asAdObjDefaultMap[] = { // outputs // { 1, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, { Slot1_Index0, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, { Slot1_Index1, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, { Slot1_Index2, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, { Slot1_Index3, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, { Slot1_Index4, PD_WRITE, AD_MAP_ALL_ELEM, 0 }, // inputs { Slot2_Index0, PD_READ, AD_MAP_ALL_ELEM, 0 }, { Slot2_Index1, PD_READ, AD_MAP_ALL_ELEM, 0 }, { AD_MAP_END_ENTRY } }; /******************************************************************************* ** Private Services ******************************************************************************** */ /******************************************************************************* ** Private Services ******************************************************************************** */ /*------------------------------------------------------------------------------ ** Callback of type ABCC_GetAdiValueFuncType. The function will be called when ** the network reads ADI #11. It will increment the value of ADI#12 every time ** this is done. ** ** ABCC_GetAdiValueFuncType is declared in abcc_ad_if.h **------------------------------------------------------------------------------ */ static void GetAdiValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { switch (psAdiEntry->bDataType) { case ABP_FLOAT: if (psAdiEntry->uData.sFLOAT.psValueProps != NULL) SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: GET: %s = %f\r\n",// (Min = %f, Max = %f, Default = %f)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sFLOAT.prValuePtr); // psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[0], // psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[1], // psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[2]); else SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: GET: %s = %f (No Range Check)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sFLOAT.prValuePtr); break; case ABP_UINT8: if (psAdiEntry->uData.sUINT8.psValueProps != NULL) { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: GET: %s = %d\r\n",// (Min = %d, Max = %d, Default = %d)\r\n", psAdiEntry->pacName, psAdiEntry->uData.sUINT8.pbValuePtr); // psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[0], // psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[1], // psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[2]); } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: GET: %s = %d\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sUINT8.pbValuePtr); } break; case ABP_CHAR: if (psAdiEntry->uData.sCHAR.psValueProps != NULL) { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: GET: %s = %s\r\n",// (Min = %d, Max = %d, Default = %d)\r\n", psAdiEntry->pacName, psAdiEntry->uData.sCHAR.pbValuePtr); // psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[0], // psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[1], // psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[2]); } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: GET: %s = %s\r\n", psAdiEntry->pacName, psAdiEntry->uData.sCHAR.pbValuePtr); } break; } } /*------------------------------------------------------------------------------ ** Callback of type ABCC_SetAdiValueFuncType. The function will be called when ** the network writes to ADI#10. It copies the changed values from ADI#10 to ADI#11. ** ** ABCC_SetAdiValueFuncType is declared in abcc_ad_if.h **------------------------------------------------------------------------------ */ static void SetAdiValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { bSetSuccess = false; switch (psAdiEntry->bDataType) { case ABP_FLOAT: if ((psAdiEntry->uData.sFLOAT.psValueProps != NULL) && (psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[0] != psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[1])) // there is a range check { if ((*psAdiEntry->uData.sFLOAT.prValuePtr >= psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[0]) && (*psAdiEntry->uData.sFLOAT.prValuePtr <= psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[1])) { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %f (Min = %f, Max = %f, Default = %f)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sFLOAT.prValuePtr, psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[0], psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[1], psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[2]); bSetSuccess = SPISetAllDeviceParamsToFLASH(); UpdateDictParam2DSP(psAdiEntry->unID); // send msg to dsp to update value } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: RANGE ERROR: %s = %f (Min = %f, Max = %f, Default = %f [0x%08X])\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sFLOAT.prValuePtr, psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[0], psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[1], psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[2], psAdiEntry->uData.sFLOAT.psValueProps->rMinMaxDefault[2]); } } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %f\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sFLOAT.prValuePtr); bSetSuccess = SPISetAllDeviceParamsToFLASH(); UpdateDictParam2DSP(psAdiEntry->unID); // send msg to dsp to update value } break; case ABP_UINT8: if ((psAdiEntry->uData.sUINT8.psValueProps != NULL) && (psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[0] != psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[1])) // there is a range check { if ((*psAdiEntry->uData.sUINT8.pbValuePtr >= psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[0]) && (*psAdiEntry->uData.sUINT8.pbValuePtr <= psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[1])) { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %d (Min = %d, Max = %d, Default = %d)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sUINT8.pbValuePtr, psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[0], psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[1], psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[2]); bSetSuccess = SPISetAllDeviceParamsToFLASH(); UpdateDictParam2DSP(psAdiEntry->unID); // send msg to dsp to update value } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: RANGE ERROR: %s = %d (Min = %d, Max = %d, Default = %d)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sUINT8.pbValuePtr, psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[0], psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[1], psAdiEntry->uData.sUINT8.psValueProps->bMinMaxDefault[2]); } } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %d\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sUINT8.pbValuePtr); bSetSuccess = SPISetAllDeviceParamsToFLASH(); UpdateDictParam2DSP(psAdiEntry->unID); // send msg to dsp to update value } break; case ABP_CHAR: if ((psAdiEntry->uData.sCHAR.psValueProps != NULL) && (psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[0] != psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[1])) // there is a range check { if ((strlen((char *)psAdiEntry->uData.sCHAR.pbValuePtr) >= psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[0]) && (strlen((char *)psAdiEntry->uData.sCHAR.pbValuePtr) <= psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[1])) { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %s (Min = %d, Max = %d, Default = %d)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sCHAR.pbValuePtr, psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[0], psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[1], psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[2]); bSetSuccess = SPISetAllDeviceParamsToFLASH(); UpdateDictParam2DSP(psAdiEntry->unID); // send msg to dsp to update value } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: RANGE ERROR: %s = %s (Min = %d, Max = %d, Default = %d)\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sCHAR.pbValuePtr, psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[0], psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[1], psAdiEntry->uData.sCHAR.psValueProps->bMinMaxDefault[2]); } } else { SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %s\r\n", psAdiEntry->pacName, *psAdiEntry->uData.sCHAR.pbValuePtr); bSetSuccess = SPISetAllDeviceParamsToFLASH(); UpdateDictParam2DSP(psAdiEntry->unID); // send msg to dsp to update value } break; } // update stuff like serial port, Ethernet etc... // DoSystemSettingsChanges(); TODO depends on screen now } static void GetAdiMapValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { switch (psAdiEntry->iInstance) { case 261: // TODO g_stMapConfig.ucVolUnits = g_stConfig.Usr.nVolUnits; break; } } static void SetAdiControlValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { if (psAdiEntry->iInstance == Slot3_Index0) ResetTotalizer(); } static void SetAdiMapValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { SetAdiValue(psAdiEntry, bNumElements, bStartIndex); if (bSetSuccess) { switch (psAdiEntry->iInstance) { case 261: g_stConfig.Usr.nVolUnits = g_stMapConfig.ucVolUnits; break; } } } static void SetAdiInputValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { // perhaps a range check or a flag indicating an update here? // SYS_ERROR_PRINT(SYS_ERROR_INFO, "Profibus DP: SET: %s = %f\r\n", // psAdiEntry->pacName, // *psAdiEntry->uData.sFLOAT.prValuePtr); } static void SetAdiPipeDiamValue( const struct AD_AdiEntry* psAdiEntry, UINT8 bNumElements, UINT8 bStartIndex ) { SetAdiValue(psAdiEntry, bNumElements, bStartIndex); if (bSetSuccess) { g_stConfig.Usr.fPipeDiamVal1 = g_stConfig.Alg.fPipeDiam; // TODO also set type, units etc } } /******************************************************************************* ** Public Services ******************************************************************************** */ UINT16 APPL_GetNumAdi( void ) { return( sizeof( APPL_asAdiEntryList ) / sizeof( AD_AdiEntryType ) ); } void APPL_CyclicalProcessing( void ) { /* ** This function is called when read and write data have been updated. It ** could for example be used for operations on the ADI data. ** Not used in this example. */ } #endif /******************************************************************************* ** Tasks ******************************************************************************** */