| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2019 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_CLL_Variable_Functions |
| // |
| // Purpose: |
| // This module contains the implementation of generic EPTF_Variable functions. |
| // |
| // Module Parameters: |
| // tsp_EPTF_Var_enableName2Id - *boolean* - if true hashmap database is maintained to get the id from a variable name, default: true |
| // tsp_EPTF_Var_enableCompRef2Id - *boolean* - if true hashmap database is maintained to get the id from a component variable, default: true |
| // tsp_EPTF_Var_enableEmptyTimeLine - *boolean* - if true timeline message will always be sent at the sync-time even if empty, default: false |
| // tsp_EPTF_Var_cfg - <EPTF_Var_InitialValueList> - the initial value list of variables to load |
| // tsp_EPTF_Var_maxWaitTime - *float* - the max time to wait for responses (default: 120.0 sec) |
| // tsp_EPTF_Var_maxWaitTimeForByeAck - *float* - the max time to wait for ByeAck messages (default: 240.0 sec) |
| // tsp_EPTF_Var_debug - *boolean* - to switch on debugging (default: false) |
| // |
| // Module depends on: |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Base_Definitions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Common_Definitions> |
| // <EPTF_CLL_Common_Functions> |
| // <EPTF_CLL_HashMapStr2Int_Functions> |
| // <EPTF_CLL_HashMapOct2Int_Functions> |
| // <TCCFileIO_Functions> |
| // <TCCDateTime_Functions> |
| // <EPTF_CLL_Logging_Definitions> |
| // <EPTF_CLL_Logging_Functions> |
| // <EPTF_CLL_Scheduler_Definitions> |
| // <EPTF_CLL_RBTScheduler_Functions> |
| // <EPTF_CLL_HashMap_Functions> |
| // <EPTF_CLL_FBQ_Functions> |
| // |
| // Current Owner: |
| // EFLOATT |
| // |
| // Last Review Date: |
| // 2010-xx-xx |
| // |
| // Detailed Comments: |
| // This module contains the interface functions for the EPTF_Variable. |
| // Public functions: |
| // <f_EPTF_Var_init_CT> |
| // <f_EPTF_Var_Log> |
| // <f_EPTF_Var_CT_LogAll> |
| // <f_EPTF_Var_logNames> |
| // <f_EPTF_Var_newIntRef> |
| // <f_EPTF_Var_newFloatRef> |
| // <f_EPTF_Var_newBoolRef> |
| // <f_EPTF_Var_newCharstringRef> |
| // <f_EPTF_Var_newOctetstringRef> |
| // <f_EPTF_Var_newHexstringRef> |
| // <f_EPTF_Var_newBitstringRef> |
| // <f_EPTF_Var_newIntegerlistRef> |
| // <f_EPTF_Var_newFloatlistRef> |
| // <f_EPTF_Var_newCharstringlistRef> |
| // <f_EPTF_Var_newStatusLEDRef> |
| // <f_EPTF_Var_newVar> |
| // <f_EPTF_Var_createVarFromCfg> |
| // <f_EPTF_Var_loadVarFromCfg> |
| // <f_EPTF_Var_saveVarToCfg> |
| // <f_EPTF_Var_saveVarToCfgStr> |
| // <f_EPTF_Var_registerVarToSave> |
| // <f_EPTF_Var_deregisterVarFromSave> |
| // <f_EPTF_Var_saveVars> |
| // <f_EPTF_Var_saveVars2tsp> |
| // <f_EPTF_Var_save> |
| // <f_EPTF_Var_load> |
| // <f_EPTF_Var_loadVarsFromCfg> |
| // <f_EPTF_Var_removeSelfName> |
| // <f_EPTF_Var_newInt> |
| // <f_EPTF_Var_newFloat> |
| // <f_EPTF_Var_newBool> |
| // <f_EPTF_Var_newCharstring> |
| // <f_EPTF_Var_newOctetstring> |
| // <f_EPTF_Var_newHexstring> |
| // <f_EPTF_Var_newBitstring> |
| // <f_EPTF_Var_newIntegerlist> |
| // <f_EPTF_Var_newFloatlist> |
| // <f_EPTF_Var_newCharstringlist> |
| // <f_EPTF_Var_newStatusLED> |
| // <f_EPTF_Var_isValid> |
| // <f_EPTF_Var_getIntValue> |
| // <f_EPTF_Var_getFloatValue> |
| // <f_EPTF_Var_getBoolValue> |
| // <f_EPTF_Var_getCharstringValue> |
| // <f_EPTF_Var_getOctetstringValue> |
| // <f_EPTF_Var_getHexstringValue> |
| // <f_EPTF_Var_getBitstringValue> |
| // <f_EPTF_Var_getIntegerlistValue> |
| // <f_EPTF_Var_getFloatlistValue> |
| // <f_EPTF_Var_getCharstringlistValue> |
| // <f_EPTF_Var_getStatusLEDValue> |
| // <f_EPTF_Var_getContent> |
| // <f_EPTF_Var_setContent> |
| // <f_EPTF_Var_updateRef> |
| // <f_EPTF_Var_getId> |
| // <f_EPTF_Var_getName> |
| // <f_EPTF_Var_intCompRef2Id> |
| // <f_EPTF_Var_Id2CompRef> |
| // <f_EPTF_Var_floatCompRef2Id> |
| // <f_EPTF_Var_boolCompRef2Id> |
| // <f_EPTF_Var_charstringCompRef2Id> |
| // <f_EPTF_Var_octetstringCompRef2Id> |
| // <f_EPTF_Var_hexstringCompRef2Id> |
| // <f_EPTF_Var_bitstringCompRef2Id> |
| // <f_EPTF_Var_integerlistCompRef2Id> |
| // <f_EPTF_Var_floatlistCompRef2Id> |
| // <f_EPTF_Var_charstringlistCompRef2Id> |
| // <f_EPTF_Var_statusLEDCompRef2Id> |
| // <f_EPTF_Var_getValueRef> |
| // <f_EPTF_Var_directContent2RefType> |
| // <f_EPTF_Var_subscribeLocal> |
| // <f_EPTF_Var_addLocalProviders> |
| // <f_EPTF_Var_removeLocalProviders> |
| // <f_EPTF_Var_isPresentRemote> |
| // <f_EPTF_Var_subscribeRemote> |
| // <f_EPTF_Var_resubscribeRemote> |
| // <f_EPTF_Var_isSubscribeRemoteFinished> |
| // <f_EPTF_Var_subscribeRemoteIntRef> |
| // <f_EPTF_Var_subscribeRemoteFloatRef> |
| // <f_EPTF_Var_subscribeRemoteBoolRef> |
| // <f_EPTF_Var_subscribeRemoteCharstringRef> |
| // <f_EPTF_Var_subscribeRemoteOctetstringRef> |
| // <f_EPTF_Var_subscribeRemoteHexstringRef> |
| // <f_EPTF_Var_subscribeRemoteBitstringRef> |
| // <f_EPTF_Var_subscribeRemoteIntegerlistRef> |
| // <f_EPTF_Var_subscribeRemoteFloatlistRef> |
| // <f_EPTF_Var_subscribeRemoteCharstringlistRef> |
| // <f_EPTF_Var_subscribeRemoteStatusLEDValRef> |
| // <f_EPTF_Var_subscribeRemoteRef> |
| // <f_EPTF_Var_unsubscribe> |
| // <f_EPTF_Var_callCalcFn> |
| // <f_EPTF_Var_callPostProcFns> |
| // <f_EPTF_Var_addPostProcFn> |
| // <f_EPTF_Var_removePostProcFn> |
| // <f_EPTF_Var_callGuardFns> |
| // <f_EPTF_Var_addGuardFn> |
| // <f_EPTF_Var_removeGuardFn> |
| // <f_EPTF_Var_callUnsubscribeNotifyFns> |
| // <f_EPTF_Var_addUnsubscribeNotifyFn> |
| // <f_EPTF_Var_removeUnsubscribeNotifyFn> |
| // <f_EPTF_Var_callSubsCanAdjustNotifyFns> |
| // <f_EPTF_Var_addSubsCanAdjustNotifyFn> |
| // <f_EPTF_Var_removeSubsCanAdjustNotifyFn> |
| // <f_EPTF_Var_callSyncCallBackFns> |
| // <f_EPTF_Var_addSyncCallBackFn> |
| // <f_EPTF_Var_removeSyncCallBackFn> |
| // <f_EPTF_Var_refreshContent> |
| // <f_EPTF_Var_getSubsCanAdjust> |
| // >f_EPTF_Var_setSubsCanAdjust> |
| // <f_EPTF_Var_adjustContent> |
| // <f_EPTF_Var_adjustContent_Blocking> |
| // <f_EPTF_Var_getRemoteContent> |
| // <f_EPTF_Var_adjustRemoteContent> |
| // <f_EPTF_Var_adjustRemoteContent_Blocking> |
| // <f_EPTF_Var_setMaxWaitTimeForByeAck> |
| // <f_EPTF_Var_getVarRefreshRate> |
| // <f_EPTF_Var_getRefreshPeriod> |
| // <f_EPTF_Var_getRefreshRate> |
| // <f_EPTF_Var_getRefreshRateId> |
| // <f_EPTF_Var_getTimeLine> |
| // <f_EPTF_Var_setSyncInterval> |
| // <f_EPTF_Var_setMinSyncInterval> |
| // <f_EPTF_Var_setMaxWaitTime> |
| // <f_EPTF_Var_content2str> |
| // <f_EPTF_Var_str2content> |
| // <f_EPTF_Var_content2string> |
| // <f_EPTF_Var_upcast> |
| // <f_EPTF_Var_downcast> |
| // <f_EPTF_Var_getIntRef> |
| // <f_EPTF_Var_derefInt> |
| // <f_EPTF_Var_modifyIntRefValue> |
| // <f_EPTF_Var_getFloatRef> |
| // <f_EPTF_Var_derefFloat> |
| // <f_EPTF_Var_modifyFloatRefValue> |
| // <f_EPTF_Var_getBoolRef> |
| // <f_EPTF_Var_derefBool> |
| // <f_EPTF_Var_modifyBoolRefValue> |
| // <f_EPTF_Var_getCharstringRef> |
| // <f_EPTF_Var_derefCharstring> |
| // <f_EPTF_Var_modifyCharstringRefValue> |
| // <f_EPTF_Var_getOctetstringRef> |
| // <f_EPTF_Var_derefOctetstring> |
| // <f_EPTF_Var_modifyOctetstringRefValue> |
| // <f_EPTF_Var_getHexstringRef> |
| // <f_EPTF_Var_derefHexstring> |
| // <f_EPTF_Var_modifyHexstringRefValue> |
| // <f_EPTF_Var_getBitstringRef> |
| // <f_EPTF_Var_derefBitstring> |
| // <f_EPTF_Var_modifyBitstringRefValue> |
| // <f_EPTF_Var_getIntegerlistRef> |
| // <f_EPTF_Var_derefIntegerlist> |
| // <f_EPTF_Var_modifyIntegerlistRefValue> |
| // <f_EPTF_Var_getFloatlistRef> |
| // <f_EPTF_Var_derefFloatlist> |
| // <f_EPTF_Var_modifyFloatlistRefValue> |
| // <f_EPTF_Var_getCharstringlistRef> |
| // <f_EPTF_Var_derefCharstringlist> |
| // <f_EPTF_Var_modifyCharstringlistRefValue> |
| // <f_EPTF_Var_getStatusLEDRef> |
| // <f_EPTF_Var_derefStatusLED> |
| // <f_EPTF_Var_modifyStatusLEDRefValue> |
| // |
| // <f_EPTF_Var_checkName> |
| // <f_EPTF_Var_directContent2str> |
| // <f_EPTF_Var_str2directContent> |
| // <f_EPTF_Var_removeVar> |
| // <f_EPTF_Var_getTopProviderType> |
| // <f_EPTF_Var_checkSubscriptionMode> |
| // <f_EPTF_Var_useCompRef2Id> |
| // <f_EPTF_Var_useName2Id> |
| // <f_EPTF_Var_getHashmap_Hashmap_CompRef2Id> |
| // <f_EPTF_Var_getHashmap_Name2Id> |
| // <f_EPTF_Var_enableDebug> |
| // <f_EPTF_Var_updateTimeLine> |
| // <f_EPTF_Var_sendTimeLine> |
| // <f_EPTF_Var_subscribeRemote_nonBlocking> |
| // |
| /////////////////////////////////////////////////////////////// |
| |
| module EPTF_CLL_Variable_Functions { |
| |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Base_Definitions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Common_Definitions all; // EPTF_IntegerList |
| import from EPTF_CLL_Common_Functions all; |
| import from EPTF_CLL_HashMapStr2Int_Functions all; |
| import from EPTF_CLL_HashMapOct2Int_Functions all; |
| import from TCCFileIO_Functions all; |
| import from TCCDateTime_Functions all; |
| import from EPTF_CLL_Logging_Definitions all; |
| import from EPTF_CLL_Logging_Functions all; |
| import from EPTF_CLL_Scheduler_Definitions all; |
| import from EPTF_CLL_RBTScheduler_Functions all; |
| import from EPTF_CLL_HashMap_Functions all; |
| import from EPTF_CLL_FBQ_Functions all; |
| |
| modulepar boolean tsp_EPTF_Var_enableName2Id := true; // if true hashmap database is maintained to get the id from a variable name |
| modulepar boolean tsp_EPTF_Var_enableCompRef2Id := true; // if true hashmap database is maintained to get the id from a component variable |
| modulepar boolean tsp_EPTF_Var_enableEmptyTimeLine := false; // if true timeline message will always be sent at the sync-time even if empty |
| |
| modulepar float tsp_EPTF_Var_maxWaitTime := 120.0; // the max time to wait for responses (default: 120.0 sec) |
| modulepar float tsp_EPTF_Var_maxWaitTimeForByeAck := 240.0; // the max time to wait for ByeAck messages (default: 240.0 sec) |
| modulepar boolean tsp_EPTF_Var_debug := false; // switch on debugging |
| modulepar EPTF_Var_InitialValueList tsp_EPTF_Var_cfg := {}; // the initial value list of variables to load |
| |
| |
| ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| // public: |
| ////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Group: Public |
| // |
| // Purpose: |
| // Public functions. Only these functions can be used by the user of <EPTF_Var_CT> |
| // |
| // Elements: |
| /////////////////////////////////////////////////////////// |
| group Public { |
| |
| // LOGGING |
| |
| /////////////////////////////////////////////////////////// |
| // Group: Logging |
| // |
| // Purpose: |
| // Logging functions. |
| // |
| // Elements: |
| /////////////////////////////////////////////////////////// |
| group Logging { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_CT_LogAll |
| // |
| // Purpose: |
| // Log everything (important) in <EPTF_Var_CT> component |
| // |
| // Parameters: |
| // pl_msg - *in* *charstring* - message to log. It is printed before and after the component data |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_CT_LogAll(in charstring pl_msg) runs on EPTF_Var_CT { |
| if (pl_msg!="") { |
| f_EPTF_Var_debug(pl_msg); |
| }; |
| f_EPTF_Var_debug(log2str("EPTF_Var_CT.v_EPTF_Vars: ", v_EPTF_Vars)); |
| f_EPTF_Var_debug(log2str("EPTF_Var_CT.v_syncBuffer: ", v_syncBuffer)); |
| f_EPTF_Var_debug(log2str("EPTF_Var_CT.adjustContentResp_handler_ParamStack:", adjustContentResp_handler_ParamStack)); |
| f_EPTF_Var_debug(log2str("EPTF_Var_CT.v_EPTF_Var_varsToSave", v_EPTF_Var_varsToSave)); |
| if (pl_msg!="") { |
| f_EPTF_Var_debug(pl_msg); |
| }; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_Log |
| // |
| // Purpose: |
| // Log a given EPTF Variable |
| // |
| // Parameters: |
| // pl_msg - *in* *charstring* - message to log. It is printed before and after the variable data |
| // pl_idx - *in* *integer* - the idx of the EPTF Variable to log |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_Log(in charstring pl_msg, in integer pl_idx) runs on EPTF_Var_CT { |
| if (pl_msg!="") { |
| f_EPTF_Var_debug(pl_msg); |
| }; |
| f_EPTF_Var_debug(log2str("EPTF_Var_CT.v_EPTF_Vars[",pl_idx,"]: ", v_EPTF_Vars[pl_idx])); |
| if (pl_msg!="") { |
| f_EPTF_Var_debug(pl_msg); |
| }; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_logNames |
| // |
| // Purpose: |
| // Log all variable names |
| // |
| // Parameters: |
| // pl_msg - *in* *charstring* - message to log. It is printed before and after the variable data |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_logNames(in charstring pl_msg) runs on EPTF_Var_CT { |
| if (pl_msg!="") { |
| f_EPTF_Var_debug(pl_msg); |
| }; |
| for(var integer i:=0; i<sizeof(v_EPTF_Vars); i:=i+1) { |
| f_EPTF_Var_debug(log2str("Name of v_EPTF_Vars[",i,"]: ", v_EPTF_Vars[i].name)); |
| } |
| if (pl_msg!="") { |
| f_EPTF_Var_debug(pl_msg); |
| }; |
| } |
| |
| } // group Logging |
| |
| /////////////////////////////////////////////////////////// |
| // Group: CompInit |
| // |
| // Purpose: |
| // Functions to initialize the <EPTF_Var_CT> component. |
| // |
| // Elements: |
| /////////////////////////////////////////////////////////// |
| group CompInit { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_init_CT |
| // |
| // Purpose: |
| // Initializes the EPTF_Var_CT component |
| // |
| // Parameters: |
| // pl_selfName - *in* *charstring* - name of the component |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function should be called before using the EPTF Variable |
| // component. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_init_CT(in charstring pl_selfName) runs on EPTF_Var_CT { |
| if (v_EPTF_Var_initialized) { |
| // set the priority of the altstep to the highest by reactivating it: |
| deactivate(v_EPTF_Var_def); |
| v_EPTF_Var_def := activate(as_EPTF_Var_mainHandler_MgmtIf()); |
| return; // already initialized |
| } |
| |
| // activate with lowest priority (befor the init function calls): |
| v_EPTF_Var_def := activate(as_EPTF_Var_mainHandler_MgmtIf()); |
| |
| f_EPTF_Base_init_CT(pl_selfName); |
| |
| f_EPTF_FBQ_init_CT(pl_selfName); |
| |
| f_EPTF_Scheduler_init_CT(pl_selfName); |
| |
| f_EPTF_Logging_init_CT(pl_selfName); |
| |
| f_EPTF_HashMap_init_CT (pl_selfName); |
| |
| f_EPTF_Var_setMaxWaitTime(tsp_EPTF_Var_maxWaitTime);//HM27497 |
| v_Var_loggingMaskId := f_EPTF_Logging_registerComponentMasks(tsp_EPTF_Var_loggingComponentMask, c_EPTF_Var_loggingEventClasses, EPTF_Logging_CLL); |
| if(tsp_EPTF_Var_debug) { |
| f_EPTF_Logging_enableLocalMask(v_Var_loggingMaskId, c_EPTF_Var_loggingClassIdx_Debug); |
| } else { |
| f_EPTF_Logging_disableLocalMask(v_Var_loggingMaskId, c_EPTF_Var_loggingClassIdx_Debug); |
| } |
| |
| v_EPTF_Var_enableName2Id := tsp_EPTF_Var_enableName2Id; |
| v_EPTF_Var_enableCompRef2Id := tsp_EPTF_Var_enableCompRef2Id; |
| if (v_EPTF_Var_enableName2Id) { |
| v_EPTF_Var_Hashmap_Name2Id := f_EPTF_str2int_HashMap_New("EPTF_Var_Hashmap_Name2Id"); |
| } |
| if (v_EPTF_Var_enableCompRef2Id) { |
| v_EPTF_Var_Hashmap_CompRef2Id := f_EPTF_oct2int_HashMap_New("EPTF_Var_Hashmap_CompRef2Id"); |
| } |
| |
| v_EPTF_Var_Hashmap_Provider2Id := f_EPTF_str2int_HashMap_New("EPTF_Var_Hashmap_Provider2Id"); |
| |
| v_EPTF_Var_Hashmap_SyncBuffer := f_EPTF_str2int_HashMap_New("EPTF_Var_Hashmap_SyncBuffer"); |
| |
| v_EPTF_Vars := {}; |
| var integer vl_refreshRateId := 0; |
| v_syncBuffer[vl_refreshRateId].refreshRate := 0; // default refresh method |
| v_syncBuffer[vl_refreshRateId].eventIdx := -1; // invalid index |
| v_syncBuffer[vl_refreshRateId].syncBuffer := {}; |
| v_syncInterval := tsp_EPTF_Var_SyncInterval; |
| v_minSyncInterval := tsp_EPTF_ELEMENTARY_TIMESTEP_PARAM; |
| if(f_EPTF_SchedulerComp_scheduleAction( |
| pl_when := f_EPTF_Base_getRelTimeInSecs()+v_syncInterval, |
| pl_actionHandler := refers(f_EPTF_Var_syncTimeoutHandler), |
| pl_action := {vl_refreshRateId}, |
| pl_eventIndex := v_syncBuffer[vl_refreshRateId].eventIdx |
| )){/*remove the warning*/}; |
| v_EPTF_Var_syncCallbackFns := {}; |
| v_EPTF_Var_varsToSave := {}; |
| f_EPTF_initEPTF_Var_adjustContentResp_handlerPool(adjustContentResp_handler_ParamStack); |
| f_EPTF_initbooleanPool(v_booleanPool); |
| v_EPTF_Var_pendingByeNum := 0; |
| v_EPTF_Var_varsToUpdate := {}; |
| f_EPTF_Var_setRefreshSubscribersPeriod(); |
| v_EPTF_Var_numPendingHellos := 0; |
| v_EPTF_Var_maxWaitTimeForByeAck := tsp_EPTF_Var_maxWaitTimeForByeAck; |
| |
| |
| v_EPTF_Var_Msg_Buffer := {}; |
| v_EPTF_Var_Msg_BufferStartIdx := 0; |
| v_EPTF_Var_nofPendingMsgs := 0; |
| |
| v_EPTF_Var_Connections := {}; |
| v_EPTF_Var_resubscribeRemoteResp_handler_DB := {}; |
| v_EPTF_Var_msgBufferBeforeConnect := {}; |
| v_EPTF_Var_nonBlockingEnabled := {}; |
| |
| v_EPTF_Var_initialized := true; |
| |
| f_EPTF_Base_registerCleanup(refers(f_EPTF_Var_cleanup_CT)); |
| |
| f_EPTF_Var_debug("---- EPTF_Variable INIT "&pl_selfName&" DONE ----"); |
| } |
| |
| } // group CompInit |
| |
| /////////////////////////////////////////////////////////// |
| // Group: VaribleCreationValueAssignment |
| // |
| // Purpose: |
| // Functions to create EPTF Variables and and assign value. |
| // |
| // Elements: |
| /////////////////////////////////////////////////////////// |
| group VaribleCreationValueAssignment { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newIntRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *integer* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newIntRef(in charstring pl_name, inout integer pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getIntRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=intType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newFloatRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *float* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newFloatRef(in charstring pl_name, inout float pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getFloatRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=floatType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newBoolRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *boolean* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newBoolRef(in charstring pl_name, inout boolean pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getBoolRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=boolType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newCharstringRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *charstring* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newCharstringRef(in charstring pl_name, inout charstring pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getCharstringRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=charstringType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newOctetstringRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *octetstring* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newOctetstringRef(in charstring pl_name, inout octetstring pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getOctetstringRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=octetstringType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newHexstringRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *hexstring* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newHexstringRef(in charstring pl_name, inout hexstring pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getHexstringRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=hexstringType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newBitstringRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *bitstring* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newBitstringRef(in charstring pl_name, inout bitstring pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getBitstringRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=bitstringType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newIntegerlistRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* <EPTF_IntegerList> - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newIntegerlistRef(in charstring pl_name, inout EPTF_IntegerList pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getIntegerlistRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=integerlistType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newFloatlistRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* <EPTF_FloatList> - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newFloatlistRef(in charstring pl_name, inout EPTF_FloatList pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getFloatlistRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=floatlistType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newCharstringlistRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* <EPTF_CharstringList> - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newCharstringlistRef(in charstring pl_name, inout EPTF_CharstringList pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getCharstringlistRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=charstringlistType, valueRef := vl_valueRef}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newStatusLEDRef |
| // |
| // Purpose: |
| // Creates a new EPTF_Var that is a reference to an existing component variable |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_compVar - *inout* *EPTF_StatusLED* - component variable for which the EPTF Variable is assigned |
| // pl_idx - *out* *integer* - the idx of the assigned new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newStatusLEDRef(in charstring pl_name, inout EPTF_StatusLED pl_compVar, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| var octetstring vl_valueRef := f_EPTF_Var_getStatusLEDRef(pl_compVar); |
| f_EPTF_Var_initContentRef(pl_idx, {refType:=statusLEDType, valueRef := vl_valueRef}); |
| } |
| //... |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newVar |
| // |
| // Purpose: |
| // Creates a new EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* <EPTF_Var_DirectContent> - initial value of the variable |
| // |
| // Return Value: |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newVar(in charstring pl_name, in EPTF_Var_DirectContent pl_initValue) runs on EPTF_Var_CT return integer { |
| var integer pl_idx; |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, pl_initValue); |
| return pl_idx; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_createVarFromCfg |
| // |
| // Purpose: |
| // Creates a new EPTF_Var and sets its initial value from cfg data |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable to create automatically if found in the pl_cfg |
| // pl_cfg - *in* <EPTF_Var_InitialValueList> - List of initial values of the variables to search for pl_name. Default: tsp_EPTF_Var_cfg |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the created variable will be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the created variable name will be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_createVarFromCfg(in charstring pl_name, in EPTF_Var_InitialValueList pl_cfg := tsp_EPTF_Var_cfg, in boolean pl_removeSelfNameFromParamName := true) runs on EPTF_Var_CT return integer |
| { |
| |
| for (var integer i:= 0; i<sizeof(pl_cfg); i:=i+1) { |
| if (f_EPTF_Base_selfName()&"."&pl_name == pl_cfg[i].name and pl_removeSelfNameFromParamName) { |
| return f_EPTF_Var_newVar(pl_name, pl_cfg[i].initValue); |
| } |
| if (pl_name == pl_cfg[i].name and not pl_removeSelfNameFromParamName) { |
| return f_EPTF_Var_newVar(pl_name, pl_cfg[i].initValue); |
| } |
| } |
| return -1; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_loadVarFromCfg |
| // |
| // Purpose: |
| // Loads a the value of an existing EPTF_Var and sets its initial value from cfg data |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable to load if found in the pl_cfg |
| // pl_cfg - *in* <EPTF_Var_InitialValueList> - List of initial values of the variables to search for pl_name. Default: tsp_EPTF_Var_cfg |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // pl_idx - *out* *integer* - the idx of the loaded EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_loadVarFromCfg(in charstring pl_name, in EPTF_Var_InitialValueList pl_cfg := tsp_EPTF_Var_cfg, in boolean pl_removeSelfNameFromParamName := true) runs on EPTF_Var_CT return integer |
| { |
| if (pl_name=="") { |
| return -1; // variables with empty names are not loaded |
| } |
| var integer vl_idx := f_EPTF_Var_getId(pl_name); |
| if (vl_idx == -1) { |
| f_EPTF_Var_warning(log2str("Cannot load Variable ", pl_name, " from config: Variable does not exist.")); |
| return -1; // variable does not exist |
| } |
| var charstring vl_name := pl_name; // cfg file name and variable name is the same |
| if (pl_removeSelfNameFromParamName) { |
| vl_name := f_EPTF_Base_selfName()&"."&pl_name; // cfg file name contains selfName, but variable name does not |
| } |
| for (var integer i:= 0; i<sizeof(pl_cfg); i:=i+1) { |
| if (vl_name == pl_cfg[i].name) { |
| f_EPTF_Var_adjustContent(vl_idx, pl_cfg[i].initValue); |
| return vl_idx; |
| } |
| } |
| f_EPTF_Var_warning(log2str("No entry found for Variable ", vl_name, " in config. Variable ",pl_name," is not loaded.")); |
| return -1; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_saveVarToCfg |
| // |
| // Purpose: |
| // Saves a the value of the given EPTF_Var to cfg data |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable to load if found in the pl_cfg |
| // pl_cfg - *out* <EPTF_Var_InitialValueList> - Initial value of the variable with its name |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is not used. Would be useful if there were a toStr function for EPTF_Var_InitialValue |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_saveVarToCfg(in charstring pl_name, out EPTF_Var_InitialValue pl_cfg, in boolean pl_removeSelfNameFromParamName := true) runs on EPTF_Var_CT |
| { |
| var integer vl_idx := f_EPTF_Var_getId(pl_name); |
| if (vl_idx == -1) { |
| pl_cfg := { |
| name := "-NOTFOUND: in component "&f_EPTF_Base_selfName()&": "&pl_name&"-", |
| initValue := {intVal := -1} |
| } |
| return; |
| } |
| // f_EPTF_Base_assert("Cannot save Variable " &pl_name& " to config: Variable does not exist.", vl_idx != -1); |
| if (pl_removeSelfNameFromParamName) { |
| pl_cfg.name := f_EPTF_Base_selfName()&"."&pl_name; // cfg file name contains selfName, but variable name does not |
| } else { |
| pl_cfg.name := pl_name; // cfg file name and variable name is the same |
| } |
| f_EPTF_Var_debug(log2str("saved to: ", pl_cfg)); |
| f_EPTF_Var_getContent(vl_idx,pl_cfg.initValue); |
| //var charstring vl_contentStr := f_EPTF_Var_content2string(pl_cfg.initValue); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_saveVarToCfgStr |
| // |
| // Purpose: |
| // Saves a the value of the given EPTF_Var to cfg string |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable to load if found in the pl_cfg |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // charstring - Value of the variable in loadable format |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_saveVarToCfgStr(in charstring pl_name, in boolean pl_removeSelfNameFromParamName := true) runs on EPTF_Var_CT return charstring |
| { |
| var integer vl_idx := f_EPTF_Var_getId(pl_name); |
| if (vl_idx == -1) { |
| return ""; // if not found: do not save |
| } |
| var charstring vl_contentStr := f_EPTF_Var_content2string(vl_idx); |
| var charstring vl_name := pl_name; // cfg file name and variable name is the same |
| if (pl_removeSelfNameFromParamName) { |
| vl_name := f_EPTF_Base_selfName()&"."&pl_name; // cfg file name contains selfName, but variable name does not |
| } |
| return "{ name := \""&vl_name&"\", initValue := "&vl_contentStr&" }" |
| |
| // var EPTF_Var_InitialValue vl_cfg; |
| // f_EPTF_Var_saveVarToCfg(pl_name,vl_cfg,pl_removeSelfNameFromParamName); |
| // var charstring vl_contentStr := f_EPTF_Var_directContent2string(vl_cfg.initValue); |
| // return "{ name := "&vl_cfg.name&", initValue := "&vl_contentStr&" }" |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_registerVarToSave |
| // |
| // Purpose: |
| // Registers a variable name that will be saved |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // Does not check if variable exists ( => it is possible to register variables before they are created) |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_registerVarToSave(in charstring pl_name) runs on EPTF_Var_CT { |
| if (pl_name=="") { |
| return; // variables with empty names are not saved |
| } |
| v_EPTF_Var_varsToSave[sizeof(v_EPTF_Var_varsToSave)] := pl_name; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_deregisterVarFromSave |
| // |
| // Purpose: |
| // Removes a variable name from the list of varibles registered by <f_EPTF_Var_registerVarToSave> |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // Does not check if variable exists ( => it is possible to deregister variables before they are created) |
| // |
| /////////////////////////////////////////////////////////// |
| |
| public function f_EPTF_Var_deregisterVarFromSave(in charstring pl_name) runs on EPTF_Var_CT { |
| if (pl_name=="") { |
| return; // variables with empty names are not saved |
| } |
| for (var integer i:=0; i<sizeof(v_EPTF_Var_varsToSave); i:=i+1) { |
| if (v_EPTF_Var_varsToSave[i] == pl_name) { |
| v_EPTF_Var_varsToSave[i] := ""; |
| } |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_saveVars |
| // |
| // Purpose: |
| // Saves all registered variables in cfg format |
| // |
| // Parameters: |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // charstring - Value of the variables in loadable format |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_saveVars(in boolean pl_removeSelfNameFromParamName := true) runs on EPTF_Var_CT return charstring { |
| var charstring vl_result := ""; |
| for(var integer i:=0; i<sizeof(v_EPTF_Var_varsToSave); i:=i+1) { |
| var charstring vl_saveStr := f_EPTF_Var_saveVarToCfgStr(v_EPTF_Var_varsToSave[i],pl_removeSelfNameFromParamName); |
| if (vl_saveStr!="") { |
| if (vl_result!="") { |
| vl_result := vl_result&",\n"; // add comma if necessary |
| } |
| vl_result := vl_result & vl_saveStr; |
| } |
| } |
| return vl_result; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_saveVars2tsp |
| // |
| // Purpose: |
| // Saves all registered variables in a module parameter tsp_xxx := {***} format |
| // |
| // Parameters: |
| // pl_moduleParName - *in charstring* - the module parameter name to save the values into. Default: tsp_EPTF_Var_cfg |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // charstring - Value of the variables in loadable format |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_saveVars2tsp( |
| in charstring pl_moduleParName := "tsp_EPTF_Var_cfg", |
| in boolean pl_removeSelfNameFromParamName := true |
| ) runs on EPTF_Var_CT return charstring { |
| return pl_moduleParName & " := {\n" &f_EPTF_Var_saveVars(pl_removeSelfNameFromParamName)& "\n}\n\n"; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_save |
| // |
| // Purpose: |
| // Saves all registered variables in a file as module parameter tsp_xxx := {***} format |
| // |
| // Parameters: |
| // pl_fileName - *in charstring* - the filename where the variables shall be saved (default: <tsp_EPTF_Var_snapshotFilename>) |
| // pl_timeStampFormat - *in charstring* - the format of the timestamp in the generated filename (pl_fileName<timestamp>). |
| // Can be anything, even empty string. For the supported time-format strings see <f_getTimeFormatted>. Default: tsp_EPTF_Var_snapshotTimestamp |
| // pl_moduleparName - *in charstring* - the module parameter name to save the values into. Default: tsp_EPTF_Var_<selfname>_cfg |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: false |
| // |
| // Return Value: |
| // charstring - name of the file the snapshot was saved in. Empty string ("") is returned on error. |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // The name of the file will be: pl_fileName + timestamp |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_save( |
| in charstring pl_fileName := tsp_EPTF_Var_snapshotFilename, |
| in charstring pl_timeStampFormat := tsp_EPTF_Var_snapshotTimestamp, |
| in charstring pl_moduleparName := "", |
| in boolean pl_removeSelfNameFromParamName := false |
| ) runs on EPTF_Var_CT return charstring { |
| var charstring vl_moduleparName := pl_moduleparName; |
| if (vl_moduleparName == "") { |
| vl_moduleparName := "tsp_EPTF_Var_"&f_EPTF_Base_selfName()&"_cfg" |
| } |
| var charstring vl_saveString := "[MODULE_PARAMETERS]\n"&f_EPTF_Var_saveVars2tsp(vl_moduleparName,pl_removeSelfNameFromParamName); |
| var charstring vl_timeStamp := f_getTimeFormatted(float2int(f_EPTF_Base_getAbsTimeInSecs(f_EPTF_SchedulerComp_snapshotTime())),pl_timeStampFormat); |
| var charstring vl_filename := pl_fileName; |
| if (vl_filename=="") { // if pl_fileName=="" the file name will be <selfname><timestamp> |
| vl_filename := f_EPTF_Base_selfName(); |
| } |
| vl_filename := vl_filename&vl_timeStamp; |
| f_EPTF_Var_debug(log2str("vl_filename: ", vl_filename)); |
| f_EPTF_Var_debug(log2str("vl_saveString: ", vl_saveString)); |
| // use filio to save the string to file. // FIXME |
| var integer vl_fd := f_FIO_open_append_wronly_excl(vl_filename); |
| if (vl_fd == -1) { |
| f_EPTF_Var_warning(log2str("f_EPTF_Var_save: cannot open file ", vl_filename, ": ", f_FIO_get_error_string())); |
| return ""; |
| } |
| var charstring vl_fileNameSaved := vl_filename; |
| if (f_FIO_write_text(vl_fd, vl_saveString) == -1) { |
| f_EPTF_Var_warning(log2str("f_EPTF_Var_save: cannot save EPTF_Variable data to file ", vl_filename, ": ", f_FIO_get_error_string())); |
| return ""; |
| }; |
| if (-1==f_FIO_close(vl_fd)) {/*to remove the warning*/}; |
| return vl_filename; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_load |
| // |
| // Purpose: |
| // Loads all variables in a file that was saved earlier by <f_EPTF_Var_save> |
| // |
| // Parameters: |
| // pl_fileName - *in charstring* - the filename from where the variables shall be loaded (default: <tsp_EPTF_Var_snapshotFilename>) |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variable should be the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. the component name (selfName) is |
| // removed from the name of the variable. Default: false |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // Not implemented yet! Inverse of log2str or parsing needed |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_load( |
| in charstring pl_fileName := tsp_EPTF_Var_snapshotFilename, |
| in boolean pl_removeSelfNameFromParamName := false |
| ) runs on EPTF_Var_CT { |
| // f_EPTF_Var_loadVarsFromCfg(pl_cfg,pl_removeSelfNameFromParamName); |
| return; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_loadVarsFromCfg |
| // |
| // Purpose: |
| // Load all variables that exists in the current component from the initial value list parameter |
| // |
| // Parameters: |
| // pl_cfg - *in* <EPTF_Var_InitialValueList> - List of initial values of the variables to load. Default: tsp_EPTF_Var_cfg |
| // pl_removeSelfNameFromParamName - *in boolean* - if false, the name of the variables are the same as in the pl_cfg. |
| // If true, the <selfName>&"."&pl_name name is searched in pl_cfg, and the variable name should be pl_name, i.e. |
| // the component name (selfName) is removed from the name of the variable. Default: true |
| // |
| // Return Value: |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_loadVarsFromCfg(in EPTF_Var_InitialValueList pl_cfg := tsp_EPTF_Var_cfg, in boolean pl_removeSelfNameFromParamName := true |
| ) runs on EPTF_Var_CT { |
| var charstring vl_varName; |
| for(var integer i:=0; i<sizeof(pl_cfg); i:=i+1) { |
| if (pl_removeSelfNameFromParamName) { |
| // load only if the name begins with selfname |
| vl_varName := f_EPTF_Var_removeSelfName(pl_cfg[i].name); |
| } else { |
| vl_varName := pl_cfg[i].name; |
| } |
| if (vl_varName != "") { |
| // f_EPTF_Var_loadVarFromCfg(vl_varName,pl_cfg,pl_removeSelfNameFromParamName); |
| var integer vl_idx := f_EPTF_Var_getId(vl_varName); |
| if (vl_idx >= 0) { |
| f_EPTF_Var_adjustContent(vl_idx, pl_cfg[i].initValue); |
| } else { |
| f_EPTF_Var_warning(log2str("Cannot load Variable ", vl_varName, " from config: Variable does not exist.")); |
| } |
| } |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_removeSelfName |
| // |
| // Purpose: |
| // Removes selfName from the name (with the dot) and returns the rest. returns "" if selfName cannot be removed |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - a name (of the variable) to remove the selfName from |
| // |
| // Return Value: |
| // charstring - the name without "<selfName>.", or "" of selfName cannot be removed |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_removeSelfName(in charstring pl_name) runs on EPTF_Var_CT return charstring { |
| if (pl_name=="") { |
| return ""; |
| } |
| if (lengthof(f_EPTF_Base_selfName())+1<lengthof(pl_name) // +1 is for the dot; the rest should not be an empty string |
| and substr(pl_name,0,lengthof(f_EPTF_Base_selfName())) == f_EPTF_Base_selfName() |
| ) { |
| // remove the selfname (+1 is the dot): |
| return substr(pl_name, lengthof(f_EPTF_Base_selfName())+1, lengthof(pl_name)-lengthof(f_EPTF_Base_selfName())-1); |
| } else { |
| return ""; |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newInt |
| // |
| // Purpose: |
| // Creates a new integer-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *integer* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newInt(in charstring pl_name, in integer pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {intVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newFloat |
| // |
| // Purpose: |
| // Creates a new float-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *float* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newFloat(in charstring pl_name, in float pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {floatVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newBool |
| // |
| // Purpose: |
| // Creates a new boolean-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *boolean* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newBool(in charstring pl_name, in boolean pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {boolVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newCharstring |
| // |
| // Purpose: |
| // Creates a new charstring-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *charstring* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newCharstring(in charstring pl_name, in charstring pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {charstringVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newOctetstring |
| // |
| // Purpose: |
| // Creates a new octetstring-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *octetstring* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newOctetstring(in charstring pl_name, in octetstring pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {octetstringVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newHexstring |
| // |
| // Purpose: |
| // Creates a new hexstring-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *hexstring* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newHexstring(in charstring pl_name, in hexstring pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {hexstringVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newBitstring |
| // |
| // Purpose: |
| // Creates a new bitstring-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *bitstring* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newBitstring(in charstring pl_name, in bitstring pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {bitstringVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newIntegerlist |
| // |
| // Purpose: |
| // Creates a new EPTF_IntegerList-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* <EPTF_IntegerList> - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newIntegerlist(in charstring pl_name, in EPTF_IntegerList pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {integerlistVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newFloatlist |
| // |
| // Purpose: |
| // Creates a new EPTF_FloatList-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* <EPTF_FloatList> - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newFloatlist(in charstring pl_name, in EPTF_FloatList pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {floatlistVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newCharstringlist |
| // |
| // Purpose: |
| // Creates a new EPTF_CharstringList-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* <EPTF_CharstringList> - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newCharstringlist(in charstring pl_name, in EPTF_CharstringList pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {charstringlistVal := pl_initValue}); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_newStatusLED |
| // |
| // Purpose: |
| // Creates a new EPTF_StatusLED-type EPTF_Var and sets its initial value |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // pl_initValue - *in* *EPTF_StatusLED* - initial value of the variable |
| // pl_idx - *out* *integer* - the idx of the created new EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_newStatusLED(in charstring pl_name, in EPTF_StatusLED pl_initValue, out integer pl_idx) runs on EPTF_Var_CT { |
| f_EPTF_Var_addNew(pl_idx, pl_name); |
| f_EPTF_Var_initContent(pl_idx, {statusLEDVal := pl_initValue}); |
| } |
| //... |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_isValid |
| // |
| // Purpose: |
| // Returns true if the variable has valid content |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *boolean* - true if the variable has valid content |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_isValid(in integer pl_idx) runs on EPTF_Var_CT return boolean { |
| return not ischosen(v_EPTF_Vars[pl_idx].content.invalid); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getIntValue |
| // |
| // Purpose: |
| // Returns the value as an integer of a direct EPTF_Var or the dereffed value of a referenced intType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *integer* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not an integer referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getIntValue(in integer pl_idx) runs on EPTF_Var_CT return integer { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.intVal)) { |
| f_EPTF_Var_error(log2str("Integer value is requested for the EPTF_Var[",pl_idx,"] which has non-integer content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.intVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.intVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != intType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not an intType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefInt(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return -1; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getFloatValue |
| // |
| // Purpose: |
| // Returns the value as a float of a direct EPTF_Var or the dereffed value of a referenced floatType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *float* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a float referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getFloatValue(in integer pl_idx) runs on EPTF_Var_CT return float { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.floatVal)) { |
| f_EPTF_Var_error(log2str("Float value is requested for the EPTF_Var[",pl_idx,"] which has non-float content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.floatVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.floatVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != floatType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not a floatType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefFloat(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return -1.0; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getBoolValue |
| // |
| // Purpose: |
| // Returns the value as a boolean of a direct EPTF_Var or the dereffed value of a referenced boolType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *boolean* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a boolean referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getBoolValue(in integer pl_idx) runs on EPTF_Var_CT return boolean { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.boolVal)) { |
| f_EPTF_Var_error(log2str("Boolean value is requested for the EPTF_Var[",pl_idx,"] which has non-boolean content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.boolVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.boolVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != boolType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not a boolType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefBool(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return false; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getCharstringValue |
| // |
| // Purpose: |
| // Returns the value as a charstring of a direct EPTF_Var or the dereffed value of a referenced charstringType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *charstring* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a charstring referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getCharstringValue(in integer pl_idx) runs on EPTF_Var_CT return charstring { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.charstringVal)) { |
| f_EPTF_Var_error(log2str("Charstring value is requested for the EPTF_Var[",pl_idx,"] which has non-charstring content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.charstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.charstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != charstringType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not a charstringType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefCharstring(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return ""; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getOctetstringValue |
| // |
| // Purpose: |
| // Returns the value as a octetstring of a direct EPTF_Var or the dereffed value of a referenced octetstringType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *octetstring* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a charstring referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getOctetstringValue(in integer pl_idx) runs on EPTF_Var_CT return octetstring { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.octetstringVal)) { |
| f_EPTF_Var_error(log2str("Octetstring value is requested for the EPTF_Var[",pl_idx,"] which has non-octetstring content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.octetstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.octetstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != octetstringType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not an octetstringType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefOctetstring(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return ''O; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getHexstringValue |
| // |
| // Purpose: |
| // Returns the value as a hexstring of a direct EPTF_Var or the dereffed value of a referenced hexstringType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *hexstring* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a hexstring referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getHexstringValue(in integer pl_idx) runs on EPTF_Var_CT return hexstring { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.hexstringVal)) { |
| f_EPTF_Var_error(log2str("Hexstring value is requested for the EPTF_Var[",pl_idx,"] which has non-hexstring content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.hexstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.hexstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != hexstringType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not a hexstringType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefHexstring(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return ''H; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getBitstringValue |
| // |
| // Purpose: |
| // Returns the value as a bitstring of a direct EPTF_Var or the dereffed value of a referenced bitstringType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *bitstring* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a bitstring referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getBitstringValue(in integer pl_idx) runs on EPTF_Var_CT return bitstring { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.bitstringVal)) { |
| f_EPTF_Var_error(log2str("Bitstring value is requested for the EPTF_Var[",pl_idx,"] which has non-bitstring content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.bitstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.bitstringVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != bitstringType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not a bitstringType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefBitstring(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return ''B; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getIntegerlistValue |
| // |
| // Purpose: |
| // Returns the value as an EPTF_IntegerList of a direct EPTF_Var or the dereffed value of a referenced integerlistType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *EPTF_IntegerList* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a EPTF_IntegerList referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getIntegerlistValue(in integer pl_idx) runs on EPTF_Var_CT return EPTF_IntegerList { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.integerlistVal)) { |
| f_EPTF_Var_error(log2str("Integerlist value is requested for the EPTF_Var[",pl_idx,"] which has non-integerlist content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.integerlistVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.integerlistVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != integerlistType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not an integerlistType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefIntegerlist(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return {}; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getFloatlistValue |
| // |
| // Purpose: |
| // Returns the value as an EPTF_FloatList of a direct EPTF_Var or the dereffed value of a referenced floatlistType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *EPTF_FloatList* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a EPTF_FloatList referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getFloatlistValue(in integer pl_idx) runs on EPTF_Var_CT return EPTF_FloatList { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.floatlistVal)) { |
| f_EPTF_Var_error(log2str("Floatlist value is requested for the EPTF_Var[",pl_idx,"] which has non-floatlist content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.floatlistVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.floatlistVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != floatlistType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not an floatlistType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefFloatlist(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return {}; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getCharstringlistValue |
| // |
| // Purpose: |
| // Returns the value as an EPTF_CharstringList of a direct EPTF_Var or the dereffed value of a referenced CharstringlistType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *EPTF_CharstringList* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a EPTF_CharstringList referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getCharstringlistValue(in integer pl_idx) runs on EPTF_Var_CT return EPTF_CharstringList { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.charstringlistVal)) { |
| f_EPTF_Var_error(log2str("Charstringlist value is requested for the EPTF_Var[",pl_idx,"] which has non-charstringlist content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.charstringlistVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.charstringlistVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != charstringlistType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not an charstringlistType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefCharstringlist(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return {}; // just to remove the warning, this is never executed |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getStatusLEDValue |
| // |
| // Purpose: |
| // Returns the value as an EPTF_StatusLED of a direct EPTF_Var or the dereffed value of a referenced statusLEDType EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *EPTF_StatusLED* - the (dereferenced) value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a EPTF_StatusLED referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getStatusLEDValue(in integer pl_idx) runs on EPTF_Var_CT return EPTF_StatusLED { |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull) or f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| var EPTF_Var_DirectContent vl_currentContent; |
| f_EPTF_Var_getContent(pl_idx,vl_currentContent); |
| if (not ischosen(vl_currentContent.statusLEDVal)) { |
| f_EPTF_Var_error(log2str("StatusLED value is requested for the EPTF_Var[",pl_idx,"] which has non-statusLED content")); |
| //f_EPTF_Base_stop(); |
| } |
| return vl_currentContent.statusLEDVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| return v_EPTF_Vars[pl_idx].content.direct.statusLEDVal; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != statusLEDType) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] content is not a statusLEDType reference")); |
| //f_EPTF_Base_stop(); |
| } |
| return f_EPTF_Var_derefStatusLED(v_EPTF_Vars[pl_idx].content.reference.valueRef); |
| } |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] has invalid content")); |
| //f_EPTF_Base_stop(); |
| return {color:=led_black, text := ""}; // just to remove the warning, this is never executed |
| } |
| //... |
| |
| /* use f_EPTF_Var_setContent instead! |
| // set the intValue of a direct EPTF_Var or the dereffed value of a referenced intType EPTF_Var |
| private function f_EPTF_Var_setIntValue(in integer pl_idx, in integer pl_newIntValue) runs on EPTF_Var_CT { |
| if (ischosen(v_EPTF_Vars[pl_idx].content.direct)) { |
| v_EPTF_Vars[pl_idx].content.direct.intVal := pl_newIntValue; |
| return; |
| } |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| if (v_EPTF_Vars[pl_idx].content.reference.refType != intType) { |
| log("ERROR: ", "EPTF_Var[",pl_idx,"] content is not and intType reference"); |
| f_EPTF_Base_stop(); |
| } |
| f_EPTF_Var_modifyIntRefValue(v_EPTF_Vars[pl_idx].content.reference.valueRef, pl_newIntValue); |
| return; |
| } |
| log("ERROR: ", "EPTF_Var[",pl_idx,"] has invalid content"); |
| f_EPTF_Base_stop(); |
| }*/ |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getContent |
| // |
| // Purpose: |
| // Returns the content of an EPTF_Var or the dereffed content of a referenced EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_currentContent - *out* <EPTF_Var_DirectContent> - the content of the EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getContent(in integer pl_idx, out EPTF_Var_DirectContent pl_currentContent) runs on EPTF_Var_CT { |
| var EPTF_Var_DirectContent vl_prevContent; |
| f_EPTF_Var_content2direct(v_EPTF_Vars[pl_idx].content,vl_prevContent); |
| if (f_EPTF_Var_checkSubscriptionMode(pl_idx,pull)) { |
| v_EPTF_Vars[pl_idx].provider.remote.routeUpdateCounter := v_EPTF_Vars[pl_idx].provider.remote.routeUpdateCounter + 1; |
| var boolean vl_useOriginalProvider := v_EPTF_Vars[pl_idx].provider.remote.routeUpdateCounter >= cg_EPTF_Var_routeUpdatePeriod; |
| if (vl_useOriginalProvider) { |
| v_EPTF_Vars[pl_idx].provider.remote.routeUpdateCounter:=0; |
| } |
| var EPTF_Var_Ref vl_provider; |
| var boolean vl_prevSubsCanAdjust := v_EPTF_Vars[pl_idx].subsCanAdjust; |
| var boolean vl_getContentResult; |
| var boolean vl_subsCanAdjust; |
| if (v_EPTF_Vars[pl_idx].provider.remote.varRef.idx != -1 and not vl_useOriginalProvider) { |
| vl_getContentResult := f_EPTF_Var_getRemoteContentById( |
| pl_remoteCompRef := v_EPTF_Vars[pl_idx].provider.remote.varRef.compRef, |
| pl_remoteVarId := { idx := v_EPTF_Vars[pl_idx].provider.remote.varRef.idx}, |
| pl_content := pl_currentContent, |
| pl_provider := vl_provider, |
| pl_subsCanAdjust := vl_subsCanAdjust |
| ); |
| } else { |
| vl_getContentResult := f_EPTF_Var_getRemoteContentById( |
| pl_remoteCompRef := v_EPTF_Vars[pl_idx].provider.remote.compRef, |
| pl_remoteVarId := {name := v_EPTF_Vars[pl_idx].provider.remote.name}, |
| pl_content := pl_currentContent, |
| pl_provider := vl_provider, |
| pl_subsCanAdjust := vl_subsCanAdjust |
| ); |
| } |
| if (vl_getContentResult) { |
| //initialize the local var: |
| if (ischosen(v_EPTF_Vars[pl_idx].content.invalid)) { |
| v_EPTF_Vars[pl_idx].content.direct := pl_currentContent; |
| } else { |
| f_EPTF_Var_setContent(pl_idx,pl_currentContent); |
| } |
| v_EPTF_Vars[pl_idx].subsCanAdjust := vl_subsCanAdjust; |
| if (vl_prevContent!=pl_currentContent) { |
| f_EPTF_Var_updateTimeLine(pl_idx,pl_currentContent); |
| f_EPTF_Var_callPostProcFns(pl_idx); |
| } |
| if (vl_prevSubsCanAdjust!=v_EPTF_Vars[pl_idx].subsCanAdjust) { |
| f_EPTF_Var_callSubsCanAdjustNotifyFns(pl_idx); |
| } |
| if (vl_provider != {null,-1}) { |
| v_EPTF_Vars[pl_idx].provider.remote.varRef := vl_provider; |
| } |
| } else { |
| // return the cached value if remote value is not available: |
| pl_currentContent := vl_prevContent; |
| } |
| } else { |
| if (f_EPTF_Var_checkLocalSubscriptionMode(pl_idx,pull)) { |
| // calculate the value: |
| // f_EPTF_Var_refreshContent(pl_idx); |
| // TODO: Use refreshContent for the var or the providers only? |
| // var EPTF_Var_DirectContent vl_contentTmp; |
| // // register update for the pull mode providers, do not recalculate: |
| // for(var integer i:=0; i<sizeof(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList); i:=i+1) { |
| // if (f_EPTF_Var_checkSubscriptionMode(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList[i],pull) |
| // or f_EPTF_Var_checkLocalSubscriptionMode(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList[i],pull) |
| // ) { |
| // //f_EPTF_Var_refreshContent(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList[i]); |
| // f_EPTF_Var_getContent(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList[i], vl_contentTmp); |
| // } |
| // } |
| f_EPTF_Var_callCalcFn(pl_idx,pl_currentContent); |
| if (vl_prevContent!=pl_currentContent) { |
| f_EPTF_Var_setContent(pl_idx,pl_currentContent); |
| f_EPTF_Var_updateTimeLine(pl_idx,pl_currentContent); |
| f_EPTF_Var_callPostProcFns(pl_idx); |
| } |
| //f_EPTF_Var_refreshContent(pl_idx); |
| } |
| f_EPTF_Var_content2direct(v_EPTF_Vars[pl_idx].content,pl_currentContent); |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_setContent |
| // |
| // Purpose: |
| // Sets the content of an EPTF_Var or the dereffed content of a referenced EPTF_Var without invoking the refresh mechanism |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_newContent - *in* <EPTF_Var_DirectContent> - the content of the EPTF_Var |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // The refresh mechanism is not invoked. The value is just copied into the content, nothing else. |
| // To invoke automatic refresh, use the function <f_EPTF_Var_adjustContent> instead. |
| // This function allows the user to modify the value of an EPTF Variable several |
| // times before activating the refresh mechanism. When the final value is set, use the function <f_EPTF_Var_refreshContent> |
| // to notify the library about the refresh. |
| // |
| // Type checking is performed in the function <f_EPTF_Var_direct2content> |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_setContent(in integer pl_idx, in EPTF_Var_DirectContent pl_newContent) runs on EPTF_Var_CT { |
| if (not f_EPTF_Var_direct2content(pl_newContent,v_EPTF_Vars[pl_idx].content)) { |
| f_EPTF_Var_error(log2str("ERROR:","Cannot set direct content ",pl_newContent," into variable #", pl_idx, " : ", v_EPTF_Vars[pl_idx])); |
| //f_EPTF_Base_stop(); |
| }; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_updateRef |
| // |
| // Purpose: |
| // Updates the reference of the EPTF Variable to the new reference |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_newReference - *in* *octetstring* - the new reference to the component variable |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // If the content of the EPTF Variable is not a reference it does not do anything. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_updateRef(in integer pl_idx, in octetstring pl_newReference) runs on EPTF_Var_CT { |
| if (ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| v_EPTF_Vars[pl_idx].content.reference.valueRef := pl_newReference; |
| } |
| } |
| |
| } // group VaribleCreationValueAssignment |
| |
| /////////////////////////////////////////////////////////// |
| // Group: LookUp |
| // |
| // Purpose: |
| // Functions to look up an EPTF Variable based on name, component variable, etc. |
| // |
| // Detailed Comments: |
| // Some of the functions need hashmap to be enabled |
| // |
| // Elements: |
| /////////////////////////////////////////////////////////// |
| group LookUp { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getId |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable name. returns -1 if not found |
| // |
| // Parameters: |
| // pl_name - *in* *charstring* - name of the variable |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // Uses hashmap if enabled, otherwise for-cycle |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getId(in charstring pl_name) runs on EPTF_Var_CT return integer { |
| if (pl_name=="") {return -1;} |
| if (v_EPTF_Var_enableName2Id == false) { |
| // search using for cycle: |
| return f_EPTF_Var_lookupName(pl_name); |
| } |
| var integer vl_idx; |
| if (f_EPTF_str2int_HashMap_Find(v_EPTF_Var_Hashmap_Name2Id, pl_name, vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getName |
| // |
| // Purpose: |
| // Returns the name for the EPTF variable with the given idx. |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - idx of the variable |
| // |
| // Return Value: |
| // *charstring* - the name of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getName(in integer pl_idx) runs on EPTF_Var_CT return charstring { |
| return v_EPTF_Vars[pl_idx].name; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_intCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *integer* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_intCompRef2Id(inout integer pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({intType,f_EPTF_Var_getIntRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getIntRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_Id2CompRef |
| // |
| // Purpose: |
| // Returns the reference for the EPTF variable with the given idx. |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - idx of the variable |
| // |
| // Return Value: |
| // <EPTF_Var_ReferencedContent> - the reference to the component variable referred by the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_Id2CompRef(in integer pl_idx) runs on EPTF_Var_CT return EPTF_Var_ReferencedContent { |
| if(ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| return v_EPTF_Vars[pl_idx].content.reference; |
| } |
| return {intType, ''O}; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_floatCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *float* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_floatCompRef2Id(inout float pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({floatType,f_EPTF_Var_getFloatRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getFloatRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_boolCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *boolean* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_boolCompRef2Id(inout boolean pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({boolType,f_EPTF_Var_getBoolRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getBoolRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_charstringCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *integer* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_charstringCompRef2Id(inout charstring pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({charstringType,f_EPTF_Var_getCharstringRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getCharstringRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_octetstringCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *octetstring* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_octetstringCompRef2Id(inout octetstring pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({octetstringType,f_EPTF_Var_getOctetstringRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getOctetstringRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_hexstringCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *hexstring* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_hexstringCompRef2Id(inout hexstring pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({hexstringType,f_EPTF_Var_getHexstringRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getHexstringRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_bitstringCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* *bitstring* - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_bitstringCompRef2Id(inout bitstring pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({bitstringType,f_EPTF_Var_getBitstringRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getBitstringRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_integerlistCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* <EPTF_IntegerList> - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_integerlistCompRef2Id(inout EPTF_IntegerList pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({integerlistType,f_EPTF_Var_getIntegerlistRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getIntegerlistRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_floatlistCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* <EPTF_FloatList> - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_floatlistCompRef2Id(inout EPTF_FloatList pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({floatlistType,f_EPTF_Var_getFloatlistRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getFloatlistRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_charstringlistCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* <EPTF_CharstringList> - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_charstringlistCompRef2Id(inout EPTF_CharstringList pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({charstringlistType,f_EPTF_Var_getCharstringlistRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getCharstringlistRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| |
| ////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_statusLEDCompRef2Id |
| // |
| // Purpose: |
| // Returns the idx for the EPTF variable that refers to the given component variable. returns -1 if not found |
| // |
| // Parameters: |
| // pl_compVar - *inout* <EPTF_StatusLED> - the component variable for which the referring EPTF Variable should be found |
| // |
| // Return Value: |
| // *integer* - the idx of the EPTF_Var |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // This function is one of the type-specific functions that are implemented for |
| // all value types. |
| // The inout for pl_compVar is needed so it is not copied |
| // (which would result in incorrect memory address for the EPTF variable). |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_statusLEDCompRef2Id(inout EPTF_StatusLED pl_compVar) runs on EPTF_Var_CT return integer { |
| if (v_EPTF_Var_enableCompRef2Id == false) { |
| return f_EPTF_Var_lookupCompRef({statusLEDType,f_EPTF_Var_getStatusLEDRef(pl_compVar)}); // hasmap is not enabled |
| } |
| var integer vl_idx; |
| if (f_EPTF_oct2int_HashMap_Find(v_EPTF_Var_Hashmap_CompRef2Id, f_EPTF_Var_getStatusLEDRef(pl_compVar), vl_idx)) { |
| return vl_idx; |
| } |
| return -1; |
| } |
| //... |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_getValueRef |
| // |
| // Purpose: |
| // Returns the valueRef of a referenced EPTF_Var |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // |
| // Return Value: |
| // *octetstring* - the reference to the value of the EPTF variable |
| // |
| // Errors: |
| // If the EPTF Variable is not a referenced variable is stops with an error |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_getValueRef(in integer pl_idx) runs on EPTF_Var_CT return octetstring { |
| if (not ischosen(v_EPTF_Vars[pl_idx].content.reference)) { |
| f_EPTF_Var_error(log2str("EPTF_Var[",pl_idx,"] is not a referenced variable")); |
| //f_EPTF_Base_stop(); |
| } |
| return v_EPTF_Vars[pl_idx].content.reference.valueRef; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_directContent2RefType |
| // |
| // Purpose: |
| // Converts type information in a <EPTF_Var_DirectContent> to the enumerated type <EPTF_Var_RefType> |
| // |
| // Parameters: |
| // pl_directContent - <EPTF_Var_DirectContent> - the direct content to convert |
| // |
| // Return Value: |
| // <EPTF_Var_RefType> - the type as an enumerated |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_directContent2RefType(in EPTF_Var_DirectContent pl_directContent) runs on EPTF_Var_CT return EPTF_Var_RefType { |
| if (ischosen(pl_directContent.intVal)) { |
| return intType; |
| } |
| if (ischosen(pl_directContent.floatVal)) { |
| return floatType; |
| } |
| if (ischosen(pl_directContent.boolVal)) { |
| return boolType; |
| } |
| if (ischosen(pl_directContent.charstringVal)) { |
| return charstringType; |
| } |
| if (ischosen(pl_directContent.octetstringVal)) { |
| return octetstringType; |
| } |
| if (ischosen(pl_directContent.hexstringVal)) { |
| return hexstringType; |
| } |
| if (ischosen(pl_directContent.bitstringVal)) { |
| return bitstringType; |
| } |
| if (ischosen(pl_directContent.integerlistVal)) { |
| return integerlistType; |
| } |
| if (ischosen(pl_directContent.floatlistVal)) { |
| return floatlistType; |
| } |
| if (ischosen(pl_directContent.charstringlistVal)) { |
| return charstringlistType; |
| } |
| if (ischosen(pl_directContent.statusLEDVal)) { |
| return statusLEDType; |
| } |
| //... |
| f_EPTF_Base_stop(); |
| // this is never reached: |
| return intType; |
| } |
| |
| } // group LookUp |
| |
| /////////////////////////////////////////////////////////// |
| // Group: Subscribing |
| // |
| // Purpose: |
| // Functions to subscribe/unsubscribe to other EPTF Variables |
| // |
| // Elements: |
| /////////////////////////////////////////////////////////// |
| group Subscribing { |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_subscribeLocal |
| // |
| // Purpose: |
| // Sets the local provider for the subscriber variable pl_idx |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_localProvider - *in* <EPTF_Var_ProviderLocal> - the local provider |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_subscribeLocal(in integer pl_idx, in EPTF_Var_ProviderLocal pl_localProvider) runs on EPTF_Var_CT { |
| // create var automatically? subscrLocalRef? |
| if (not ischosen(v_EPTF_Vars[pl_idx].provider.empty)) { |
| f_EPTF_Var_error(log2str("Cannot set local provider for EPTF_Var[",pl_idx,"]. It has already a provider")); |
| //f_EPTF_Base_stop(); |
| } |
| v_EPTF_Vars[pl_idx].provider := {local:=pl_localProvider}; |
| v_EPTF_Vars[pl_idx].subsCanAdjust := false; |
| f_EPTF_Var_addLocalSubscriber(pl_idx, pl_localProvider.calcFn.argList); |
| f_EPTF_Var_refreshContent(pl_idx); |
| f_EPTF_Var_callSubsCanAdjustNotifyFns(pl_idx); |
| f_EPTF_Var_setSubsCanAdjustInAllSubscribers(pl_idx); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_addLocalProviders |
| // |
| // Purpose: |
| // Adds the local providers to the variable with ID pl_idx |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_providerList - *in* <EPTF_IntegerList> - the local providers to add |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // The varible should already have local providers. If it does not, |
| // this function stops with an error |
| // |
| // Detailed Comments: |
| // This function can be used to add additional local providers to a |
| // variable that is a local subscriber already (i.e. <f_EPTF_Var_subscribeLocal> |
| // was already called) |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_addLocalProviders(in integer pl_idx, in EPTF_IntegerList pl_providerList) |
| runs on EPTF_Var_CT |
| { |
| f_EPTF_Base_assert(%definitionId&": not a local subscription.", ischosen(v_EPTF_Vars[pl_idx].provider.local)); |
| for(var integer i:=0; i<sizeof(pl_providerList); i:=i+1) { |
| v_EPTF_Vars[pl_idx].provider.local.calcFn.argList |
| [sizeof(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList)] := pl_providerList[i]; |
| } |
| f_EPTF_Var_addLocalSubscriber(pl_idx, pl_providerList); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_removeLocalProviders |
| // |
| // Purpose: |
| // Removes the local providers from the variable with ID pl_idx |
| // |
| // Parameters: |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_providerList - *in* <EPTF_IntegerList> - the local providers to remove |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // The varible should already have local providers. If it does not, |
| // this function stops with an error |
| // |
| // Detailed Comments: |
| // This function can be used to remove the given local providers from a |
| // variable that is a local subscriber already (i.e. <f_EPTF_Var_subscribeLocal> |
| // was already called) |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_removeLocalProviders(in integer pl_idx, in EPTF_IntegerList pl_providerList) |
| runs on EPTF_Var_CT |
| { |
| f_EPTF_Base_assert(%definitionId&": not a local subscription.", ischosen(v_EPTF_Vars[pl_idx].provider.local)); |
| f_EPTF_Var_removeLocalSubscriber(pl_idx, pl_providerList); |
| var EPTF_IntegerList vl_old := v_EPTF_Vars[pl_idx].provider.local.calcFn.argList; |
| v_EPTF_Vars[pl_idx].provider.local.calcFn.argList := {}; |
| for(var integer i:=0; i<sizeof(vl_old); i:=i+1) { |
| var boolean vl_found := false; |
| for(var integer j:=0; j<sizeof(pl_providerList); j:=j+1) { |
| if(vl_old[i] == pl_providerList[j]) { vl_found := true; break;} |
| } |
| if(not vl_found) { |
| v_EPTF_Vars[pl_idx].provider.local.calcFn.argList |
| [sizeof(v_EPTF_Vars[pl_idx].provider.local.calcFn.argList)] := vl_old[i]; |
| } |
| } |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_isPresentRemote |
| // |
| // Purpose: |
| // Checks if a variable is present on a remote component |
| // |
| // Parameters: |
| // pl_remoteCompRef - *in* <EPTF_Var_CT> - the remote variable's component reference |
| // pl_remoteVarName - *in* *charstring* - the remote variable's name |
| // |
| // Return Value: |
| // boolean - true if present, false if not |
| // |
| // Errors: |
| // - |
| // |
| // Detailed Comments: |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_isPresentRemote(in EPTF_Var_CT pl_remoteCompRef, in charstring pl_remoteVarName) runs on EPTF_Var_CT |
| return boolean { |
| |
| var integer vl_blockingFlagIdx := f_EPTF_setNewboolean(v_booleanPool,false); |
| var integer vl_responseIdx := f_EPTF_setNewboolean(v_booleanPool,false); |
| |
| f_EPTF_Var_addConnection(pl_remoteCompRef); |
| f_EPTF_Var_send( |
| {isPresentRemote:={ |
| pl_remoteVarName, |
| vl_blockingFlagIdx, |
| vl_responseIdx |
| }}, |
| pl_remoteCompRef |
| ); |
| timer t_minWait := 0.0; // zero wait |
| timer t_maxWait := v_Var_maxWaitTime; // maximum wait |
| t_minWait.start; |
| t_maxWait.start; |
| // wait until response is received: |
| alt { |
| [f_EPTF_getValueboolean(v_booleanPool,vl_blockingFlagIdx)] t_minWait.timeout; |
| [] t_maxWait.timeout { |
| f_EPTF_Var_warning(log2str("No response received for isPresent for: ", pl_remoteVarName, " from: ", pl_remoteCompRef)); |
| } |
| } |
| // response is received here, boolean at vl_responseIdx is set to the appropriate value |
| var boolean vl_isPresentResponse := f_EPTF_getValueboolean(v_booleanPool,vl_responseIdx); |
| // remove the bool from the pool: |
| f_EPTF_deleteboolean(v_booleanPool,vl_blockingFlagIdx); |
| f_EPTF_deleteboolean(v_booleanPool,vl_responseIdx); |
| return vl_isPresentResponse; |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_subscribeRemote |
| // |
| // Purpose: |
| // Creates a new EPTF_Var (this will be the subscriber) and subscribes it to the remote provider (provider on a remote component) |
| // |
| // Parameters: |
| // pl_remoteCompRef - *in* <EPTF_Var_CT> - the remote provider variable's component reference |
| // pl_remoteProviderVarName - *in* *charstring* - the remote provider variable's name |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode: sampled or timeLine: buffered; realtime: non-buffered |
| // pl_idx - *out* *integer* - the idx of the new EPTF_Var |
| // pl_localName - *in* *charstring* *optional* - the name of the subscriber variable. If not specified (or "") |
| // the name will be auto-generated by the provider variable as "ProviderCompName.providerVarName" (if not already subscribed) |
| // pl_refreshRate - *in integer* - the refresh rate for the subscription. It is the multiplier of the elementary refresh period. |
| // If it is set to -1: the old refresh period is used (default) |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // stops execution if the specified (or autogenerated) name is not unique |
| // |
| // Detailed Comments: |
| // If pl_localName is empty ("") only one subscriber can be created from the same component for a remote provider |
| // If there is a subscriber already, the function returns its index instead of creating |
| // a new subscriber |
| // This function blocks execution until subscription response is received. |
| // Buffered mode means that the value of the provider will be received periodically as a time series (timeLine) or a sample (sampled) |
| // |
| // If subscribing realtime to a local variable and pl_localName is not given or it is the same as pl_remoteProviderVarName, new variable |
| // is not created, instead the id of pl_remoteProviderVarName is returned |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_subscribeRemote( |
| in EPTF_Var_CT pl_remoteCompRef, |
| in charstring pl_remoteProviderVarName, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| out integer pl_idx, |
| in charstring pl_localName := "", |
| in integer pl_refreshRate := -1 |
| ) runs on EPTF_Var_CT { |
| |
| if (pl_remoteCompRef==self and pl_subscriptionMode == realtime) { |
| if (f_EPTF_Var_getId(pl_remoteProviderVarName) == -1) { |
| // remote var does not exist |
| pl_idx := -1; // subscribe is unsuccessful |
| return; |
| } |
| if (pl_remoteProviderVarName==pl_localName or pl_localName=="") { |
| //remote var is on the local component and subscription is realtime and local name is not given or is the same => return the local var |
| pl_idx := f_EPTF_Var_getId(pl_remoteProviderVarName); |
| return; |
| } else { |
| // local name is given but does not match with the already existing local var |
| f_EPTF_Var_debug(%definitionId& |
| ": Subscribing realtime to a local variable with a different name (existing:"&pl_remoteProviderVarName&", given:"&pl_localName&") might cause performance degradation."& |
| " For optimal performance pl_localName should not be specified.") |
| } |
| } |
| |
| // zero or negative pl_refreshRate-s are treated as zero (default refresh method) |
| var integer vl_refreshRate := 0; |
| if (pl_refreshRate>0) { |
| vl_refreshRate := pl_refreshRate; |
| } |
| f_EPTF_Var_findSubscription(pl_remoteCompRef,pl_remoteProviderVarName,pl_idx); |
| if (pl_idx != -1) { |
| f_EPTF_Var_debug(log2str("Already subscribed for ", pl_remoteCompRef,":",pl_remoteProviderVarName, " by v_EPTF_Vars[",pl_idx,"]: ",v_EPTF_Vars[pl_idx])); |
| if ((pl_remoteProviderVarName==pl_localName or pl_localName=="" |
| or pl_localName==v_EPTF_Vars[pl_idx].name) and vl_refreshRate == f_EPTF_Var_getVarRefreshRate(pl_idx)) { |
| return; // using the existing variable (the autoGenerated name is the name of the existing variable) |
| } |
| // // subscribe to the local variable: |
| // // FIXME: this requires more port communication than if subscribing directly to the remote var twice: |
| // This is better: comp1/1->comp2/2 comp1/1->comp2/3 (needs 1 message) than comp1/1->comp2/2->comp2/3 needs 2 messages |
| // f_EPTF_Var_subscribeRemote(self,v_EPTF_Vars[pl_idx].name,pl_subscriptionMode,pl_idx,pl_localName); |
| // |
| // no return: creating new subscriber variable |
| } |
| if (pl_subscriptionMode==pull and pl_localName=="") { |
| // auto-generate name for the pull mode subscriber |
| pl_localName := "PullSubscrOf."&log2str(pl_remoteCompRef)&"."&pl_remoteProviderVarName; |
| pl_idx := f_EPTF_Var_getId(pl_localName); |
| if (pl_idx!=-1) { |
| return; // already subscribed |
| } |
| } |
| |
| f_EPTF_Var_addNew(pl_idx,pl_localName); |
| v_EPTF_Vars[pl_idx].provider := {remote:={pl_remoteProviderVarName, pl_remoteCompRef, {pl_remoteCompRef,-1},pl_subscriptionMode,vl_refreshRate,empty,0}}; |
| f_EPTF_str2int_HashMap_Insert(v_EPTF_Var_Hashmap_Provider2Id,log2str(pl_remoteCompRef)&"."&pl_remoteProviderVarName,pl_idx); |
| |
| if (pl_subscriptionMode==pull) { |
| // This is not needed if No request is sent and there is no response for pull type subscription!!!: |
| f_EPTF_Var_sendSubscribe(pl_idx, pl_remoteCompRef, pl_remoteProviderVarName, pl_subscriptionMode, 0, -1); |
| return; // do not have to block execution for pull mode subscription |
| } |
| |
| // create a blocking flag: |
| timer t_minWait := 0.0; // zero wait |
| timer t_maxWait := v_Var_maxWaitTime; // maximum wait |
| var integer v_blockingFlagIdx := f_EPTF_setNewboolean(v_booleanPool,false); |
| f_EPTF_Var_sendSubscribe(pl_idx, pl_remoteCompRef, pl_remoteProviderVarName, pl_subscriptionMode, vl_refreshRate, v_blockingFlagIdx); |
| t_minWait.start; |
| t_maxWait.start; |
| |
| // block execution until subscribeResp arrives: |
| alt { |
| [f_EPTF_getValueboolean(v_booleanPool,v_blockingFlagIdx)] t_minWait.timeout; |
| [] t_maxWait.timeout { |
| //HM27497 |
| //It must be an error instead of warning |
| f_EPTF_Var_error(log2str("No response received for subscribe with data: ", pl_idx, pl_remoteCompRef, pl_remoteProviderVarName, pl_subscriptionMode, v_blockingFlagIdx)); |
| //f_EPTF_Base_stopAll(); // called by f_EPTF_Var_error |
| } |
| } |
| // here the subscribe resp was handled, which fills in the omit value, the idx, and the name |
| |
| // remove the bool from the pool: |
| f_EPTF_deleteboolean(v_booleanPool,v_blockingFlagIdx); |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_subscribeRemote_nonBlocking |
| // |
| // Purpose: |
| // Nonblocking version of <f_EPTF_Var_subscribeRemote>. |
| // |
| // Parameters: |
| // pl_remoteCompRef - *in* <EPTF_Var_CT> - the remote provider variable's component reference |
| // pl_remoteProviderVarName - *in* *charstring* - the remote provider variable's name |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode: sampled or timeLine: buffered; realtime: non-buffered |
| // pl_localName - *in* *charstring* *optional* - the name of the subscriber variable. If not specified (or "") |
| // the original name will be reused, otherwise the variable is renamed to this name. |
| // pl_refreshRate - *in integer* - the refresh rate for the subscription. It is the multiplier of the elementary refresh period. |
| // If it is set to -1: the old refresh period is used (default) |
| // pl_respHandler - *in* <EPTF_Var_resubscribeRemoteResp_handler> - subscribe response handler callback function |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // |
| // Detailed Comments: |
| // It creates an "invalid" variable in order to call f_EPTF_Var_resubscribeRemote which does not block execution until resubscription response is received. |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_subscribeRemote_nonBlocking( |
| in EPTF_Var_CT pl_remoteCompRef, |
| in charstring pl_remoteProviderVarName, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in charstring pl_localName := "", |
| in integer pl_refreshRate := -1, |
| in EPTF_Var_resubscribeRemoteResp_handler pl_respHandler := cg_EPTF_Var_resubscribeRemoteResp_handler_null |
| ) runs on EPTF_Var_CT { |
| |
| var integer vl_varIdx; |
| f_EPTF_Var_addNew(vl_varIdx,pl_localName); |
| |
| f_EPTF_Var_resubscribeRemote( |
| pl_remoteCompRef := pl_remoteCompRef, |
| pl_remoteProviderVarName := pl_remoteProviderVarName, |
| pl_subscriptionMode := pl_subscriptionMode, |
| pl_idx := vl_varIdx, |
| pl_localName := pl_localName, |
| pl_refreshRate := pl_refreshRate, |
| pl_respHandler := pl_respHandler |
| ) |
| } |
| |
| /////////////////////////////////////////////////////////// |
| // Function: f_EPTF_Var_resubscribeRemote |
| // |
| // Purpose: |
| // Resubscribes an existing EPTF Variable to the remote provider (provider on a remote component) |
| // |
| // Parameters: |
| // pl_remoteCompRef - *in* <EPTF_Var_CT> - the remote provider variable's component reference |
| // pl_remoteProviderVarName - *in* *charstring* - the remote provider variable's name |
| // pl_subscriptionMode - *in* <EPTF_Var_SubscriptionMode> - subscription mode: sampled or timeLine: buffered; realtime: non-buffered |
| // pl_idx - *in* *integer* - the idx of the EPTF_Var |
| // pl_localName - *in* *charstring* *optional* - the name of the subscriber variable. If not specified (or "") |
| // the original name will be reused, otherwise the variable is renamed to this name. |
| // pl_refreshRate - *in integer* - the refresh rate for the subscription. It is the multiplier of the elementary refresh period. |
| // If it is set to -1: the old refresh period is used (default) |
| // pl_respHandler - *in* <EPTF_Var_resubscribeRemoteResp_handler> - subscribe response handler callback function |
| // |
| // Return Value: |
| // - |
| // |
| // Errors: |
| // stops execution if the specified (or autogenerated) name is not unique |
| // |
| // Detailed Comments: |
| // If pl_localName is empty ("") only one subscriber can be created from the same component for a remote provider |
| // If there is a subscriber already, the function returns immediately |
| // This function does not block execution until subscription response is received. |
| // Buffered mode means that the value of the provider will be received periodically as a time series (timeLine) or a sample (sampled) |
| // |
| /////////////////////////////////////////////////////////// |
| public function f_EPTF_Var_resubscribeRemote( |
| in EPTF_Var_CT pl_remoteCompRef, |
| in charstring pl_remoteProviderVarName, |
| in EPTF_Var_SubscriptionMode pl_subscriptionMode, |
| in integer pl_idx, |
| in charstring pl_localName := "", |
| in integer pl_refreshRate := -1, |
| in EPTF_Var_resubscribeRemoteResp_handler pl_respHandler := cg_EPTF_Var_resubscribeRemoteResp_handler_null |
| ) runs on EPTF_Var_CT { |
| |
| if (pl_remoteCompRef==self) { |
| if (f_EPTF_Var_getId(pl_remoteProviderVarName) == -1) { |
| // remote var does not exist |
| // resubscribe is unsuccessful |
| if(pl_respHandler.handlerFn != null) { |
| pl_respHandler.handlerFn.apply(pl_idx,false,pl_respHandler.argList); |
| } |
| return; |
| } |
| if (pl_remoteProviderVarName==f_EPTF_Var_getName(pl_idx)) { |
| // update the name: |
| if (pl_localName != "") |