[c3b98b]: / project / sparkplug™_mqtt_edge_and_host-stack_b9741afd / function_blocks_8ad6e219 / fb_exponentialbackofftimer_1f49134a / fb_exponentialbackofftimer_8c736ed9 / 8c736ed92eb64565bf88d4dbf06baf94.object  Maximize  Restore  History

Download this file

1 lines (1 with data), 5.6 kB

1
{"payload":{"meta":{"Graph":{"@Type":"81297157","@Value":{"Guid":"(Guid)8c736ed9-2eb6-4565-bf88-d4dbf06baf94","ParentGuid":"(Guid)00000000-0000-0000-0000-000000000000","Name":"(string)FB_ExponentialBackOffTimer","Properties":{"@Type":"2c41fa04:IDictionary","@Value":[{"@Key":"(Guid)829a18f2-c514-4f6e-9634-1df173429203","@Value":{"@Type":"829a18f2","@Value":{"ParentObjects":{"@Type":"fa2ee218:IDictionary","@Value":[{"@Key":"(Guid)21af5390-2942-461a-bf89-951aaf6999f1","@Value":"(Guid)1f49134a-44dc-4cc5-ab6f-f0c8ab00fdb6"}]}}}}]},"TypeGuid":"(Guid)6f9dac99-8de1-4efc-8465-68ac443b7d08","EmbeddedTypeGuids":{"@Type":"[Guid]","@Value":["(Guid)a9ed5b7e-75c5-4651-af16-d2c27e98cb94","(Guid)3b83b776-fb25-43b8-99f2-3c507c9143fc"]}}},"TypeInfos":{"2c41fa04":"{2c41fa04-1834-41c1-816e-303c7aa2c05b}","81297157":"{81297157-7ec9-45ce-845e-84cab2b88ade}","829a18f2":"{829a18f2-c514-4f6e-9634-1df173429203}","fa2ee218":"{fa2ee218-a39b-4b6d-b249-49dbddbd168a}","Guid":"System.Guid","string":"System.String"}},"object":{"Graph":{"@Type":"6f9dac99","@Value":{"SpecialFunc":{"@Type":"0db3d7bb:Enum","@Value":"None"},"Implementation":{"@Type":"3b83b776","@Value":{"TextDocument":{"@Type":"f3878285","@Value":{"TextBlobForSerialisation":"(string)EnableFEdge( Clk := Enable );\nIsEnabled := Enable; // Set feedback IsEnabled\n\nCASE iState OF\n\n    0: // Init, wait for IsEnabled := TRUE;\n        Q := FALSE;\n\n        IF IsEnabled THEN\n            THIS^.ResetIndex(); // If the Timer is enabled we simply reset the LockTime Array index\n            ReleaseTimerET := T#0S;\n            LockTimeET := T#0S;\n            ReleaseTimer();\n            LockTimer();\n            iState := 100;\n        END_IF\n\n    100: // Enable Release during ReleaseTime\n        Q := TRUE;\n        Call_ReleaseTimer();\n        Call_LockTimer();\n\n        // If someone disable it, we goto init\n        IF NOT Enable THEN\n            iState := 0;\n        END_IF\n\n        // If during this Time we connected we goto 1000\n        IF IsConnected THEN\n            iState := 1000;\n            Q_TimeRemain := T#0S;\n            LockTimeRemain := T#0S;\n        END_IF;\n\n        IF ReleaseTimer.Q THEN\n            THIS^.Next();\n            iState := 200;\n        END_IF\n\n    200: // Enable Lock during locktimer \n        Q := FALSE;\n        Call_ReleaseTimer();\n        Call_LockTimer();\n\n        // If someone disable it, we goto init\n        IF NOT Enable THEN\n            iState := 0;\n        END_IF\n\n        // We deliberatly ignore it, since Q = False\n        IF IsConnected THEN\n            ;\n        END_IF;\n\n        // If the timer expires we go back to 100\n        IF LockTimer.Q THEN\n            iState := 100;\n        END_IF\n\n    1000: // Connected so we latch the output\n        Q := TRUE;\n\n        // If someone disconnects us or we get disconnected, we goto init\n        IF NOT IsConnected OR NOT Enable THEN\n            iState := 0;\n        END_IF\n\nEND_CASE","LineInfoPersistence":"(string)8c736ed9-2eb6-4565-bf88-d4dbf06baf94_Impl_LineIds"}}}},"Interface":{"@Type":"a9ed5b7e","@Value":{"TextDocument":{"@Type":"f3878285","@Value":{"TextBlobForSerialisation":"(string)// {attribute 'hide'}\n// An exponential Backoff Timer \n// Connects during ConnectionTime 30s (Q = TRUE) then Waits during an exponential increasing locktime (Q = FALSE)\n//\n// Default behaviour\n// Attempt 1: connects 30s after which we waits 30s\n// Attempt 2: connects 30s after which we waits 30s\n// Attempt 3: connects 30s after which we waits 60s\n// Attempt 5: connects 30s after which we waits 120s\n// Attempt 6: connects 30s after which we waits 240s\n// Attempt 7: connects 30s after which we waits 480s\n// Attempt 8: connects 30s after which we waits 960s\n// Any further attemp: connects 30s after which we wait 1920s\n\nFUNCTION_BLOCK FB_ExponentialBackOffTimer\nVAR_INPUT\n    Enable : BOOL; // Enable the timer\n    IsConnected : BOOL; // Is the client connected with the server?\n    ConnectionTime : TIME := T#30S;\n    LockTimesArray : ARRAY[ MIN_RANGE..MAX_RANGE ] OF TIME := [ 2(TIME#30S0MS),\n        TIME#1M0S0MS,\n        TIME#2M0S0MS,\n        TIME#4M0S0MS,\n        TIME#8M0S0MS,\n        TIME#16M0S0MS,\n        TIME#32M0S0MS ];\nEND_VAR\nVAR_OUTPUT\n    IsEnabled : BOOL; // Feedback enabled    \n    Q : BOOL; // Q = TRUE during \"Out Time Period Remaining <> 0\" and otherwise exponentially longer FALSE\n    Q_TimeRemain : TIME; // Duration of \"Q Time Period is TRUE\" remaining\n    LockTimeRemain : TIME; // Duration of \"Q Time Period is FALSE\" remaining\nEND_VAR\nVAR\n    iState : INT;\n    EnableFEdge : F_TRIG;\n    ReleaseTimer : TON;\n    ReleaseTimerET : TIME;\n    LockTimer : TON;\n    lockTimeET : TIME;\n    Index : DINT := MIN_RANGE;\nEND_VAR\nVAR CONSTANT\n    MIN_RANGE : DINT := 1;\n    MAX_RANGE : DINT := 8;\nEND_VAR","LineInfoPersistence":"(string)8c736ed9-2eb6-4565-bf88-d4dbf06baf94_Decl_LineIds"}}}},"UniqueIdGenerator":"(string)1761","POULevel":{"@Type":"8e575c5b:Enum","@Value":"Standard"},"ChildObjectGuids":{"@Type":"ArrayList:IList","@Value":[]},"AddAttributeSubsequent":"(bool)False"}},"TypeInfos":{"0db3d7bb":"{0db3d7bb-cde0-4416-9a7b-ce49a0124323}","3b83b776":"{3b83b776-fb25-43b8-99f2-3c507c9143fc}","6f9dac99":"{6f9dac99-8de1-4efc-8465-68ac443b7d08}","8e575c5b":"{8e575c5b-1d37-49c6-941b-5c0ec7874787}","a9ed5b7e":"{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}","ArrayList":"System.Collections.ArrayList","bool":"System.Boolean","f3878285":"{f3878285-8e4f-490b-bb1b-9acbb7eb04db}","string":"System.String"}}},"FormatVersion":"1.0"}