{"payload":{"meta":{"Graph":{"@Type":"81297157","@Value":{"Guid":"(Guid)ff5d8fa7-1c8e-4a1e-97b0-2eb59c724c9e","ParentGuid":"(Guid)74ccca2f-50e3-4d5a-9d7a-9fd420284f83","Name":"(string)atStageCtl","Properties":{"@Type":"2c41fa04:IDictionary","@Value":[{"@Key":"(Guid)829a18f2-c514-4f6e-9634-1df173429203","@Value":{"@Type":"829a18f2","@Value":{"ParentObjects":{"@Type":"fa2ee218:IDictionary","@Value":[{"@Key":"(Guid)d9b2b2cc-ea99-4c3b-aa42-1e5c49e65b84","@Value":"(Guid)60ba916a-ad0d-4ac0-b4be-7ab0e9fa4006"}]}}}}]},"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)in_stagesHi := in_teSP + in_offsetHi;\nin_stagesLo := in_teSP - in_offsetLo;\n//Get the total span of all stages\nspan := in_stagesHi - in_stagesLo;\n//Get the interval between stages\nstageInterval := (span + in_stagesGap) / in_stagesCnt;\n//Get the size of each stage\nstageSize := (span - (in_stagesGap * (in_stagesCnt -1)))/ in_stagesCnt;\n\n//calculate values for each stage\nFOR I := 0 TO in_stagesCnt-1 DO\n\t//calculate the center of the stage\n\tstages[i].center := in_stagesLo + (i * stageInterval + stageInterval * 0.5 - in_stagesGap/2);\n\t//calculate the botom of the stage\n\tstages[i].lo := stages[i].center - stageSize /2;\n\t//calculate the top of the stage\n\tstages[i].hi := stages[i].center + stageSize /2;\nEND_FOR\n\n//calculate which stage we are in now\nFOR I := 0 TO in_stagesCnt-1 DO\n\n\tIF in_cv >= stages[i].lo AND in_cv <= stages[i].hi THEN\n\t\tactiveStageIdx := i;\n\tEND_IF\n\t\n\t//If temp is between this stage and the stage below make sure index is one of the two\n\tIF i > 0 AND in_cv > stages[i -1].hi AND in_cv < stages[i].lo THEN\n\t\tIF NOT (activeStageIdx = i OR activeStageIdx = i - 1) THEN\n\t\t\tactiveStageIdx := i;\n\t\tEND_IF\n\tEND_IF\n\nEND_FOR\n\n//cv is less then bottom stage\nIF in_cv < stages[0].lo THEN\n\tactiveStageIdx := 0;\t\nEND_IF\n\n//cv is greater then highest stage\nIF in_cv > stages[in_stagesCnt-1].hi THEN\n\tactiveStageIdx := in_stagesCnt -1;\t\nEND_IF\n\n//get the active stage\nactiveStage REF= stages[activeStageIdx];\n\nFOR i := 0 TO in_stagesCnt-1 DO\n\tstages[i].active := activeStageIdx = i;\n\tstages[i].idx := i;\nEND_FOR\n\nhmiStage REF= stages[hmiIDX];\n\nFOR I := 0 TO in_stagesCnt-1 DO\n\tstages[i](in_cv := in_cv);\nEND_FOR","LineInfoPersistence":"(string)ff5d8fa7-1c8e-4a1e-97b0-2eb59c724c9e_Impl_LineIds"}}}},"Interface":{"@Type":"a9ed5b7e","@Value":{"TextDocument":{"@Type":"f3878285","@Value":{"TextBlobForSerialisation":"(string){attribute 'no_assign'}\nFUNCTION_BLOCK atStageCtl\nVAR_INPUT\n\tin_stagesHi: REAL;  //Offset from setpoint to the top of the highest stage\n\tin_stagesLo: REAL;  //Offset from setpoint to the bottom fo the lowest stage\n\tin_cv: REAL; //Current temperature input\n\tstages: ARRAY[0..10] OF atStage;\n\tactiveStage: REFERENCE TO atStage;\n\thmiStage: REFERENCE TO atStage;\nEND_VAR\nVAR_INPUT PERSISTENT\n\tin_offsetHi: REAL := 4;\n\tin_offsetLo: REAL := 1;\n\tin_stagesCnt: INT := 5; //Number of stages\n\tin_stagesGap: REAL :=0.2; //Gap between stages where nothing changes\n\tin_teSP: REAL := 15; //Setpoint\nEND_VAR\nVAR_OUTPUT PERSISTENT\n\tactiveStageIdx: INT;\n\thmiIDX: INT;\nEND_VAR\nVAR\n\ti: INT; //Loop variable\n\tspan: REAL; //total span from bottom of first stage to top of last stage\n\tstageStart: REAL;\n\tstageInterval: REAL;\n\tstageSize: REAL;\n\tdebug_hi: REAL;\n\tdebug_lo: REAL;\nEND_VAR\nVAR_IN_OUT\n\t\nEND_VAR\n\n","LineInfoPersistence":"(string)ff5d8fa7-1c8e-4a1e-97b0-2eb59c724c9e_Decl_LineIds"}}}},"UniqueIdGenerator":"(string)543","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"}