<lib version="2.4.0" name="PLL\BACnet_Addons.plclib" fullXml="true" link="true">
	<descr>&lt;HTML&gt;
&lt;p&gt;The BACnet Addons library helps to simplify the implementation of the BACnet protocol into either new or existing projects.&lt;/p&gt;
&lt;p&gt;This library is complementary to the BACnet_IEC library.&lt;/p&gt;

The key functionalities of the current library version are:
&lt;ul&gt;
  &lt;li&gt; Link a variable (Status or Global Variable) or an EEPROM parameter to:
    &lt;ul&gt;
    &lt;li&gt;an Analog Value BACnet Object (supports INT, UINT, REAL);&lt;/li&gt;
    &lt;li&gt;a Binary Value BACnet Object (supports BOOL).&lt;/li&gt;
    &lt;li&gt;a Multi State Value BACnet Object (supports INT, UINT, UDINT, USINT, REAL);&lt;/li&gt;
    &lt;li&gt;any UDINT attribute of any BACnet Object (supports REAL).&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Use an IEC variable to set the Present Value of:
    &lt;ul&gt;
    &lt;li&gt;an Analog Input BACnet Object (supports INT, REAL);&lt;/li&gt;
    &lt;li&gt;a Binary Input BACnet Object (supports BOOL).&lt;/li&gt;
    &lt;li&gt;a Multi State Input BACnet Object (supports DINT, UDINT, USINT).&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Set the Object Identifier of the Device BACnet Object using EEPROM parameters and store in those parameters any change to the Idetifier originating from the BACnet side.&lt;/li&gt;
  &lt;li&gt;Update the above mentioned EEPROM parameters after a Device ID change from the supervisor. Notify when it happens that those parameters are locally changed.&lt;/li&gt;
  &lt;li&gt;Automate the Present Value update procedure of each BACnet Object type.&lt;/li&gt;
  &lt;li&gt;Be able to read and write an UDINT value as REAL.&lt;/li&gt;
&lt;/ul&gt;

In addition, the documentation attached to this library (i.e. BACnet Application Project Template) will guide you through the implementation of the following functions:
&lt;ul&gt;
  &lt;li&gt;Setup the BBMD Service.&lt;/li&gt;
  &lt;li&gt;Define the Warm Restart and Cold Restart procedures, which are executed by the &lt;i&gt;ReinitializeDevice&lt;/i&gt; service.&lt;/li&gt;
  &lt;li&gt;Write the &lt;i&gt;BACnet Setup Init&lt;/i&gt;, which for instance contains also the call to the Object_Identifier function.&lt;/li&gt;
  &lt;li&gt;Add BACnet objects using pre-configured &lt;b&gt;XML Objects templates&lt;/b&gt;, where the properties (Publish, EEPROM, etc.) are already defined.&lt;/li&gt;
&lt;/ul&gt;

The &lt;b&gt;targets&lt;/b&gt; supported by this library version are:
  &lt;ul&gt;
  &lt;li&gt;BIOS 423.26 and greater;&lt;/li&gt;
  &lt;li&gt;BIOS 477.26 and greater;&lt;/li&gt;
  &lt;li&gt;BIOS 489.19 and greater;&lt;/li&gt;
  &lt;li&gt;BIOS 596.6 and greater;&lt;/li&gt;
  &lt;li&gt;BIOS 668.6 and greater.&lt;/li&gt;
  &lt;/ul&gt;

The library is tested/supported on EcoStruxure Machine Expert HVAC 1.2.1 and greater versions.

&lt;p&gt;Together with the library and the implementation example, &lt;b&gt;templates of several BACnet Objects&lt;/b&gt; are provided, in order to achieve a smoother and easier implementation of the various Objects.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
	<libWorkspace>
		<folder name="bacnet_addons" id="18719">
			<folder name="Object Identifier">
				<Pou name="BACnet_ObjID"/>
				<Pou name="BACnet_ObjID_De_store_EE"/>
			</folder>
			<folder name="Conversion">
				<Pou name="BACnet_r_ROUND_ui"/>
				<Pou name="BACnet_r_ROUND_udi"/>
				<Pou name="BACnet_r_ROUND_i"/>
				<Pou name="BACnet_r_ROUND_di"/>
				<Pou name="BACnet_di_TO_x"/>
			</folder>
			<folder name="Input BACnet Objects">
				<Pou name="BACnet_AI_SetPV"/>
				<Pou name="BACnet_BI_SetPV"/>
				<Pou name="BACnet_MSI_diSetPV"/>
				<Pou name="BACnet_MSI_udiSetPV"/>
				<Pou name="BACnet_MSI_usiSetPV"/>
			</folder>
			<Pou name="BACnet_PVUpdPr"/>
			<GlobalVars name="BACnet GlobalVars"/>
			<folder name="UDINT as REAL">
				<Pou name="BACnet_UdAsReal_read"/>
				<Pou name="BACnet_UdAsReal_write"/>
			</folder>
			<folder name="Value BACnet Objects">
				<Pou name="BACnet_RelDef_MV_link_usi"/>
				<Pou name="BACnet_RelDef_AV_link_i"/>
				<Pou name="BACnet_RelDef_AV_link_r"/>
				<Pou name="BACnet_RelDef_AV_link_ui"/>
				<Pou name="BACnet_RelDef_BV_link_x"/>
				<Pou name="BACnet_RelDef_MV_link_i"/>
				<Pou name="BACnet_RelDef_MV_link_r"/>
				<Pou name="BACnet_RelDef_MV_link_udi"/>
				<Pou name="BACnet_RelDef_MV_link_ui"/>
				<Pou name="BACnet_udiValue_link_r"/>
			</folder>
		</folder>
	</libWorkspace>
	<globalVars>
		<group name="BACnet GlobalVars"/>
	</globalVars>
	<retainVars>
		<group name="BACnet GlobalVars"/>
	</retainVars>
	<constantVars>
		<group name="BACnet GlobalVars">
			<const name="BACnet_rNULL" type="REAL">
				<initValue>340282346638528860000000000000000000000.00000000</initValue>
			</const>
			<const name="BACnet_udiNULL" type="UDINT">
				<initValue>4294967295</initValue>
			</const>
			<const name="BACnet_xNULL" type="USINT">
				<initValue>255</initValue>
			</const>
		</group>
	</constantVars>
	<iecVarsDeclaration>
		<group name="BACnet GlobalVars">
			<iecDeclaration active="FALSE"/>
		</group>
	</iecVarsDeclaration>
	<functions>
		<function name="BACnet_UdAsReal_write" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<descr>&lt;HTML&gt;This function allows you to write a REAL value which is stored as UDINT in a BACnet attribute.

&lt;p&gt;Passing the pointer to the UDINT variable/attribute where a REAL value has to be written instead, it performs the data format equivalence and writes the rValue. If the BACnet attribute is set to be in EEPROM, xE2 must be TRUE.&lt;/p&gt;

&lt;p&gt;The returned value is the attribute value in REAL.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<returnValue>REAL</returnValue>
			<vars>
				<inputVars>
					<var name="ptr_udi" type="@UDINT">
						<descr>Pointer to the BACnet attribute.</descr>
					</var>
					<var name="rValue" type="REAL">
						<descr>Value to be written.</descr>
					</var>
					<var name="xE2" type="BOOL">
						<descr>Used to define if the BACnet attribute is in EEPROM or not. TRUE if it is, FALSE if it is not.</descr>
					</var>
				</inputVars>
				<localVars>
					<var name="ptr_r" type="@REAL"/>
					<var name="usiRet" type="USINT"/>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_Sc_write_REAL												*
*																					*
* PURPOSE		: Write a REAL value from the IEC code into a Schedule BACnet Obj	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	28-02-18 	Pierpaolo Armeli	First release 								*
* 												 									*
*************************************************************************************)

ptr_r := ptr_udi;
@ptr_r := rValue;

IF xE2 THEN //in EEPROM
	usiRet := sysBACnet_WriteE2Par(ptr_udi,ADR(rValue));
END_IF;

BACnet_UdAsReal_write := @ptr_r;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_UdAsReal_read" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<descr>&lt;HTML&gt;This function allows you to read a REAL value which is stored as UDINT in a BACnet attribute.

&lt;p&gt;Passing the pointer to the UDINT variable/attribute where a REAL value has been written instead, it performs the data format equivalence and returns as output the REAL value that has originally been written on the variable/attribute.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<returnValue>REAL</returnValue>
			<vars>
				<inputVars>
					<var name="ptr_udi" type="@UDINT">
						<descr>Pointer to the BACnet attribute that has to be read.</descr>
					</var>
				</inputVars>
				<localVars>
					<var name="ptr_r" type="@REAL"/>
					<var name="usiRet" type="USINT"/>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_Sc_write_REAL												*
*																					*
* PURPOSE		: Read a REAL value from a Schedule BACnet Object				 	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	28-02-18 	Pierpaolo Armeli	First release 								*
* 												 									*
*************************************************************************************)

ptr_r := ptr_udi;
BACnet_UdAsReal_read := @ptr_r;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_di_TO_x" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<returnValue>BOOL</returnValue>
			<vars>
				<inputVars>
					<var name="diValue" type="DINT"/>
				</inputVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[IF diValue=0 THEN
	BACnet_di_TO_x:=FALSE;
ELSIF diValue=1 THEN
	BACnet_di_TO_x:=TRUE;
END_IF;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_r_ROUND_di" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<returnValue>DINT</returnValue>
			<vars>
				<inputVars>
					<var name="rValue" type="REAL"/>
				</inputVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[IF rValue>=0.0 THEN
	BACnet_r_ROUND_di:=TO_DINT(rValue+0.5);
ELSE
	BACnet_r_ROUND_di:=TO_DINT(rValue-0.5);
END_IF;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_r_ROUND_i" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<returnValue>INT</returnValue>
			<vars>
				<inputVars>
					<var name="rValue" type="REAL"/>
				</inputVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[IF rValue>=0.0 THEN
	BACnet_r_ROUND_i:=TO_INT(rValue+0.5);
ELSE
	BACnet_r_ROUND_i:=TO_INT(rValue-0.5);
END_IF;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_r_ROUND_udi" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<returnValue>UDINT</returnValue>
			<vars>
				<inputVars>
					<var name="rValue" type="REAL"/>
				</inputVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[IF rValue>=0.0 THEN
	BACnet_r_ROUND_udi:=TO_UDINT(rValue+0.5);
ELSE
	BACnet_r_ROUND_udi:=TO_UDINT(rValue-0.5);
END_IF;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_r_ROUND_ui" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<returnValue>UINT</returnValue>
			<vars>
				<inputVars>
					<var name="rValue" type="REAL"/>
				</inputVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[IF rValue>=0.0 THEN
	BACnet_r_ROUND_ui:=TO_UINT(rValue+0.5);
ELSE
	BACnet_r_ROUND_ui:=TO_UINT(rValue-0.5);
END_IF;
]]>
			</sourceCode>
		</function>
		<function name="BACnet_ObjID" version="1.1.0" creationDate="0" lastModifiedDate="0">
			<title>It calculates the BACnet Object Identifier</title>
			<descr>&lt;HTML&gt;It calculates the BACnet Object Identifier given the BACnet node number and subnet value.
&lt;p&gt;It is suggested to store the two parameters required by this function in the EEPROM of the device.&lt;/p&gt;

&lt;p&gt;This function has to be called in the Init task in order to restore the Device Object Identifier after each device restart.&lt;/p&gt;
&lt;p&gt;In this way, the BACnet Object Identifier will be kept always the same, even after a restart.&lt;/p&gt;

An &lt;b&gt;implementation example&lt;/b&gt; of this function is provided in the &lt;i&gt;BACnet Application Project Template&lt;/i&gt; chapter, which can be found in the Library documentation (please see the description of the library for the link to the documentation).

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<returnValue>UDINT</returnValue>
			<vars>
				<inputVars>
					<var name="udiBACnet_ID" type="UDINT">
						<descr>BACnet ID value</descr>
					</var>
					<var name="usiBACnet_Subnet" type="USINT">
						<descr>BACnet Subnet value</descr>
					</var>
				</inputVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_ObjID														*
*																					*
* PURPOSE		: Calculate the BACnet Object Identifier.							*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2  	22-08-19 	Pierpaolo Armeli	Changed BACnet_ID to UDINT format			*
* 												 									*
*************************************************************************************)

BACnet_ObjID := 33554432 + udiBACnet_ID + SHL(TO_UDINT(usiBACnet_Subnet),16);
]]>
			</sourceCode>
		</function>
	</functions>
	<functionBlocks>
		<functionBlock name="BACnet_udiValue_link_r" version="1.1.0" creationDate="0" lastModifiedDate="1603723846">
			<title>Link a REAL EEPROM parameter to the value of an UDINT BACnet attribute</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link a REAL variable or EEPROM parameter to the value of an UDINT BACnet attribute.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where you would like to keep a BACnet UDINT attribute aligned with a REALvariable or EEPROM parameter.&lt;/p&gt;

&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt; of a BACnet Object to keep it synchronized with the variable or EEPROM parameter. No scaler is used.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are:
  &lt;ul&gt;
  &lt;li&gt;The UDINT value address &lt;span style='font-family: Courier New '&gt;ptrBACnet_udiAttribute&lt;/span&gt;. This is not the address of the BACnet Object, but the address of a specific attribute of it.&lt;/li&gt;
  &lt;li&gt;The address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_rEE&lt;/span&gt;.&lt;/li&gt;
  &lt;/ul&gt;

This FB can either be called in background or in timed, depending on the requirements of your application. Note that until its first execution, the value of the attribute (e.g. a Schedule Default) will not be correctly aligned. Therefore, in case you use the attribute in a timed task it is important either:
  &lt;ul&gt;
  &lt;li&gt;to call an instance of the FB also in the Init task, when it is called in a background task;&lt;/li&gt;
  &lt;li&gt;if the FB is called in a timed task, this has to be set before the other timed tasks which use the linked attribute.&lt;/li&gt;
  &lt;/ul&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_udiValue_link_rEE&lt;/span&gt; FB.&lt;/p&gt;
&lt;p&gt;The purpose is to link the &lt;span style='font-family: Courier New '&gt;rSetpoint_DefSch&lt;/span&gt; EEPROM parameter to the &lt;span style='font-family: Courier New '&gt;Schedule_Default&lt;/span&gt; value of the &lt;span style='font-family: Courier New '&gt;Sc_Setpoint_REAL_Schedule&lt;/span&gt; Schedule BACnet Object.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note that this function block can be used for any type of BACnet Object.&lt;/b&gt;&lt;/p&gt;
&lt;img src= BACnet_udiValue_link_rEE.png  width= 500 &gt;



&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;rRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;rRelMax&lt;/span&gt; allow to limit the value that the EEPROM parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range writes from the supervisor side.&lt;/p&gt;
&lt;p&gt;In case of an out-of-range write from the supervisor on the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt;, this write will not be accepted (the EEPROM does not get updated with the written value) and the value which is present in the EEPROM will be restored on the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Versions:&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
Ver. 1.1:&lt;br&gt;
- Fix change from Bacnet BMS&lt;br&gt;
- Fix out of range write from Bacnet BMS&lt;br&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="ptr_BACnet_udiAttribute" type="@UDINT">
						<descr>UDINT Attribute Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_r" type="@REAL">
						<descr>Local Variable / EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for attribute value in REAL.</descr>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for attribute value in REAL.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="rValue" type="REAL">
						<descr>REAL attribute value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xWriteFlag" type="BOOL">
						<descr>Takes trace of the last type of write operation on the attribute value.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRel_to_write" type="REAL">
						<descr>REAL value to be written on the attribute.</descr>
					</var>
					<var name="xModified" type="BOOL">
						<descr>Flag that informs if the attribute has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRel_to_write_old" type="REAL"/>
					<var name="rWritten" type="REAL"/>
					<var name="rReadVal" type="REAL"/>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_udiValue_link_r											*
*																					*
* PURPOSE		: Link a REAL EEPROM parameter to the value of an					*
*		   	   	  UDINT BACnet attribute 											*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 1.1  	26-10-20 	Federico Marcassa	Fix change from Bacnet BMS					*
* 										Fix out of range write from Bacnet BMS		*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 2: there is a configuration error;
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF NOT (ptr_BACnet_udiAttribute=0) AND NOT (ptr_r=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	wStatus:=wStatus OR UINT#2#1;

	rRel_to_write := @ptr_r;
		
	// I write on the BACnet attribute
	IF rRel_to_write_old<>rRel_to_write OR NOT(runCheck) THEN
		xWriteFlag:=TRUE;	// Ver. 1.1
		rWritten:=BACnet_UdAsReal_write(ptr_BACnet_udiAttribute,rRel_to_write,TRUE);
	ELSE
		xWriteFlag:=FALSE; // Ver. 1.1
	END_IF;	
	
	rReadVal:=BACnet_UdAsReal_read(ptr_BACnet_udiAttribute);
	
	IF rReadVal<>rRel_to_write AND NOT(xWriteFlag) THEN // Ver. 1.1
		xModified:=TRUE;
	ELSE
		xModified:=FALSE;
	END_IF;
	
	rRel_to_write_old:=rRel_to_write;
	
	IF rReadVal<rRelMin THEN // I saturate rValue with Min and Max in the Out of Range case
		rValue:=rRel_to_write;	// Ver. 1.1
		inside_limits_flag:=FALSE;
	ELSIF rReadVal>rRelMax THEN
		rValue := rRel_to_write;	// Ver. 1.1
		inside_limits_flag:=FALSE;
	ELSE
		rValue:=rReadVal;
		inside_limits_flag:=TRUE;
	END_IF;
	
	IF xModified THEN
		IF inside_limits_flag THEN	// Ver. 1.1
			
			IF NOT(sysWriteParREAL(ptr_r,rReadVal)) THEN
				@ptr_r := rReadVal;
			END_IF;
			
		ELSE
			rWritten:=BACnet_UdAsReal_write(ptr_BACnet_udiAttribute,rRel_to_write,TRUE);
		END_IF;
	END_IF;
	
ELSE // FB not configured properly
	xWriteFlag := FALSE;	// Ver. 1.1	
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	rValue:=@ptr_r;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_udivalue_link_ree.png" width="733" height="136">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAt0AAACICAIAAAHDjvBeAAAAAXNS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OnHKcBqcyQoYabuQXAW7NzngbkADQwAHUH6
MftVZXzCLgHXRtgliwcaGAA6osEuedraI7Xhud9VnasGgoMRdsnigQYGgI5osEsc3aPCaztX
zWyUEJ/yKcIzw+5YFBA8nrBLFo+KBu7W6kgVA6liLDhVZiWUaUelre1ctSQff3IJWyTOOgHB
jmwerZ3HsrmOAVLF6DFVl4wAACDQiMqsBGOFqbGyc9XIjtFlFTZo0oTkA9MEPIGd+zwwF6CB
AaAjau2SEdmPXQKC8yHsksUDDQwAHQG7BATHJ+ySxQMNDABrBOwScKaEXbJ4oIEBYI2AXQLO
lLBLFg80MACsFDBNwNkRRskagDYGgPWCtDysE3AW1L5qHRdYNNDMAAAAAABMBRV2STebFKli
IFUMpIqBVDGQKgZSxUCqGKtK1SUjAAAAAACAIQC7BAAAAACAqQB2CQAAAAAAUwHsEgAAAAAA
poHv7/8HEQ/ize1MNCEAAAAASUVORK5CYII=]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_ui" version="1.0.1" creationDate="0" lastModifiedDate="0">
			<title>Link a Multi State Value BACnet Object to an UINT local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link an UINT variable or EEPROM parameter to a Multi State Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_ui&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
See the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_MV_link_usi&lt;/span&gt; FB. The implementation is analogous.

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the local parameter; a change in the local parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the PV output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in the Background task, the global variable connected to the PV output has to be initialized in the Init task, by setting it equal to the local parameter. If the link FB is called in the Timed Task instead, this initialization is not required, but it is important to run the program that uses it before the other timed programs that use the PV output.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_ui" type="@UINT">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>Offset summed to the local parameter.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value used if out of range. The range is 1 ... Number_Of_States.</descr>
						<initValue>1</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="uiPV_current" type="UINT">
						<descr>Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
					<var name="uiPV_offset" type="UINT">
						<descr>Present Value w/ Offset</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="uiEE_old" type="UINT">
						<descr>Last value of the iRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="uiRelinq_current_minus_Offset" type="UINT">
						<descr>Scaled UINT value present in the Relinquish Default</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="uiEE" type="UINT">
						<descr>UINT Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="ui_to_write" type="UINT"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiPV" type="UDINT"/>
					<var name="udiPV_old" type="UDINT"/>
					<var name="diEE" type="DINT"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_ui											*
*																					*
* PURPOSE		: Set the present value of a Multi State Value UINT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 2		16-07-18	Pierpaolo Armeli	Added uiPV_offset output					*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_ui=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		uiEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------		
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;

	xEn_old:=xEn;
		
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	uiEE := @ptr_ui;
	diEE := TO_DINT(uiEE)+TO_DINT(iOffset);

	// -------    diEE consistency check    ---------	
	udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF uiEE_old<>uiEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			uiRelinq_current_minus_Offset := TO_UINT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			
			IF NOT(sysWriteParUINT(ptr_ui, uiRelinq_current_minus_Offset)) THEN
				@ptr_ui := uiRelinq_current_minus_Offset;
			END_IF;
			
		ELSE
			@ptrMV_BACnet.Relinquish_Default := TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;	

	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;

	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			ui_to_write:=TO_UINT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			
			IF NOT(sysWriteParUINT(ptr_ui, ui_to_write)) THEN
				@ptr_ui := ui_to_write;
			END_IF;
			
			uiEE_old:=uiEE;
		END_IF;
	END_IF;

	uiEE_old:=@ptr_ui;
	udiPV_old:=udiPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;
	
// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrMV_BACnet.Priority_Array[j_Act].choice_integer<>BACnet_udiNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	IF NOT(inside_limits_flag) THEN
		uiPV_current := TO_UINT(iWrongLinkValue);
		uiPV_offset := TO_UINT(iWrongLinkValue)-TO_UINT(iOffset);
	ELSE
		uiPV_current := TO_UINT(udiPV);
		uiPV_offset := TO_UINT(udiPV)-TO_UINT(iOffset);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
		
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;

	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	uiPV_current:=@ptr_ui;
	uiPV_offset:=@ptr_ui-TO_UINT(iOffset);
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_udi" version="1.0.1" creationDate="0" lastModifiedDate="0">
			<title>Link a Multi State Value BACnet Object to an UDINT local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link an UDINT variable or EEPROM parameter to a Multi State Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_udi&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
See the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_MV_link_usi&lt;/span&gt; FB. The implementation is analogous.


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the local parameter; a change in the local parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the PV output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in the Background task, the global variable connected to the PV output has to be initialized in the Init task, by setting it equal to the local parameter. If the link FB is called in the Timed Task instead, this initialization is not required, but it is important to run the program that uses it before the other timed programs that use the PV output.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_udi" type="@UDINT">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>Offset summed to the local parameter.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value used if out of range. The range is 1 ... Number_Of_States.</descr>
						<initValue>1</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="udiPV_current" type="UDINT">
						<descr>Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
					<var name="udiPV_offset" type="UDINT">
						<descr>Present Value w/ Offset</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="udiEE_old" type="UDINT">
						<descr>Last value of the iRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="udiRelinq_current_minus_Offset" type="UDINT">
						<descr>Scaled UDINT value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="udiEE" type="UDINT">
						<descr>UDINT Value to be written in RelinquishDefault. If iValue=32767, it is disabled and rValue is used instead.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="udiPV_old" type="UDINT"/>
					<var name="udi_to_write" type="UDINT"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiEE_offs" type="UDINT"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_udi											*
*																					*
* PURPOSE		: Set the present value of a Multi State Value UDINT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 2		16-07-18	Pierpaolo Armeli	Added udiPV_offset output					*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_udi=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		udiEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
		
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------			
	udiEE := @ptr_udi;
	udiEE_offs:= udiEE + TO_UDINT(iOffset);
	
	// -------    udiEE_offs consistency check    ---------
	udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	IF (udiEE_offs<udiRelMin OR udiEE_offs>udiRelMax) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------

	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF udiEE_old<>udiEE THEN
			@ptrMV_BACnet.Relinquish_Default:=udiEE_offs;
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>udiEE_offs AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;
	
	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			udiRelinq_current_minus_Offset := TO_UDINT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
		
			IF NOT(sysWriteParUDINT(ptr_udi, udiRelinq_current_minus_Offset)) THEN
				@ptr_udi := udiRelinq_current_minus_Offset;
			END_IF;
			
		ELSE
			@ptrMV_BACnet.Relinquish_Default := udiEE_offs;
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;
	
	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(udiEE_offs);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;	
		
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			udi_to_write:=TO_UDINT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
		
			IF NOT(sysWriteParUDINT(ptr_udi, udi_to_write)) THEN
				@ptr_udi := udi_to_write;
			END_IF;
			
			udiEE_old:=udiEE;
		END_IF;
	END_IF;		

	udiEE_old:=@ptr_udi;
	udiPV_old:=udiPV;

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------	
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrMV_BACnet.Priority_Array[j_Act].choice_integer<>BACnet_udiNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	IF NOT(inside_limits_flag) THEN
		udiPV_current := TO_UDINT(iWrongLinkValue);
		udiPV_offset := TO_UDINT(iWrongLinkValue) - TO_UDINT(iOffset);
	ELSE
		udiPV_current := udiPV;
		udiPV_offset := udiPV - TO_UDINT(iOffset);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
		
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
 	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	udiPV_current:=@ptr_udi;
	udiPV_current:=@ptr_udi - TO_UDINT(iOffset);
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_r" version="1.0.1" creationDate="0" lastModifiedDate="0">
			<title>Link a Multi State Value BACnet Object to a REAL local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link a REAL variable or EEPROM parameter to a Multi State Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_r&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Check the range limitations given by this setting before using this variant of the BACnet_RelDef_MV_link FBs Family.&lt;/b&gt; A &lt;u&gt;TO_UDINT conversion&lt;/u&gt; takes place before writing the REAL number on the Relinquish.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
See the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_MV_link_usi&lt;/span&gt; FB. The implementation is analogous.

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the local parameter; a change in the local parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the PV output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in the Background task, the global variable connected to the PV output has to be initialized in the Init task, by setting it equal to the local parameter. If the link FB is called in the Timed Task instead, this initialization is not required, but it is important to run the program that uses it before the other timed programs that use the PV output.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_r" type="@REAL">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>Offset summed to the local parameter.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value used if out of range. The range is 1 ... Number_Of_States.</descr>
						<initValue>1</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="rPV_current" type="REAL">
						<descr>Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
					<var name="rPV_offset" type="REAL">
						<descr>Present Value w/ Offset</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="rEE_old" type="REAL">
						<descr>Last value of the iRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRelinq_current_minus_Offset" type="REAL">
						<descr>Scaled REAL value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rEE" type="REAL">
						<descr>REAL Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="udiPV_old" type="UDINT"/>
					<var name="r_to_write" type="REAL"/>
					<var name="diEE" type="DINT"/>
					<var name="xOOS" type="BOOL"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="j_overr" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_r											*
*																					*
* PURPOSE		: Set the present value of a Multi State Value REAL BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 2		16-07-18	Pierpaolo Armeli	Added rPV_offset output						*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_r=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		rEE_old:=0.0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;

	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	

	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
 			
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	rEE := @ptr_r;
	diEE := BACnet_r_ROUND_di(rEE) + TO_DINT(iOffset);

	// -------    diEE consistency check    ---------
		udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF rEE_old<>rEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;
	
	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			rRelinq_current_minus_Offset:=TO_REAL(TO_DINT(udiRelDef)-TO_DINT(iOffset));
		
			IF NOT(sysWriteParREAL(ptr_r,rRelinq_current_minus_Offset)) THEN
				@ptr_r := rRelinq_current_minus_Offset;
			END_IF;	
			
		ELSE
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;
	
	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;

	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			r_to_write:=TO_REAL(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			
			IF NOT(sysWriteParREAL(ptr_r,r_to_write)) THEN
				@ptr_r := r_to_write;
			END_IF;	
			
			rEE_old:=rEE;
		END_IF;
	END_IF;

	rEE_old:=@ptr_r;
	udiPV_old:=udiPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrMV_BACnet.Priority_Array[j_Act].choice_integer<>BACnet_udiNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------	
	IF NOT(inside_limits_flag) THEN
		rPV_current := TO_REAL(iWrongLinkValue);
		rPV_offset := TO_REAL(iWrongLinkValue)-TO_REAL(iOffset);
	ELSE
		rPV_current := TO_REAL(udiPV);
		rPV_offset := TO_REAL(udiPV)-TO_REAL(iOffset);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
		
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;

	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	rPV_current:=@ptr_r;
	rPV_current:=@ptr_r-TO_REAL(iOffset);
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_i" version="1.0.1" creationDate="0" lastModifiedDate="0">
			<title>Link a Multi State Value BACnet Object to an INT local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link an INT variable or EEPROM parameter to a Multi State Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_i&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Check the range limitations given by this setting before using this variant of the BACnet_RelDef_MV_link FBs Family.&lt;/b&gt; A &lt;u&gt;TO_UDINT conversion&lt;/u&gt; takes place before writing the INT number on the Relinquish.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
See the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_MV_link_usi&lt;/span&gt; FB. The implementation is analogous.

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the local parameter; a change in the local parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the PV output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in the Background task, the global variable connected to the PV output has to be initialized in the Init task, by setting it equal to the local parameter. If the link FB is called in the Timed Task instead, this initialization is not required, but it is important to run the program that uses it before the other timed programs that use the PV output.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_i" type="@INT">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>Offset summed to the local parameter.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value used if out of range. The range is 1 ... Number_Of_States.</descr>
						<initValue>1</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="iPV_current" type="INT">
						<descr>Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
					<var name="iPV_offset" type="INT">
						<descr>Present Value w/ Offset</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="diEE" type="DINT">
						<descr>DINT value to be written in the Reliquish Default</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="iRelinq_current_minus_Offset" type="INT">
						<descr>Scaled INT value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="iEE" type="INT">
						<descr>INT Value to be written in RelinquishDefault. If iValue=32767, it is disabled and rValue is used instead.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="udiPV_old" type="UDINT"/>
					<var name="iEE_old" type="INT"/>
					<var name="i_to_write" type="INT"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiRelDef" type="UDINT"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_i											*
*																					*
* PURPOSE		: Set the present value of a Multi State Value INT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 2		16-07-18	Pierpaolo Armeli	Added iPV_offset output						*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_i=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		iEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;	
			
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	iEE := @ptr_i;
	diEE := TO_DINT(iEE)+TO_DINT(iOffset);
	
		// -------    diEE consistency check    ---------
	udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF iEE_old<>iEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			iRelinq_current_minus_Offset:=TO_INT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			
			IF NOT(sysWriteParINT(ptr_i,iRelinq_current_minus_Offset)) THEN
				@ptr_i := iRelinq_current_minus_Offset;
			END_IF;
			
		ELSE
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;

	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			i_to_write:=TO_INT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			
			IF NOT(sysWriteParINT(ptr_i,i_to_write)) THEN
				@ptr_i := i_to_write;
			END_IF;
			
			iEE_old:=iEE;
		END_IF;
	END_IF;

	iEE_old:=@ptr_i;
	udiPV_old:=udiPV;

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrMV_BACnet.Priority_Array[j_Act].choice_integer<>BACnet_udiNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------	
	IF NOT(inside_limits_flag) THEN
		iPV_current := iWrongLinkValue;
		iPV_offset := iWrongLinkValue - iOffset;
	ELSE
		iPV_current := TO_INT(udiPV);
		iPV_offset := TO_INT(udiPV)-iOffset;
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	iPV_current:=@ptr_i;
	iPV_current:=@ptr_i-iOffset;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_reldef_mv_link_iee.png" width="801" height="217">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAyEAAADZCAYAAAA3xz8aAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAEL5SURBVHhe7Z27rhvL1a31Ksr0ACvZ
0gsoVKBwxQz0FIsP8GNLwAF2sgEdA0oFwYCPMhnwBgQYUGA4UfArMJw42TDsN+jTs7qqOWvW
rL6Q3U1y8RvAwGJ33W+sMVjNxScNAAAAcHP40fz805PmyRPF3ecYdmH48XPzU6jjrilr+LnZ
VcPGIGl/an7+ES+3RGhTrHPfPo8z4gAArgqYEAAAADeHz7tWvGamI5qSSzQiQYD/1PzU1q+o
3udd8+SnNuzaTIiGNiQ1TIkDALgqYEIAAADcGCri+1KFbqzXzz+3ZsNUWszU7udj640JAQCc
D5gQAAAAN4appx7pUSfnkR85gdCPBOm8sjAj8oOYdsKU0Uhpe8ORBLj8/enntvYJUr94X9ev
VoZA1223MyZkoL01uGWr61pf6Hg2jYcpcQAAVwVMCAAAgBuEFtwtC0PSGZV0+4eYg94AdGn7
JEFoJ4EtYUpsS9hgOi3ElfEowuS11MnkLZllAn2gDBMW2tTXdai9A7DmoKhLpS90vPBajYXm
oULjcQAAVwVMCAAAgBtHJ84zQWvFtRXUGXRYLvQzDOUZwlT+Oq56LeYgGZXwKFZ3043bQZWh
TUCALb+Sbgg2XXY9sS+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>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_BV_link_x" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<title>Link a Binary Value BACnet Object to a BOOL local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link a BOOL variable or EEPROM parameter to a Binary Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrBV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_x&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;img src= bacnet_reldef_bv_link_xee.png  width= 500 &gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the local parameter; a change in the local parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the PV output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in the Background task, the global variable connected to the PV output has to be initialized in the Init task, by setting it equal to the local parameter. If the link FB is called in the Timed Task instead, this initialization is not required, but it is important to run the program that uses it before the other timed programs that use the PV output.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrBV_BACnet" type="@BACNET_BINARY_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_x" type="@BOOL">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="xPV_current" type="BOOL">
						<descr>Current Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_xNULL" type="BOOL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="BV_Description" type="STRING" length="32">
						<descr>Binary Value Description</descr>
					</var>
					<var name="siEE" type="SINT">
						<descr>SINT value to be written in the Reliquish Default</descr>
					</var>
					<var name="dintRet" type="DINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xPV" type="BOOL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="xEE_val" type="BOOL">
						<descr>BOOL Value to be written in RelinquishDefault. If iValue=32767, it is disabled and rValue is used instead.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
						<initValue>0</initValue>
					</var>
					<var name="xEE_old" type="BOOL"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="xPV_old" type="BOOL"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_BV_link_x											*
*																					*
* PURPOSE		: Set the present value of a Binary Value BACnet Object.			*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;		
 - bit 4: Priority Active (override from supervisor)						*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrBV_BACnet.Object_Type=BACnetObjectType#OBJECT_BINARY_VALUE AND NOT (ptrBV_BACnet=0) AND NOT (ptr_x=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		xEE_old:=NOT(@ptr_x);
		xPV_old:=@ptrBV_BACnet.Present_Value<>0;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrBV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrBV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrBV_BACnet.Description:=BV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		BV_Description := @ptrBV_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrBV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------

	xEE_val := @ptr_x;
	IF xEE_val THEN siEE := 1; ELSE siEE := 0; END_IF;
	
	IF xEE_old<>xEE_val THEN
		@ptrBV_BACnet.Relinquish_Default:=siEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrBV_BACnet.Priority_Array[j_overr].choice_binary := BACnet_xNULL;
			END_FOR;
		END_IF;
	END_IF;	
	
	IF @ptrBV_BACnet.Relinquish_Default<>siEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;	

	IF xRelMod THEN
		
		IF NOT (sysWriteParBOOL(ptr_x, @ptrBV_BACnet.Relinquish_Default<>0)) THEN
			@ptr_x := @ptrBV_BACnet.Relinquish_Default<>0;
		END_IF;
		
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN dintRet := sysBACnet_BV_PresentValue(ptrBV_BACnet); END_IF;
	
	IF @ptrBV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		xPV:=xEE_val;
		xOOS:=TRUE;
	ELSE
		xPV:=@ptrBV_BACnet.Present_Value<>0;
		xOOS:=FALSE;
	END_IF;	

	IF xPV_old<>xPV AND usiMode=2 AND NOT(xOOS) THEN
		IF NOT (sysWriteParBOOL(ptr_x,xPV)) THEN
			@ptr_x := xPV;
		END_IF;
		
		xEE_old:=xEE_val;
	END_IF;

	xEE_old:=@ptr_x;
	xPV_old:=xPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrBV_BACnet.Priority_Array[j_overr].choice_binary := BACnet_xNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;
	
// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrBV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrBV_BACnet.Priority_Array[j_Act].choice_binary<>BACnet_xNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;
	
// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	xPV_current:=xPV;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrBV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	xPV_current:=@ptr_x;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_reldef_bv_link_xee.png" width="561" height="164">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAjEAAACkCAYAAABmW38tAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACcBSURBVHhe7V1BiyW3te5fkHW2s/MP
6E2YRXZmlrPwstezGG+cf9C9DTzMmEe8MYzBs22MIQnE0IEYBgJemHgxi+eE4I0hmJD8g3o6
RzqqoyOpqu69UnXVvd8HH31Vko5UUpXOd09VX10NAAAAAAAAOwREDAAAAAAAuwREDAAAAOHv
Xw/v/+I3w0d/CmmHf3zy2+GXv/hi+DqkDwLZ+/XXwz9CMqJ2fAn+9IXrz28ix75+P3w0a3NJ
mQNh+vPLX/x2+N3fJ44DQGNAxAAAABBYXPx2eP/D78OBfw2/o/SvG4uYY8EiS/WF00EcLGmr
dX8IJFbieCnUjgNAY0DEAAAAEIKT/90n4ui/Hz760KWViPGRmRBd0E6aBYVEHUJ5tvfF8NGv
TXkRE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CGAADoAogYcO+EiNk+MEMAAHQDOQGIGXBvlOsW
2D4wSwAAdIc4BRDcA4H9ALMFAAAAAMAuAREDAAAAAMAuAREDAAAAAMAuAREDAAAAAMAuARED
AAAAAMAuAREDAAAAAMAuAREDAAAAAMAOMQz/D4gB0ammkyWXAAAAAElFTkSuQmCC]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_AV_link_ui" version="1.1.0" creationDate="0" lastModifiedDate="1603789382">
			<title>Link an Analog Value BACnet Object to an UINT local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link a UINT variable or EEPROM parameter to an Analog Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrAV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_ui&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
See the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_AV_link_i&lt;/span&gt; FB. The implementation is analogous.

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the scaled output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in a background task, the global variable connected to the scaled output has to be initialized in an init task, by setting it equal to the local parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the scaled output.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range (OOR) writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; allow to limit the values the local parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;Local variable / EEprom parameter&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range (OOR) writes from the supervisor side.&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;With usiMode equal to 0 or 1, in case of an OOR write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;, this write will not be accepted and the local value will be restored on the BACnet side.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In case of an OOR write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Priority_Array / Relinquish&lt;/span&gt;, which will cause an OOR &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt;, the scaled output of the FB will be saturated with the &lt;u&gt;&lt;b&gt;scaled&lt;/u&gt;&lt;/b&gt; &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; (if lower than it) or the &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; (if higher than it) and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute of the BACnet Object will be set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNDER_RANGE&lt;/span&gt; in the former case and to &lt;span style='font-family: Courier New '&gt;RELIABILITY_OVER_RANGE&lt;/span&gt; in the latter one.&lt;br&gt;
  The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; gets back into the limits. &lt;br&gt;&lt;span style='font-family: Courier New '&gt;Local variable / EEprom parameter&lt;/span&gt; will be updated accordingly to the scaled limited output of the FB.
  &lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;Please note that &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; are both scaled by multiplying them by the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; before using them for the comparisons.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Versions:&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
Ver. 1.1:&lt;br&gt;
- Fixed update of Local Variable / EEprom in case of OOR write and usiMode=2&lt;br&gt;
- Updated description in case of OOR write from supervisor&lt;br&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrAV_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_ui" type="@UINT">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="uiRelMin" type="UINT">
						<descr>Local value lower limit. Scaled by rScaler.</descr>
						<initValue>0</initValue>
					</var>
					<var name="uiRelMax" type="UINT">
						<descr>Local value higher limit. Scaled by rScaler.</descr>
						<initValue>65535</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="uiPV_scaled" type="UINT">
						<descr>Scaled Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_rNULL" type="REAL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AV_Description" type="STRING" length="32">
						<descr>Analog Value Description</descr>
					</var>
					<var name="rRel_to_write" type="REAL">
						<descr>REAL value to be written in the Reliquish Default</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="uiRelinqScaled" type="UINT">
						<descr>Scaled UINT value present in the Relinquish Default</descr>
					</var>
					<var name="rPV" type="REAL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_over" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="writeRel_under" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="rPV_old" type="REAL"/>
					<var name="uiEE_old" type="UINT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="uiEE" type="UINT"/>
					<var name="j_overr" type="USINT"/>
					<var name="rEE" type="REAL"/>
					<var name="xOOS" type="BOOL">
						<initValue>FALSE</initValue>
					</var>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_AV_link_ui											*
*																					*
* PURPOSE		: Set the present value of an Analog Value UINT BACnet Object.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 1.1  	27-10-20 	Federico Marcassa	Fixed update of EE in case of OOR write		*
*										and usiMode=2								*
* 										Description Update							*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;	
 - bit 4: Priority Active (override from supervisor)							*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAV_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_VALUE AND rScaler<>0.0 AND NOT (ptrAV_BACnet=0) AND NOT (ptr_ui=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		uiEE_old:=@ptr_ui+1;
		rPV_old:=TO_REAL(uiEE) * rScaler;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;
	
// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrAV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrAV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrAV_BACnet.Description:=AV_Description;
		END_IF;
	END_IF;
		
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		AV_Description := @ptrAV_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrAV_BACnet.Description:='Disabled';
	END_IF;

	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------
	uiEE := @ptr_ui;
	rEE:= TO_REAL(uiEE) * rScaler;

	IF uiEE_old<>uiEE THEN
		@ptrAV_BACnet.Relinquish_Default:=rEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
			END_FOR;
		END_IF;
	END_IF;
	
	IF @ptrAV_BACnet.Relinquish_Default<>rEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;	
	
	IF xRelMod THEN
		uiRelinqScaled:=BACnet_r_ROUND_ui(@ptrAV_BACnet.Relinquish_Default/rScaler);
		IF @ptrAV_BACnet.Relinquish_Default>rRelMin AND @ptrAV_BACnet.Relinquish_Default<rRelMax THEN

			IF NOT(sysWriteParUINT(ptr_ui,uiRelinqScaled)) THEN
				@ptr_ui := uiRelinqScaled;
			END_IF;
			
		ELSE
			@ptrAV_BACnet.Relinquish_Default:=rEE;
		END_IF;
	END_IF;
		
	IF xLocalPV_Upd OR NOT(runCheck)	THEN	realRet := sysBACnet_AV_PresentValue(ptrAV_BACnet);	END_IF;	

	IF @ptrAV_BACnet.Out_Of_Service=TRUE THEN 
		rPV:=rEE;  // if OOS, I write what I would have passed from IEC side
		xOOS:=TRUE;
	ELSE
		rPV:= @ptrAV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	IF rPV_old<>rPV AND usiMode=2 AND NOT(xOOS) THEN
		uiPV_scaled:=BACnet_r_ROUND_ui(rPV/rScaler);
		uiPV_scaled:=LIMIT(uiPV_scaled,uiRelMin,uiRelMax); // Ver. 1.1
		
		IF NOT(sysWriteParUINT(ptr_ui,uiPV_scaled)) THEN
			@ptr_ui := uiPV_scaled;
		END_IF;		
		
		//uiEE_old:=uiEE; // Ver. 1.1
	END_IF;
	
	uiEE_old:=@ptr_ui;
	rPV_old:=rPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrAV_BACnet.Priority_Array[j_Act].choice_real<>BACnet_rNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	rRelMin:=TO_REAL(uiRelMin)*rScaler;
	rRelMax:=TO_REAL(uiRelMax)*rScaler;
	
	IF rPV<rRelMin THEN // I saturate rPV_scaled with Min and Max in the Out of Range case, PV side (PriorArr15 side)
		uiPV_scaled := uiRelMin;
		inside_limits_flag:=FALSE;
		IF writeRel_under THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNDER_RANGE;
			writeRel_under:=FALSE;
		END_IF;
	ELSIF rPV>rRelMax THEN
		uiPV_scaled := uiRelMax;
		inside_limits_flag:=FALSE;
		IF writeRel_over THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_OVER_RANGE;
			writeRel_over:=FALSE;
		END_IF;
	ELSE
		uiPV_scaled:=BACnet_r_ROUND_ui(rPV/rScaler);
		inside_limits_flag:=TRUE;
		writeRel_under:=TRUE;
		writeRel_over:=TRUE;
	END_IF;

	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits	
	IF (@ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNDER_RANGE OR @ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_OVER_RANGE) AND inside_limits_flag THEN
		@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;

	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	IF NOT(@ptr_ui=0) THEN
		uiPV_scaled:=@ptr_ui;
	ELSE
		uiPV_scaled:=uiRelMin;
	END_IF;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_AV_link_r" version="1.1.0" creationDate="0" lastModifiedDate="1603789382">
			<title>Link an Analog Value BACnet Object to a REAL local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link a REAL variable or EEPROM parameter to an Analog Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrAV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_r&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
See the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_AV_link_i&lt;/span&gt; FB. The implementation is analogous.

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the scaled output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in a background task, the global variable connected to the scaled output has to be initialized in an init task, by setting it equal to the local parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the scaled output.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range (OOR) writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; allow to limit the values the local parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;Local variable / EEprom parameter&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range (OOR) writes from the supervisor side.&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;With usiMode equal to 0 or 1, in case of an OOR write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;, this write will not be accepted and the local value will be restored on the BACnet side.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In case of an OOR write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Priority_Array / Relinquish&lt;/span&gt;, which will cause an OOR &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt;, the scaled output of the FB will be saturated with the &lt;u&gt;&lt;b&gt;scaled&lt;/u&gt;&lt;/b&gt; &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; (if lower than it) or the &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; (if higher than it) and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute of the BACnet Object will be set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNDER_RANGE&lt;/span&gt; in the former case and to &lt;span style='font-family: Courier New '&gt;RELIABILITY_OVER_RANGE&lt;/span&gt; in the latter one.&lt;br&gt;
  The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; gets back into the limits. &lt;br&gt;&lt;span style='font-family: Courier New '&gt;Local variable / EEprom parameter&lt;/span&gt; will be updated accordingly to the scaled limited output of the FB.
  &lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;Please note that &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; are both scaled by multiplying them by the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; before using them for the comparisons.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Versions:&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
Ver. 1.1:&lt;br&gt;
- Fixed update of Local Variable / EEprom in case of OOR write and usiMode=2&lt;br&gt;
- Updated description in case of OOR write from supervisor&lt;br&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrAV_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_r" type="@REAL">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0.0</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Local value lower limit. Scaled by rScaler.</descr>
						<initValue>-3.40E+38</initValue>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Local value higher limit. Scaled by rScaler.</descr>
						<initValue>3.40E+38</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="rPV_scaled" type="REAL">
						<descr>Scaled Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_rNULL" type="REAL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AV_Description" type="STRING" length="32">
						<descr>Analog Value Description</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRelinqScaled" type="REAL">
						<descr>Scaled REAL value present in the Relinquish Default</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_over" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="writeRel_under" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rEE" type="REAL">
						<descr>REAL Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="rRelMin_sc" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rRelMax_sc" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rPV" type="REAL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="rEE_old" type="REAL"/>
					<var name="rPV_old" type="REAL"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_AV_link_r											*
*																					*
* PURPOSE		: Set the present value of an Analog Value REAL BACnet Object.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 1.1  	27-10-20 	Federico Marcassa	Fixed update of EE in case of OOR write		*
*										and usiMode=2								*
* 										Description Update							*
************************************************************************************)

(* it initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;		
 - bit 4: Priority Active (override from supervisor)						*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAV_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_VALUE AND rScaler<>0.0 AND NOT (ptrAV_BACnet=0) AND NOT (ptr_r=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);

	IF NOT(runCheck) THEN
		rEE_old := @ptr_r+1;
		rPV_old := (@ptr_r) * rScaler;
		xPrArrClear_OD_old := xPrArrClear_OD;
	END_IF;
	
// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrAV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrAV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrAV_BACnet.Description:=AV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		AV_Description := @ptrAV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrAV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------

	rEE := (@ptr_r) * rScaler;
	
	IF rEE_old<>rEE THEN
		@ptrAV_BACnet.Relinquish_Default:=rEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
			END_FOR;
		END_IF;		
	END_IF;

	IF @ptrAV_BACnet.Relinquish_Default<>rEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;
	
	IF xRelMod THEN
		rRelinqScaled:=@ptrAV_BACnet.Relinquish_Default/rScaler;
		IF @ptrAV_BACnet.Relinquish_Default>rRelMin AND @ptrAV_BACnet.Relinquish_Default<rRelMax THEN
		
			IF NOT(sysWriteParREAL(ptr_r,rRelinqScaled)) THEN
				@ptr_r := rRelinqScaled;
			END_IF;
		
		ELSE
			@ptrAV_BACnet.Relinquish_Default:=rEE;
		END_IF;
	END_IF;
	
	IF xLocalPV_Upd OR NOT(runCheck)	THEN	realRet := sysBACnet_AV_PresentValue(ptrAV_BACnet);	END_IF;
	
	IF @ptrAV_BACnet.Out_Of_Service=TRUE THEN
		rPV:=rEE; // if OOS, I write what I would have passed from IEC side
		xOOS:=TRUE;
	ELSE
		rPV:= @ptrAV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;

	IF rPV_old<>rPV AND usiMode=2 AND NOT(xOOS) THEN
		rPV_scaled:=rPV/rScaler;
		rPV_scaled:=LIMIT(rPV_scaled,rRelMin,rRelMax); // Ver. 1.1
		IF NOT(sysWriteParREAL(ptr_r,rPV_scaled)) THEN
			@ptr_r := rPV_scaled;
		END_IF;
		
		//rEE_old:=rEE; // Ver. 1.1
	END_IF;

	rEE_old:=(@ptr_r) * rScaler;
	rPV_old:=rPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;
	
// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrAV_BACnet.Priority_Array[j_Act].choice_real<>BACnet_rNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	rRelMin_sc:=rRelMin*rScaler;
	rRelMax_sc:=rRelMax*rScaler;
	
	IF rPV<rRelMin_sc THEN // I saturate rPV_scaled with Min and Max in the Out of Range case, PV side (PriorArr15 side)
		rPV_scaled := rRelMin;
		inside_limits_flag:=FALSE;
		IF writeRel_under THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNDER_RANGE;
			writeRel_under:=FALSE;
		END_IF;
	ELSIF rPV>rRelMax_sc THEN
		rPV_scaled := rRelMax;
		inside_limits_flag:=FALSE;
		IF writeRel_over THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_OVER_RANGE;
			writeRel_over:=FALSE;
		END_IF;
	ELSE
		rPV_scaled:=rPV/rScaler;
		inside_limits_flag:=TRUE;
		writeRel_under:=TRUE;
		writeRel_over:=TRUE;
	END_IF;

	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits	
	IF (@ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNDER_RANGE OR @ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_OVER_RANGE) AND inside_limits_flag THEN
		@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------		
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	IF NOT(@ptr_r=0.0) THEN
		rPV_scaled:=@ptr_r;
	ELSE
		rPV_scaled:=rRelMin;
	END_IF;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_AV_link_i" version="1.1.0" creationDate="0" lastModifiedDate="1603789382">
			<title>Link an Analog Value BACnet Object to an INT local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link an INT variable or EEPROM parameter to an Analog Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrAV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_i&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;img src= bacnet_reldef_av_link_iee.png  width= 500 &gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the scaled output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in a background task, the global variable connected to the scaled output has to be initialized in an init task, by setting it equal to the local parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the scaled output.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range (OOR) writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; allow to limit the values the local parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;Local variable / EEprom parameter&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range (OOR) writes from the supervisor side.&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;With usiMode equal to 0 or 1, in case of an OOR write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;, this write will not be accepted and the local value will be restored on the BACnet side.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In case of an OOR write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Priority_Array / Relinquish&lt;/span&gt;, which will cause an OOR &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt;, the scaled output of the FB will be saturated with the &lt;u&gt;&lt;b&gt;scaled&lt;/u&gt;&lt;/b&gt; &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; (if lower than it) or the &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; (if higher than it) and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute of the BACnet Object will be set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNDER_RANGE&lt;/span&gt; in the former case and to &lt;span style='font-family: Courier New '&gt;RELIABILITY_OVER_RANGE&lt;/span&gt; in the latter one.&lt;br&gt;
  The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; gets back into the limits. &lt;br&gt;&lt;span style='font-family: Courier New '&gt;Local variable / EEprom parameter&lt;/span&gt; will be updated accordingly to the scaled limited output of the FB.
  &lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;Please note that &lt;span style='font-family: Courier New '&gt;RelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;RelMax&lt;/span&gt; are both scaled by multiplying them by the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; before using them for the comparisons.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Versions:&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
Ver. 1.1:&lt;br&gt;
- Fixed update of Local Variable / EEprom in case of OOR write and usiMode=2&lt;br&gt;
- Updated description in case of OOR write from supervisor&lt;br&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrAV_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_i" type="@INT">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iRelMin" type="INT">
						<descr>Local value lower limit. Scaled by rScaler.</descr>
						<initValue>-32768</initValue>
					</var>
					<var name="iRelMax" type="INT">
						<descr>Local value higher limit. Scaled by rScaler.</descr>
						<initValue>32767</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="iPV_scaled" type="INT">
						<descr>Scaled Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_rNULL" type="REAL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AV_Description" type="STRING" length="32">
						<descr>Analog Value Description</descr>
					</var>
					<var name="rEE" type="REAL">
						<descr>REAL value to be written in the Reliquish Default</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="iRelinqScaled" type="INT">
						<descr>Scaled INT value present in the Relinquish Default</descr>
					</var>
					<var name="rPV" type="REAL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_over" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="writeRel_under" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="j_overr" type="USINT"/>
					<var name="rPV_old" type="REAL"/>
					<var name="iEE_old" type="INT"/>
					<var name="iEE" type="INT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_ov_start" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_AV_link_i											*
*																					*
* PURPOSE		: Set the present value of an Analog Value INT BACnet Object.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	11-06-18 	Pierpaolo Armeli	First release 								*
* 1.1  	27-10-20 	Federico Marcassa	Fixed update of EE in case of OOR write		*
*										and usiMode=2								*
* 										Description Update							*
************************************************************************************)

(* it initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;		
 - bit 4: Priority Active (override from supervisor)						*)

IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAV_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_VALUE AND rScaler<>0.0 AND NOT (ptrAV_BACnet=0) AND NOT(ptr_i=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
		
	IF NOT(runCheck) THEN
		iEE_old:=@ptr_i+1;
		rPV_old:=TO_REAL(@ptr_i) * rScaler;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrAV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrAV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrAV_BACnet.Description:=AV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		AV_Description := @ptrAV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrAV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------

	iEE := @ptr_i;
	rEE := TO_REAL(iEE) * rScaler;
	
	IF iEE_old<>iEE THEN
		@ptrAV_BACnet.Relinquish_Default:=rEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
			END_FOR;
		END_IF;
	END_IF;
	
	IF @ptrAV_BACnet.Relinquish_Default<>rEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;
		
	IF xRelMod THEN
		iRelinqScaled:=BACnet_r_ROUND_i(@ptrAV_BACnet.Relinquish_Default/rScaler);
		IF @ptrAV_BACnet.Relinquish_Default>rRelMin AND @ptrAV_BACnet.Relinquish_Default<rRelMax THEN
			
			IF NOT(sysWriteParINT(ptr_i,iRelinqScaled)) THEN
				@ptr_i := iRelinqScaled;
			END_IF;
		
		ELSE
			@ptrAV_BACnet.Relinquish_Default:=rEE;
		END_IF;
	END_IF;
	
	IF xLocalPV_Upd OR NOT(runCheck)	THEN	realRet := sysBACnet_AV_PresentValue(ptrAV_BACnet);	END_IF;
		
	IF @ptrAV_BACnet.Out_Of_Service=TRUE THEN 
		rPV:=rEE;  // if OOS, I write what I would have passed from IEC side
		xOOS:=TRUE;
	ELSE
		rPV:= @ptrAV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	IF rPV_old<>rPV AND usiMode=2 AND NOT(xOOS) THEN
		iPV_scaled:=BACnet_r_ROUND_i(rPV/rScaler);
		iPV_scaled:=LIMIT(iPV_scaled,iRelMin,iRelMax); // Ver. 1.1
		IF NOT(sysWriteParINT(ptr_i,iPV_scaled)) THEN
			@ptr_i := iPV_scaled;
		END_IF;
		
		// iEE_old:=iEE; // Ver. 1.1
	END_IF;
	
	iEE_old:=@ptr_i;	
	rPV_old:=rPV;

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrAV_BACnet.Priority_Array[j_Act].choice_real<>BACnet_rNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------	
	rRelMin:=TO_REAL(iRelMin)*rScaler;
	rRelMax:=TO_REAL(iRelMax)*rScaler;
	
	IF rPV<rRelMin THEN // I saturate rPV_scaled with Min and Max in the Out of Range case, PV side (PriorArr15 side)
		iPV_scaled := iRelMin;
		inside_limits_flag:=FALSE;
		IF writeRel_under THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNDER_RANGE;
			writeRel_under:=FALSE;
		END_IF;
	ELSIF rPV>rRelMax THEN
		iPV_scaled := iRelMax;
		inside_limits_flag:=FALSE;
		IF writeRel_over THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_OVER_RANGE;
			writeRel_over:=FALSE;
		END_IF;
	ELSE
		iPV_scaled:=BACnet_r_ROUND_i(rPV/rScaler);
		inside_limits_flag:=TRUE;
		writeRel_under:=TRUE;
		writeRel_over:=TRUE;
	END_IF;

	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF (@ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNDER_RANGE OR @ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_OVER_RANGE) AND inside_limits_flag THEN
		@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;

// --------------------    wStatus Update    --------------------------------------------------------------------------
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	IF NOT(@ptr_i=0) THEN
		iPV_scaled:=@ptr_i;
	ELSE
		iPV_scaled:=iRelMin;
	END_IF;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_reldef_av_link_iee.png" width="614" height="214">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAmYAAADWCAYAAAB7eU7WAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACunSURBVHhe7Z09j9xKdobnFzh2qkw/
QImgwNliwgkUTjyBNln/g5l0E0GG4U0uoGCVCjdaAV5gkgsoupE3UOBrpwaMDfwTaJ764qkv
dnU32VNkPw/wYppkVZFdp1n1zmHP1M0AAAAAAF2AMQMAgDr//ufhH//hn4P+8O9uf5W/DX/4
p78O/y0v/+uvw+9U3X/8hz8O//ZfplAZKe/rFlFt10iuN5yzth+gMzBmAABQxhirPw9/dZt2
+whzlRotMUeHjNUcB43biJzj939zG4rafoDOwJgBAECZQ0ZIZ6GM6fnf4d/+yW1LvbS+2v7v
f/ljqPu7f/nf+Lj8/P2fhz/MtW1r5GDMYONgzAAAoMpff+/MkM6cCYnpknLmMafen5Qx5sgb
r9De30YD5rJwvnx23L1O2yuhzaI2cbX9AJ2BMQMAgAbEIImpcSYpNTqjTOZLmydjsHQZ9X0v
lb3KTF1kwCRTlhg3s79C0nagth+gMzBmAADQjDyCNAasZnRSY1YyUhgzgCoYMwAAKCNmJnqE
ab/nFUxU+EOAZP8hY2bqHniUiTGDKwVjBgAAVfSX9MPjSo8xbu5YMD3ukWdmsGJ0u8bQCYeM
mW7bHCugr0m3X9sP0BkYMwAAAIBOwJgBAMC2kIxakv2y8pk1gO2CMQMAAADoBIwZAAAAQCdg
zAAAAAA6AWMGAAAA0AkYMwAAAIBOwJgBAJzAzc0NQpsRbAeiBQBwBH6i+9e//CdCmxEGbTsQ
JQCARjBkaOvCnPUPEQIAaARjhrYujFn/ECEAgAYwZWgvwpz1DdEBAGgAY4b2IoxZ3xAdAIAG
VjFmP/08v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qd/vZvM6/e3ZI1pzlbY/S5zRSGUX04sKY9Q3RAQBo
IM+YIbRNYcz6hugAADRwdcZMsmdR1ovs116EMesbogMA0AAZM7QXYcz6hugAADSAMUN7Ecas
b4gOAEADGDO0F2HM+oboAAA0gDFDexHGrG+IDgBAAxgztBdhzPqG6AAANIAxQ3sRxqxviA4A
QCOYM7R1Ycr6hwgBADSCMUNbF8asf4gQAMARyMSGQUNbk//cQv8QJQCAE/ATHUJbEGwHogUA
AADQCRgzAAAAgE7AmAEAAAB0AsYMAAAAoAuG4f8BiMGjYj4rF6AAAAAASUVORK5CYII=]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_usi" version="1.0.1" creationDate="0" lastModifiedDate="0">
			<title>Link a Multi State Value BACnet Object to an USINT local variable or EEPROM parameter</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;&lt;p&gt;
This function block allows to link an USINT variable or EEPROM parameter to a Multi State Value BACnet Object.&lt;br&gt;
The link is achieved by writing on the Relinquish Default and eventually, depending on the Mode, by clearing the Priority Array.&lt;br&gt;
The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the local parameter &lt;span style='font-family: Courier New '&gt;ptr_usi&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;img src= bacnet_reldef_mv_link_usiee.png  width= 500 &gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the local parameter is linked to the RelDef and they get updated both ways;&lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the  local parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2 (default)&lt;/b&gt;: a change in PV updates the local parameter; a change in the local parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null);
&lt;p&gt;&lt;b&gt;&lt;span style='color:green;'&gt;Mode 2 allows to keep the existing parameters (no renaming required, no new parameters required) and to keep the existing HMI.&lt;/b&gt;&lt;/span&gt;&lt;br&gt;
Remember that, in case an EEPROM parameter is linked, only 100.000 value changes are guaranteed on each EEPROM location.

&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider that the Mode has an impact on the prioritization between the BACnet supervisor and the PLC.&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, the scaled output can be skipped.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the PV output has to be used in the IEC code.&lt;br&gt;In this two modes, if the link FB is called in the Background task, the global variable connected to the PV output has to be initialized in the Init task, by setting it equal to the local parameter. If the link FB is called in the Timed Task instead, this initialization is not required, but it is important to run the program that uses it before the other timed programs that use the PV output.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_usi" type="@USINT">
						<descr>Local Variable / EEPROM Parameter Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>Offset summed to the local parameter.</descr>
						<initValue>0</initValue>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value used if out of range. The range is 1 ... Number_Of_States.</descr>
						<initValue>1</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Working Mode. Default: 2. See description for details.</descr>
						<initValue>2</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand, on transition FALSE -&gt; TRUE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="usiPV_current" type="USINT">
						<descr>Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Priority Array Active: supervisor override.</descr>
					</var>
					<var name="usiPV_offset" type="USINT">
						<descr>Present Value w/ Offset</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="usiEE_old" type="USINT">
						<descr>Last value of the usiRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiRelinq_current_minus_Offset" type="USINT">
						<descr>Scaled USINT value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="usiEE" type="USINT">
						<descr>USINT Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="udiPV_old" type="UDINT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="diEE" type="DINT"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="usi_to_write" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_usi											*
*																					*
* PURPOSE		: Link a Multi State Value BACnet Object to an USINT variable.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	22-05-18 	Pierpaolo Armeli	First release 								*
* 2  	11-06-18 	Pierpaolo Armeli	Added xEE input (default TRUE)				*
* 2		16-07-18	Pierpaolo Armeli	Added usiPV_offset output					*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;
 - bit 4: Priority Active (override from supervisor)						*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_usi=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		usiEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;
	
// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;	
			
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	usiEE := @ptr_usi;
	diEE := TO_DINT(usiEE) + TO_DINT(iOffset);

	// -------    diEE consistency check    ---------
	udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------	
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF usiEE_old<>usiEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;
	
	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			usiRelinq_current_minus_Offset:=TO_USINT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			IF NOT(sysWriteParUSINT(ptr_usi,usiRelinq_current_minus_Offset)) THEN
				@ptr_usi := usiRelinq_current_minus_Offset;
			END_IF;
		ELSE
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;

	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			usi_to_write:=TO_USINT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			
			IF NOT(sysWriteParUSINT(ptr_usi,usi_to_write)) THEN
				@ptr_usi := usi_to_write;
			END_IF;
			
			usiEE_old:=usiEE;
		END_IF;
	END_IF;

	usiEE_old:=@ptr_usi;
	udiPV_old:=udiPV;	

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
	
		IF j_Act=0 THEN
			xPriorityActive:=xActiveOne;
			xActiveOne:=FALSE;
		END_IF;
		
		IF @ptrMV_BACnet.Priority_Array[j_Act].choice_integer<>BACnet_udiNULL THEN
			xActiveOne:=TRUE;
		END_IF;
					
		j_Act:=(j_Act+1) MOD n_count_PrAct;
	
	ELSE
		xPriorityActive:=FALSE;
	END_IF;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	IF NOT(inside_limits_flag) THEN
		usiPV_current := TO_USINT(iWrongLinkValue);
		usiPV_offset := TO_USINT(iWrongLinkValue)-TO_USINT(iOffset);
	ELSE
		usiPV_current := TO_USINT(udiPV);
		usiPV_offset := TO_USINT(udiPV)-TO_USINT(iOffset);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;

// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
 	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	usiPV_current:=@ptr_usi;
	usiPV_offset := @ptr_usi-TO_USINT(iOffset);
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_reldef_mv_link_usiee.png" width="681" height="196">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAqkAAADECAYAAAC807hqAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAEtXSURBVHhe7b3/UxTpnuf79sb+jDqD
esFutI7NdCE4nDMSvaEEtMPVM9Cs9pdljdHgnN6Jbe3WtkP64BD7w8ZF9m7cuOHqaQ1t7VYn
5jpDNBsuY9t4aWqOLqMYpbEdOGeYRqk+6kFRYUV2Vf6Bvs/nySezsr5kUUAVVBXvV8RD5fPk
k8+3TDLf+Xk+mbnoRwUIIYQQQgjJIP4380sIIYQQQkjGQJFKCCEktfymHQWLf+WET39j0ueL
+5fxZ1Ht+P3x/6za1o7LJj414zi1aY76Iu3ddBm/jxrHgsX/Gafuq/Ve6YTkGBSphBBCUocI
rH8D/M3LX2NMwj/W4c6/yQAR9bMC3On63kTG8fd/B/zxz0w001izBX9/dQt+Isu/+AtrHHX4
S+xZo3N4pxOSQ1CkEkIISS0/WwFHM4ngcosotxVwny0abctmdLplvbTT/+z4uEmPzO+ki0De
145PTbq7fOCneOf1/4Hf6+Wn+F2Ziutli7jlKZz0Tb/B70yaxqMfcbEtozoifbJFu0f/IvIT
snChSCWEEJI6lCg9UNaDSi28oqbTRXz93ysQNBbAv8FfW9PnKn3P3/3UpP8F/vxvB6ztfvMb
/Mcy22L4F1j7H35jpUv+/1BgrLWSfi5sqf1b4K3ocgyvKXH693q6fAB3Xv/frUTBqzx3+l+t
wJ3fWtk9+zFdvPrn5m//OiyG3cLVK52QHIIilRBCSErZcsISb2Mvy/GtW6zef4p//q0tYH+F
XypBeeeHccva+lfAHp3+1/gvGMM9EYlrVuCPbTG2D/jsZSO22OX8otxaxjq89Ysx/M4WqY4V
dwX+6GemHMOa16Hz/f4H4J23VphUhUd5v//2n4D/9HMrXcT3L3QG735MF6/+uXFP69suAIJX
OiE5BEUqIYS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NdihSSbJQpBKSg1Ckzj3p9kGlJZXkChSpJFkoUgnJQUTQkLkl3adS
ilSSK1CkkmTh0/2E5CByAWCY20AIISS1UKQSQgghhJCMgyKVEEIIIYRkHBSphBBCCCEk46BI
JYSQLED8XuWBE0KyGT40RaYDRSohhBBCCMk4+AoqQgjJIuzXi/F1VCSbsGcBKDnIdKBIJYSQ
LITvwiXZBKUGmQkUqYQQQgghJOOgTyohhBBCCMk4KFIJIYQQQkiGAfz/DVIRWcA+7PMAAAAA
SUVORK5CYII=]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_PVUpdPr" version="1.0.1" creationDate="0" lastModifiedDate="0">
			<title>Update the present value of all the BACnet Objects</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;P&gt;This function block updates the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; (PV) of all the supported BACnet Object Types: Analog Value (AV), Binary Value (BV), Multi State Value (MV), Calendar (Ca).&lt;/p&gt;
&lt;p&gt;The update timeframe is defined by &lt;span style='font-family: Courier New '&gt;uiPrd&lt;/span&gt; (in tenths of seconds).&lt;/p&gt;
&lt;p&gt;It can be chosen if the Object Types have to be updated synchronously (all at the same time) or asynchronously (alternatively, one per cycle), using the BOOL &lt;span style='font-family: Courier New '&gt;xSync&lt;/span&gt; input:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If synchronously, all the Object Types will be updated at each &lt;span style='font-family: Courier New '&gt;uiPrd&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;If asynchronously, at each &lt;span style='font-family: Courier New '&gt;uiPrd&lt;/span&gt; defined timeframe, only one Object Type will be updated, in a rotation sequence; therefore, the Object Types will be all updated in a timeframe equal to four times the &lt;span style='font-family: Courier New '&gt;uiPrd&lt;/span&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can decide to force the update of a specific Object Type at each &lt;span style='font-family: Courier New '&gt;uiPrd&lt;/span&gt;, overriding the asynchronous setting for that Object Type only, by setting the related &lt;span style='font-family: Courier New '&gt;xForce∙∙∙&lt;/span&gt; input to TRUE.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr FB&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In this case, no update of any Object Type is forced at each run and the update is asynchronous: at each run, which is executed every 1 second (default uiPrd), only one Object Type is updated, in sequence.&lt;/p&gt;

&lt;img src= bacnet_pvupdpr.png  width= 300 &gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Context of use&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;It is strongly suggested to use this function block in every project where the BACnet protocol is implemented, because otherwise the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; will not be updated, unless this functionality is implemented in another part of the code.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update Status&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The ouput variable &lt;span style='font-family: Courier New '&gt;wBACnetObjUpdStat&lt;/span&gt; is a WORD, which should be read as described below:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the bits 0-3 contain the info about the last execution;&lt;/li&gt;
&lt;li&gt;the bits 8-11 contain the info about the first run of the update.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The four bits of each category (0-3 and 8-11) are correlated to the Object Types as follows (the numbers refer to the bit number):&lt;/p&gt;
&lt;ol type= 1  start= 0 &gt;
&lt;li&gt;Analog Value;&lt;/li&gt;
&lt;li&gt;Binary Value;&lt;/li&gt;
&lt;li&gt;Multi State Value;&lt;/li&gt;
&lt;li&gt;Calendar.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="uiPrd" type="UINT">
						<descr>Present Value update period in [sec/10]. Default 1 sec.</descr>
						<initValue>10</initValue>
					</var>
					<var name="xSync" type="BOOL">
						<descr>Synchronous PV update or asynchronous (only one type per execution). Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xForceAVUpd" type="BOOL">
						<descr>Force the Analog Value Objects present value update at every run, if TRUE.</descr>
					</var>
					<var name="xForceBVUpd" type="BOOL">
						<descr>Force the Binary Value Objects present value update at every run, if TRUE.</descr>
					</var>
					<var name="xForceMVUpd" type="BOOL">
						<descr>Force the Multi State Value Objects present value update at every run, if TRUE.</descr>
					</var>
					<var name="xForceCaUpd" type="BOOL">
						<descr>Force the Calendar Objects present value update at every run, if TRUE.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="wBACnetObjUpdStat" type="WORD">
						<descr>Status of the BACnet Objects Present Value update. See description for details.</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="sysTimer" type="UDINT">
						<descr>System timer [ms]</descr>
					</var>
				</externalVars>
				<localVars>
					<var name="lastexeTime" type="UDINT">
						<descr>Time of the last executed instance</descr>
					</var>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the FB has been run at least one time</descr>
					</var>
					<var name="curDeltat" type="UDINT">
						<descr>Delta time between current time and last execution time</descr>
					</var>
					<var name="bObjUpd" type="BOOL" dim0="4">
						<descr>Flags vector of the 4 BACnet Object Types</descr>
					</var>
					<var name="index" type="USINT">
						<descr>Index to keep track of the last changed flag in async loop</descr>
					</var>
					<var name="j" type="USINT">
						<descr>Index used to reset flags to FALSE at cycle start</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Return for Analog Value PV function</descr>
					</var>
					<var name="BinaryPVRet" type="DINT">
						<descr>Return for Binary Value PV function</descr>
					</var>
					<var name="udRet" type="UDINT">
						<descr>Return for Multi State Value PV function</descr>
					</var>
					<var name="bRet" type="BOOL">
						<descr>Return for Calendar PV function</descr>
					</var>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_PVUpdPr													*
*																					*
* PURPOSE		: Update the present value of all the BACnet Objects				*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 												 									*
*************************************************************************************)

FOR j:=0 TO 3 BY 1 DO // sets the flags vector to false
	bObjUpd[j]:=FALSE;
END_FOR;

curDeltat:=sysTimer-lastexeTime;

(* Updates the PV only if the defined Update Time is not null and
if the requested Delta Time has been reached. It runs the update of
all the types of objects at the first run. *)

IF (uiPrd>0 AND curDeltat>=uiPrd*UINT#100) OR NOT(runCheck) THEN
	IF xSync OR NOT(runCheck) THEN
		// syncronous update: all Object Types are updated together
		FOR index:=0 TO 3 BY 1 DO
			bObjUpd[index]:=TRUE;
		END_FOR;
	ELSE
		// asyncronous: one Object Type update per run
		index:=(index+1) MOD 4;
		bObjUpd[index]:=TRUE;
	END_IF;
	lastexeTime:=sysTimer;
END_IF;

// forces the update if the related input has been set to do so
bObjUpd[0]:=bObjUpd[0] OR xForceAVUpd;
bObjUpd[1]:=bObjUpd[1] OR xForceBVUpd;
bObjUpd[2]:=bObjUpd[2] OR xForceMVUpd;
bObjUpd[3]:=bObjUpd[3] OR xForceCaUpd;

(* initializes the output variable
The output variable is made of 16 bits:
 - the bits 0-3 contain the info about the last execution
 - the bits 8-11 contain the info about the first run of the update
  Correlation to the Object Types is: 0 An.Val, 1: Bin.Val, 2: Multi State Var, 3: Calendar  *)
IF NOT(runCheck) THEN
	wBACnetObjUpdStat:=UINT#2#0;
END_IF;

// Usese the above defined and set flags to execute the sysBACnet_**_PresentValue() command

IF bObjUpd[0] THEN
	(* Update Bacnet Analog Value Objects *)
	realRet := sysBACnet_AV_PresentValue(0);
	wBACnetObjUpdStat:=wBACnetObjUpdStat OR UINT#2#100000001;
ELSE
	wBACnetObjUpdStat:=wBACnetObjUpdStat AND NOT(UINT#2#1);
END_IF;

IF bObjUpd[1] THEN
	(* Update Bacnet Binary Value Objects *)
	BinaryPVRet := sysBACnet_BV_PresentValue(0);
	wBACnetObjUpdStat:=wBACnetObjUpdStat OR UINT#2#1000000010;
ELSE
	wBACnetObjUpdStat:=wBACnetObjUpdStat AND NOT(UINT#2#10);
END_IF;

IF bObjUpd[2] THEN
	(* Update Bacnet Multi State Value Objects *)
	udRet := sysBACnet_MV_PresentValue(0);
	wBACnetObjUpdStat:=wBACnetObjUpdStat OR UINT#2#10000000100;
ELSE
	wBACnetObjUpdStat:=wBACnetObjUpdStat AND NOT(UINT#2#100);
END_IF;

IF bObjUpd[3] THEN
	(* Update Bacnet Calendar Objects *)
	bRet := sysBACnet_Ca_PresentValue(0);
	wBACnetObjUpdStat:=wBACnetObjUpdStat OR UINT#2#100000001000;
ELSE
	wBACnetObjUpdStat:=wBACnetObjUpdStat AND NOT(UINT#2#1000);
END_IF;

runCheck:=TRUE;

]]>
			</sourceCode>
			<images>
				<image name="bacnet_pvupdpr.png" width="315" height="162">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAATsAAACiCAYAAAA+wmr4AAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAABebSURBVHhe7Z2PTx1luse/vX8ALUkv
LlQo2MTLVrpY25h0CU3TbC1I/NFd9kaMbmOszbXbZlfLNcYYoWZjzG69eoO33WCNqTZidnHr
jyAom8bQnG1iWl0UK9dcpVDL2W2atPIPeN/nfd+Z885wBubAHArM95MMZ37Pezhnvud53pn5
Pit+UIAQQpY5/2JfCSFkWUOxI4SkAoodSY5vBrFz5eMod4bHPrLLHAb3P46dXZftlMtlHN02
87bx+AKPbRvEt3YqL9Pa+gcc/cYcP1/bvu36A8pln7Kdu+/w9KyYY+j3lrcNZi2SPBQ7kiwb
m5H5/r+Q1cNDwC9DJ7A6wQ+jGfe+/REG7SyDiMDzeOcXT0ZvG5dv/oHzdnRG3Lb+uRzPPjyM
nU/dhs/fHg6J12V8+HYW9z21AzfZOYkxrQ2FCCcpBIodKS4bb8XOdXZcMfhiP9bfvQM7f5HF
B27k9s0w3lEiePRAmZ2xAQc+bcJOGZUIaP8JPOZFQPu/0GtoPjqRi4z0fCWaD/fj88/60VBI
xLXuBvxEXu+4A8/g7/gwINCmbQfusNNR6ChPtdOLTp126shQ5m37CF/bedPw2hDYz4nQjwKZ
KxQ7kiwiMp74rHwNb9X9yImGvsAHb9yGO5Vo3HTnrTj/nJsO/hOfB9ZV66zboAY78Q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<functionBlock name="BACnet_MSI_usiSetPV" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<title>Set the Present Value of a BACnet Multi State Input Object (USINT input)</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block sets the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of a Multi State Input BACnet Object.&lt;/p&gt;
It takes as input &lt;span style='font-family: Courier New '&gt;usiValue&lt;/span&gt;, which is the value that, scaled by the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;, has to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of the BACnet Object. The input is an USINT value.&lt;br&gt;
&lt;b&gt;Check the range limitations given by this setting before using this variant of the MSI SetPV FBs Family.&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;It returns the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; as output.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Context of use&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The wording &lt;i&gt;Input&lt;/i&gt; in the name of this object underlines that this object accepts only inputs from the IEC and cannot write on the IEC environment; therefore, it is a BACnet object which can only read.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_MSI_usiSetPV&lt;/span&gt; FB. The purpose is to write the USINT value of the &lt;span style='font-family: Courier New '&gt;usiOperating_State&lt;/span&gt; status variable into the BACnet Object &lt;span style='font-family: Courier New '&gt;MSI_OperatingState&lt;/span&gt;, which is an &lt;span style='font-family: Courier New '&gt;Enumerative&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In this way, it is possible to read the &lt;span style='font-family: Courier New '&gt;usiOperating_State&lt;/span&gt; of the machine from a supervisor, by reading the PV of the &lt;span style='font-family: Courier New '&gt;MSI_OperatingState&lt;/span&gt;.&lt;/p&gt;
&lt;img src= bacnet_msi_usisetpv.png  width= 500&gt;


&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMSI_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="usiValue" type="USINT">
						<descr>USINT Value to be written in PV, scaled by summing the iOffset to it. Its value must be such that the sum diValue + iOffset is in the range 1… Number_Of_States.</descr>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT offset that is summed to the input value.</descr>
					</var>
					<var name="iWrongInputValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value of the MSI BACnet Object.</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 3: BACnet not aligned with input value.</descr>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MI_Description" type="STRING" length="32">
						<descr>Analog Input Description</descr>
					</var>
					<var name="udiMin" type="UDINT">
						<descr>Lower limit for Present Value in UDINT.</descr>
					</var>
					<var name="udiMax" type="UDINT">
						<descr>Higher limit for Present Value in UDINT.</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
					</var>
					<var name="udi_to_write" type="UDINT">
						<descr>UDINT value to be written in the Present Value</descr>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_MSI_usiSetPV												*
*																					*
* PURPOSE		: Set the Present Value of a BACnet Multi State Input Object		*
*				  (USINT input).													*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMSI_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_INPUT AND NOT (ptrMSI_BACnet=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMSI_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	END_IF;
	
	IF NOT(xEn_old) AND xEn THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMSI_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMSI_BACnet.Description:=MI_Description;
		END_IF;
	END_IF;
	
	IF NOT(@ptrMSI_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
		
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MI_Description := @ptrMSI_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMSI_BACnet.Description:='Disabled';
	END_IF;

	xEn_old:=xEn;

	udiMin:=1;
	udiMax:=@ptrMSI_BACnet.Number_Of_States;

	udi_to_write := TO_UDINT(usiValue)+TO_UDINT(iOffset);

	IF (udi_to_write<udiMin OR udi_to_write>udiMax) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMSI_BACnet.Present_Value:=TO_UDINT(iWrongInputValue);
		IF writeRel_OutOfRange THEN
			@ptrMSI_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		@ptrMSI_BACnet.Present_Value := udi_to_write;
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xLocalPV_Upd THEN
		udintRet := sysBACnet_MV_PresentValue(ptrMSI_BACnet);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMSI_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMSI_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
					
	udiPV:= @ptrMSI_BACnet.Present_Value;
	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	udiPV := BACnet_udiNULL;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_msi_usisetpv.png" width="702" height="172">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAr4AAACsCAYAAACdBq/MAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACioSURBVHhe7Z09jtw417Z7K85mAU4G
3kCHDhx23IFX4V7BwMALTDJAJ06Nib7JnDyAo8kn+CZ/kncR9fLwT4cUKbFKP82Srgu40SWJ
PKTY1NFdtNp6uAAAAAAAnACMLwAAAACcAowvAAAAAJwCjC8AAAAAnIIm4/vwsI4/Js40xJmG
ONMQZxriTEOcaYgzDXGmIc40e8ZZpyUAAAAAgM7B+AIAAADAKcD4AgAAAMApwPgCAAAAwCnA
+AIAwAT/Xn779cH+0YjV819+/5b8dXn+9TfTsuHf3y6/hs/X8tfz0G+joesqfpWWMhWkz6rd
tO2Bv54fLr/+VmohHfPbh3zBOQAcFIwvAABUcAZMmzMxa5ub3yVmN2DN57Oxfh67/evFnkpL
/CV9GNU1BjS0HZAyz7+Z8VV9tORjXqjbypJzADgoGF8AAChTNE5ixLxZs8efL89hdVIbYr3a
GvYn5V2Mf3/7NSunVjul7dAH+fls6uYxhdjW8+U3E8+FKfVdyOLLnrk+SLXS+dQYtT1eeZUv
EBJG2k7CFfr9779/GcmHljEI+wvnAAAYXwAAqCBmamTyxFCpldO4GumMlvNcqXkLJi8t77dj
udxQ+/3hs60bVkdVWfs5xJTPw6MBdnXamsFQ1lOKbw/M9EE+G+L51LB9DW17JRUq7QjFMffY
uIUxqPUvjw0AGF8AAKjQYnyVsZLVS/tP9Hr10cvuLxkxa+ZCuULc8DmpW+9D2ZQ6QxwNcFZn
tg+186mRx7ftB3Muh/04eZI+zxnf0hhcM94AJwfjCwAAZYrGqb7SmBjfknnL41nDplcwtzK+
jtg/XaelD1NmtETWJ2HoVzDhmUL5Qt1Iciwzvi3jDQAYXwAAqCHmauKP28R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OgUjC86ijC+0AvMRACATsH4oqMI4wu9wEwEAOgYzC+6d2F6oSeYjQAAHYPxRfcu
jC/0BLMRAKBzxDhggNG9KcxbgJ5gRgIA3AnBSCB0DwLoEWYmAAAAAJwCjC8AAAAAnIIm47vW
P1kQZxriTEOcaYgzDXGmIc40xJmGONMQZ5o946zTEgAAAABA52B8AQAAAOAUYHwBAAAA4BRg
fAEAAADgFGB8AQAAAOAEXC7/B+3aiYisidjdAAAAAElFTkSuQmCC]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_MSI_udiSetPV" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<title>Set the Present Value of a BACnet Multi State Input Object (UDINT input)</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block sets the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of a Multi State Input BACnet Object.&lt;/p&gt;
It takes as input &lt;span style='font-family: Courier New '&gt;udiValue&lt;/span&gt;, which is the value that, scaled by the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;, has to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of the BACnet Object. The input is an UDINT value.&lt;br&gt;
&lt;b&gt;Check the range limitations given by this setting before using this variant of the MSI SetPV FBs Family.&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;It returns the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; as output.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Context of use&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The wording &lt;i&gt;Input&lt;/i&gt; in the name of this object underlines that this object accepts only inputs from the IEC and cannot write on the IEC environment; therefore, it is a BACnet object which can only read.&lt;/p&gt;



&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_MSI_udiSetPV&lt;/span&gt; FB. The purpose is to write the UDINT value of the &lt;span style='font-family: Courier New '&gt;udiOperating_State&lt;/span&gt; status variable into the BACnet Object &lt;span style='font-family: Courier New '&gt;MSI_OperatingState&lt;/span&gt;, which is an &lt;span style='font-family: Courier New '&gt;Enumerative&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In this way, it is possible to read the &lt;span style='font-family: Courier New '&gt;udiOperating_State&lt;/span&gt; of the machine from a supervisor, by reading the PV of the &lt;span style='font-family: Courier New '&gt;MSI_OperatingState&lt;/span&gt;.&lt;/p&gt;
&lt;img src= bacnet_msi_udisetpv.png  width= 500&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMSI_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
					</var>
					<var name="udiValue" type="UDINT">
						<descr>UDINT Value to be written in PV, scaled by summing the iOffset to it. Its value must be such that the sum udiValue + iOffset is in the range 1… Number_Of_States.</descr>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT offset that is summed to the input value.</descr>
					</var>
					<var name="iWrongInputValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value of the MSI BACnet Object.</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 3: BACnet not aligned with input value.</descr>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MI_Description" type="STRING" length="32">
						<descr>Analog Input Description</descr>
					</var>
					<var name="udiMin" type="UDINT">
						<descr>Lower limit for Present Value in UDINT.</descr>
					</var>
					<var name="udiMax" type="UDINT">
						<descr>Higher limit for Present Value in UDINT.</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
					</var>
					<var name="di_to_write" type="DINT">
						<descr>DINT value to be written in the Present Value</descr>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_MSI_udiSetPV												*
*																					*
* PURPOSE		: Set the Present Value of a BACnet Multi State Input Object		*
*				  (UDINT input).													*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMSI_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_INPUT AND NOT (ptrMSI_BACnet=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMSI_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	END_IF;
	
	IF NOT(xEn_old) AND xEn THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMSI_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMSI_BACnet.Description:=MI_Description;
		END_IF;
	END_IF;
	
	IF NOT(@ptrMSI_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;	
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MI_Description := @ptrMSI_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMSI_BACnet.Description:='Disabled';
	END_IF;

	xEn_old:=xEn;

	udiMin:=1;
	udiMax:=@ptrMSI_BACnet.Number_Of_States;

	di_to_write := TO_DINT(udiValue)+TO_DINT(iOffset);

	IF (di_to_write<TO_DINT(udiMin) OR di_to_write>TO_DINT(udiMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMSI_BACnet.Present_Value:=TO_UDINT(iWrongInputValue);
		IF writeRel_OutOfRange THEN
			@ptrMSI_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		@ptrMSI_BACnet.Present_Value := TO_UDINT(di_to_write);
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xLocalPV_Upd THEN
		udintRet := sysBACnet_MV_PresentValue(ptrMSI_BACnet);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMSI_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMSI_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
					
	udiPV:= @ptrMSI_BACnet.Present_Value;
	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	udiPV := BACnet_udiNULL;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_msi_udisetpv.png" width="695" height="173">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAArcAAACtCAYAAACqT1ejAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACjPSURBVHhe7Z09buQ417a9lc5mAU4G
3oBDBx06duBVdK1g0MALTNKAk04bE32TOXmAjibv4Jv8Sd5F1MvDPx1SpES59Feq6wJuuCSR
hxSLOrqLLlt3ZwAAAACAg4C5BQAAAIDDgLkFAAAAgMOAuQUAAACAw4C5BQAAAIDDUDS3d3fz
eF7iDEOcYYgzDHGGIc4wxBmGOMMQZxjiDLN0nHmiAwAAAADsAMwtAAAAABwGzC0AAAAAHAbM
LQAAAAAcBswtAMBN8u/5j9/v7B9kWL387fcvyd/nl9//MC0b/v3j/Ht4PZW/X7p+G3VdV/Gr
tJSpIH1W7aZtd/z9cnf+/Y9SC+mYf3zIW85hi/cXYB9gbgEAbg5nfLQBE0O2uAG6xNAGrMF8
MfbOY7d/P9tTaYl/SR96dY3JDG0HpMzLH2Z8VR8t+ZgX6rbScA7//vG7ej9d2/hbuBUwtwAA
t0bRHInZ8obMHn85v4SVP+2K9Kpp2J+UdzGsuUrKqZVEaTv0QX6+mLp5TCG29XL+w8RzYUp9
F7L4smesD1KtdD41em33V1DlQ4KEkbaTcIV+//vv30byomU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01t1K+tNIb
ytfqeYX4+SpuVXk8vZ0dw9xet+YyLwAfgdkHALAT+uZW/Xpe/xFXzXTK/pJZTV4bhVjaDFuj
O83cunLyPVgVe1BpPxJTbPsejlW+lmDrY26vQZhb2BJmHwDATsjNrf06QrYSa7et4QtfFfDy
5axh9PsSE5jUSc2iq29MaqhjTWuDuS19ZWJM1kT7NnU929bIH5QZ8/spmN5QD+1SmFvYEmYf
AMBO6K/c3pBGjTS6JmFuYUuYfQAAO+EQ5jZZIdYa+eoC5vZQwtzCljD7AAB2wk2v3KJDCXML
W8LsAwDYCZhbdBRhbmFLmH0AADsBc4uOIswtbAmzDwBgJ2Bu0VGEuYUtYfYBAOwEzC06ijC3
sCXMPgCAnYC5RUcR5ha2hNkHALAjMLjo2oWxha1hBgIA7AjMLbp2YW5ha5iBAAA7Q8wBJhdd
m8K8BdgaZiEAwE4JZgGhaxDAXmA2AgAAAMBhwNwCAAAAwGEomtu5fr1AnGGIMwxxhiHOMMQZ
hjjDEGcY4gxDnGGWjjNPdAAAAACAHYC5BQAAAIDDgLkFAAAAgMOAuQUAAACAw4C5BQAAAICD
cD7/H+QeS/d4Nkf6AAAAAElFTkSuQmCC]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_MSI_diSetPV" version="1.0.0" creationDate="0" lastModifiedDate="0">
			<title>Set the Present Value of a BACnet Multi State Input Object (DINT input)</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block sets the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of a Multi State Input BACnet Object.&lt;/p&gt;
It takes as input &lt;span style='font-family: Courier New '&gt;diValue&lt;/span&gt;, which is the value that, scaled by the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;, has to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of the BACnet Object. The input is a DINT value.&lt;br&gt;
&lt;b&gt;Check the range limitations given by this setting before using this variant of the MSI SetPV FBs Family.&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;It returns the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; as output.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Context of use&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The wording &lt;i&gt;Input&lt;/i&gt; in the name of this object underlines that this object accepts only inputs from the IEC and cannot write on the IEC environment; therefore, it is a BACnet object which can only read.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_MSI_diSetPV&lt;/span&gt; FB. The purpose is to write the DINT value of the &lt;span style='font-family: Courier New '&gt;diOperating_State&lt;/span&gt; status variable into the BACnet Object &lt;span style='font-family: Courier New '&gt;MSI_OperatingState&lt;/span&gt;, which is an &lt;span style='font-family: Courier New '&gt;Enumerative&lt;/span&gt;.
&lt;p&gt;In this way, it is possible to read the &lt;span style='font-family: Courier New '&gt;diOperating_State&lt;/span&gt; of the machine from a supervisor, by reading the PV of the &lt;span style='font-family: Courier New '&gt;MSI_OperatingState&lt;/span&gt;.&lt;/p&gt;
&lt;img src= bacnet_msi_disetpv.png  width= 500&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrMSI_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
					</var>
					<var name="diValue" type="DINT">
						<descr>DINT Value to be written in PV, scaled by summing the iOffset to it. Its value must be such that the sum diValue + iOffset is in the range 1… Number_Of_States.</descr>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT offset that is summed to the input value.</descr>
					</var>
					<var name="iWrongInputValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
						<initValue>1</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value of the MSI BACnet Object.</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 3: BACnet not aligned with input value.</descr>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MI_Description" type="STRING" length="32">
						<descr>Analog Input Description</descr>
					</var>
					<var name="udiMin" type="UDINT">
						<descr>Lower limit for Present Value in UDINT.</descr>
					</var>
					<var name="udiMax" type="UDINT">
						<descr>Higher limit for Present Value in UDINT.</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
					</var>
					<var name="di_to_write" type="DINT">
						<descr>DINT value to be written in the Present Value</descr>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_MSI_diSetPV												*
*																					*
* PURPOSE		: Set the Present Value of a BACnet Multi State Input Object		*
*				  (DINT input).														*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMSI_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_INPUT AND NOT (ptrMSI_BACnet=0) AND NOT (iWrongInputValue<1) AND NOT (iWrongInputValue>5) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMSI_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	END_IF;
	
	IF NOT(xEn_old) AND xEn THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMSI_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMSI_BACnet.Description:=MI_Description;
		END_IF;
	END_IF;
	
	IF NOT(@ptrMSI_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
		
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MI_Description := @ptrMSI_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMSI_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
	udiMin:=1;
	udiMax:=@ptrMSI_BACnet.Number_Of_States;
	
	di_to_write := diValue + TO_DINT(iOffset);
	
	IF (di_to_write<TO_DINT(udiMin) OR di_to_write>TO_DINT(udiMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	
	IF iWrongInputValue>TO_INT(udiMax) AND NOT(runCheck) THEN
		iWrongInputValue:=TO_INT(udiMax);
	END_IF;
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMSI_BACnet.Present_Value:=TO_UDINT(iWrongInputValue);
		IF writeRel_OutOfRange THEN
			@ptrMSI_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		@ptrMSI_BACnet.Present_Value := TO_UDINT(di_to_write);
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xLocalPV_Upd THEN
		udintRet := sysBACnet_MV_PresentValue(ptrMSI_BACnet);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMSI_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMSI_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
					
	udiPV:= @ptrMSI_BACnet.Present_Value;
	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	udiPV := BACnet_udiNULL;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_msi_disetpv.png" width="697" height="168">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAArkAAACoCAYAAADkS/ajAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAChxSURBVHhe7Z09buQ417a9lc5mAU4G
vQGHDjp07KBX0bWCQQMvMEkDTjptTPRN5uQBOpq8g2/yJ3kXoZeHfzqkSInlkmSW6rqAGy5J
5CGloo7uYqmsuwEA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aVOnJF9GT4Xyt89vI5l
JX7VlEpfZFbXr0+2qXW5qvHC65fho9nHpC9GsY9+Oya3f2FyoRcYiQAAO3D35S6qRGkmV4yu
mFVreHMTmpW166OBfR0+2tsL8tfeNEqsJI6U8XXD+rwdNYMbY/htoZ9huag8nl6W17GPasbW
rlf9MmYXk9u/MLnQC5ORuNbgJM48xJmHOPMQZ57e4jw+PiYmV5ZzSVtTw+AMX3J7QG4Wg8SE
ZsYzGsVSeZE3jm4215vMUD7ZprbbusoUJ69nlPdDL2fbxESLaQ5/Q4y4T34Z9anW8+ao5ztx
5tkzzjotAQDALNrklpCEPTEM0Wgqg5mbxaBzTa6UL838hvK1el4hfj6rW1UeTy9n2zC51621
TAzApTASAQA6YGpy1df2+sdeNfMp60umNXltFGJpU2wN73km15WT+2RV7Fml/UjMse172Fa5
XcHWx+RegzC50AuMRACADshNrr1NIZuZtcvW+IVbCLx8OWsc/brEDCZ1UtPo6huzGupY89pg
cku3UizJmmnfpq5n21r44ZkxwR+C+Q31UJfC5EIvMBIBADpgOpN7Q1o01OiahMmFXmAkAgB0
wCFMbjJjrLVwSwMm91DC5EIvMBIBADrgpmdy0aGEyYVeYCQCAHQAJhcdRZhc6AVGIgBAB2By
0VGEyYVeYCQCAHQAJhcdRZhc6AVGIgBAB2By0VGEyYVeYCQCAHQAJhcdRZhc6AVGIgBAJ2B0
0bULgws9wWgEAOgETC66dmFyoScYjQAAHSEmAbOLrk1h3AL0BCMSAKBDgmlA6BoE0COMTAAA
AAA4HJhcAAAAADgcE5O71tcOxJmHOPMQZx7izEOceYgzD3HmIc48xJlnzzjrtAQAAAAA0BGY
XAAAAAA4HJhcAAAAADgYw/B/GH/Gark1cGQAAAAASUVORK5CYII=]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_BI_SetPV" version="1.1.0" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an Binary Input BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;P&gt;This function block sets the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of a Binary Input BACnet Object.&lt;/p&gt;
&lt;p&gt;It takes as input the value to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; and, using the passed BACnet Object pointer, it writes the value on the BACnet Object &lt;span style='font-family: Courier New '&gt;Priority_Array[15]&lt;/span&gt;. The output is equal to the input passed to the FB and does not come from the BACnet Object attributes.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; by setting the xClearAlways input to TRUE, your application may result  being not 100% compliant with the BTL standard.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Context of use&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Note that the value to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of a Binary Input BACnet Object can be of any kind, provided that the requirements regarding the data format are satisfied. E.g. it can be a Digital Input, a Digital Output, a generic Boolean IEC variable, etc.&lt;/p&gt;
&lt;p&gt;The wording &lt;i&gt;Input&lt;/i&gt; in the name of this object underlines that this object accepts only inputs from the IEC and cannot write on the IEC environment; therefore, it is a BACnet object which can only read.&lt;/p&gt;


&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_BI_SetPV&lt;/span&gt; FB. The purpose is to write the BOOL value of the xOutput_Cooling variable into the BACnet Object &lt;span style='font-family: Courier New '&gt;BI1_OutputCooling&lt;/span&gt;.&lt;/p&gt;
In this way, the value of xOutput_Cooling will be available to be read by a supervisor, which can access it by reading the PV of the &lt;span style='font-family: Courier New '&gt;BI1_OutputCooling&lt;/span&gt;.
&lt;img src= bacnet_bi_setpv.png  width= 500 &gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrBI_BACnet" type="@BACNET_BINARY_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="xValue" type="BOOL">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xClearAlways" type="BOOL">
						<descr>If TRUE, the PrArr is cleared at each execution, if required, in order for the Present_Value to reflect the Input Value. Default if FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="xPV_current" type="BOOL">
						<descr>BOOL Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error. Bit 4: PrArr Active.</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_xNULL" type="USINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="BI_Description" type="STRING" length="32">
						<descr>Binary Value Description</descr>
					</var>
					<var name="siToWrite" type="SINT">
						<descr>SINT value to be written in PrArr15</descr>
					</var>
					<var name="dintRet" type="DINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>Takes track of eventual overrides from the Supervisor (which does it by writing in the PriorityArray [0-14] Stack)</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>15</initValue>
					</var>
					<var name="writeFlag" type="USINT">
						<descr>Takes trace of the last type of write operation on PrArr15.</descr>
					</var>
					<var name="siToWrite_old" type="SINT"/>
					<var name="j_overr" type="USINT"/>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_BI_SetPVE													*
*																					*
* PURPOSE		: Set the present value of a Binary Input BACnet Object.			*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		21-05-18	Pierpaolo Armeli	Added option to clear all always			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 4: Priority Active (override from supervisor).
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrBI_BACnet.Object_Type=BACnetObjectType#OBJECT_BINARY_VALUE AND NOT (ptrBI_BACnet=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrBI_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	END_IF;
	
	IF NOT(xEn_old) AND xEn THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrBI_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrBI_BACnet.Description:=BI_Description;
		END_IF;
	END_IF;
		
	IF NOT(@ptrBI_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		BI_Description := @ptrBI_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrBI_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;

	IF xValue THEN
		siToWrite := 1;
	ELSIF NOT(xValue) THEN
		siToWrite := 0;
	END_IF;
	
	// I write on the PrArr15, continuously
	@ptrBI_BACnet.Priority_Array[15].choice_binary:=siToWrite;
	
	IF siToWrite<>siToWrite_old OR (xClearAlways AND @ptrBI_BACnet.Present_Value<>siToWrite) THEN
			FOR j_overr:=0 TO 14 DO
				@ptrBI_BACnet.Priority_Array[j_overr].choice_binary := BACnet_xNULL;
			END_FOR;
	END_IF;
		
	IF xLocalPV_Upd THEN
		dintRet := sysBACnet_BV_PresentValue(ptrBI_BACnet);
	END_IF;

	// xPriorityActive calculation - START
	IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF @ptrBI_BACnet.Priority_Array[j_Act].choice_binary<>BACnet_xNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;
	// xPriorityActive calculation - END
	
	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
	writeFlag := 1;
	
	siToWrite_old := siToWrite;
	
ELSE // BACnet Object not configured properly
	writeFlag := 0;
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
END_IF;

xPV_current:=xValue;
runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_bi_setpv.png" width="789" height="154">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAxUAAACaCAY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b1Knu06aRIy0sn9GONo4IyEWUi2S1Mhy3FJfhzHK8xIJIm/iWWOM+vMsvzXxy2V
P26Tsx3H2Q1/nDcW4TgMxnWoRfsAuEVoCQBQJTUV7k2+/N3A9FWhQkK+ZJ+c7HFR8u1nEbKx
3LbJhMhtKhm3vwmpGITJDChNvx/R5zDGT35LIZar5Yt10pjY9bYcsd8GpqJVwpQ3FT4pN2/4
o+TeJdNpEi3Wy+Q+MQdCdpswGKHMnKkoxZEx1D7ma1sfX8Z1csbiZTRFkQkplD8tm3jGmMj1
SkuMFuoiTAWAg5YAAFW0qbAJsUx8/cyBTcRtEmwSZi2RCOuEfE42kRaxZMKfxPJ1scqYEb/t
4fD7aECiGHoGQSkk9bpcf96TobH7LSw/xPDnGa0T650qdWuglslSaircrID8DYL82pFdjpJv
P4sQ9omSe7dtMiFym0rG7e84KgZhMgNK028+1DEmfvJbCrFcLV+sk8bErtdmBFNxNcJUADho
CQBQRZsK1EhrzVZjtU6UtKmwybVMov0sRJTU20TaJOFecptO7sPxVhkz4rfdvXw/GpAohp5B
UApJvS7XLgtDY/dbWH6I4c8zWifWO1XqhroKUwHgoCUAQBVMRR/Zr3oVvnbVWz2SJG0qkFBi
kNA1C1MB4KAlAECVZqbCf2Xo+OZVqu/XfDbVdB2uY5aiV4KEqShL/lgbXb8wFQAOWgIAVGlm
KtDVqWdyhKnIyH91it9K3JYwFQAOWgIAVDEDJnof6okpL5egIXRr6t12AK4VWgIAAHQHU4H2
IkwFgIOWAAAA3cFUoL0IUwHgoCUAAEB3MBVoL8JUADhoCQAA0B1MBdqLMBUADloCAAB0B1OB
9iJMBYCDlgAAAJuAsUC3LgwFwBFaAwAAbAKmAt26MBUAR2gNAACwGSYpw1ygW1N4bgHgCC0C
AAA2JyRpCN2CAEAzDP8fr2oMDfTHEukAAAAASUVORK5CYII=]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_AI_SetPV" version="1.0.1" creationDate="0" lastModifiedDate="1603873225">
			<title>Set the Present Value of a BACnet Analog Input Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;P&gt;This function block sets the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of an Analog Input BACnet Object.&lt;/p&gt;
&lt;p&gt;It takes as input the value to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; and, using the passed BACnet Object pointer, it writes the value on the BACnet Object and gives back the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; as output.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Context of use&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Note that the value to be written on the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; of an Analog Input BACnet Object can be of any kind, provided that the requirements regarding the data format are satisfied. E.g. it can be an Analog Input, an Analog Output, a generic IEC variable, etc.&lt;/p&gt;
&lt;p&gt;The wording &lt;i&gt;Input&lt;/i&gt; in the name of this object underlines that this object accepts only inputs from the IEC and cannot write on the IEC environment; therefore, it is a BACnet object which can only read.&lt;/p&gt;


&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_AI_SetPV&lt;/span&gt; FB. The purpose is to write the INT value of the Analog Output 2 (AO2) into the BACnet Object &lt;span style='font-family: Courier New '&gt;AI1_Template&lt;/span&gt;.&lt;/p&gt;
In this way, the value of the AO2 will be available to be read by a supervisor, which can access it by reading the PV of the &lt;span style='font-family: Courier New '&gt;AI1_Template&lt;/span&gt;.
&lt;img src= bacnet_ai_setpv.png  width= 500 &gt;
&lt;p&gt;Please note that also an AI can be made available through a BACnet AI Object. This is true as well for any kind of variable, whose value the user is interested to read from a supervisor.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Versions:&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
Ver. 1.0.1:&lt;br&gt;
- Forced casting to INT to avoid warning&lt;br&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable BACnet service for the Object.</descr>
					</var>
					<var name="ptrAI_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>BACnet Object Address (use ADR)</descr>
					</var>
					<var name="iValue" type="INT">
						<descr>INT value to be written in PV. If iValue = 32767, it is disabled and rValue is used to set the PV instead. It is multiplied by rScaler to calculate the PV.</descr>
						<initValue>32767</initValue>
					</var>
					<var name="rValue" type="REAL">
						<descr>REAL Value to be written in PV. Enabled only if iValue = 32767. It is multiplied by rScaler to calculate the PV.</descr>
						<initValue>340282346638528860000000000000000000000.00000000</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0. NOTE: it is multiplied by the iValue or the rValue to determine the PV.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Force local PV Update. Default: FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="rPV" type="REAL">
						<descr>It returns the Present Value.</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK. Bit 1: Out Of Service. Bit 2: Config Error.</descr>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AI_Description" type="STRING" length="32">
						<descr>Analog Input Description</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_AI_SetPV													*
*																					*
* PURPOSE		: Set the present value of an Analog Input BACnet Object.			*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		28-10-20	Federico Marcassa	Minor change: Add casting to INT			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAI_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_INPUT AND rScaler<>0.0 AND NOT (ptrAI_BACnet=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);

	IF NOT(xEn) THEN
		@ptrAI_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	END_IF;
	
	IF NOT(xEn_old) AND xEn THEN
  		@ptrAI_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN
			@ptrAI_BACnet.Description:=AI_Description;
		END_IF;
	END_IF;
	
	IF NOT(@ptrAI_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
		
	IF xEn OR NOT(runCheck) THEN
		AI_Description := @ptrAI_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN
 		 @ptrAI_BACnet.Description:='Disabled';
	END_IF;
			
	IF iValue<INT#32767 THEN // Ver. 1.0.1
		@ptrAI_BACnet.Present_Value := TO_REAL(iValue) * rScaler;
	ELSE //it means iValue=32767
		@ptrAI_BACnet.Present_Value := rValue * rScaler;
	END_IF;
	
	IF xLocalPV_Upd THEN
		realRet := sysBACnet_AV_PresentValue(ptrAI_BACnet);
	END_IF;
		
	rPV:= @ptrAI_BACnet.Present_Value;
	xEn_old:=xEn;

	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	rPV := BACnet_rNULL;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_ai_setpv.png" width="646" height="165">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAoYAAAClCAYAAADBLTzIAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACB6SURBVHhe7Z2/btw4uEf9Kun2AdIE
fgGXLrZ07cJP4TzBIsAFtlnATdpgq7udmwCp0m9xt99mH0JXH0VqPv4VRxblGfEc4AfPjCSK
EiXyhGNHNwMAAAAAwAhiCAAAAAAGxBAAAAAADIghAAAAABgQQwAASPLX483w6bd/7DvNP8Nv
n26Gmxubx7/s50JpWWumfS/v8lTH5tX757fhkzsXNql91p7r9fX9a3j89NtYGkAZxBAAAGJE
aB5/G6XkcVQKzSQqWmJEapwA/vPbJyWDtaK2FZX7k2PbS5KifY2CdvNp8Byw+lwntq1lz2OG
qwYxBACACJE9ESwRPU+0koIhwhJKzYRsn54Js5jyHodHMytmy/jrcZ4h0zOORjpLn9tyymIo
dbVlyP4S+9f7mevurSef/2WkzVsnRXS+4pm7c871P//8NUZejMsex/rYenozs9H5U7OOyCEs
gBgCAECAEr1QTkQ6IvMS8UjNZOWFcUbK17Ngwf6cNPmfB/XzXp85Y2i2CfY/11n2Y5fp9cLX
Jdky61opc/EqeO65tphydT3TZaTPH0AexBAAADzCWb5ZLqY3lWKopKpESoYCkfJm7ebPp7KL
dc2h95navyogKVal7UOi5f55Of9cW7xy1fnPnb+legJYEEMAAFCIuPhiYVIUITVjJcg6NVIo
hOXlZMgITzyTd31iqOu45lxbvGWBGKZO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EsD9ocQCAK+fm+WZOitSMocihCJ6RxFDcgnXN57P0vQ635qvf
8LUVLSnLK0fWsdu6z8P9qJnCuQy7zNXTvU8mLE+/l9dzHdXMoPlc1WsURMQwDmLYH1UtvtWF
QTllKKcM5ZShnDJHLef+/t4TQ3kfRvYVD/qTJHlf3YaC5SLiFsjaLFep9SVWtqZZQytmbn1v
mVputlUi6b0uJKyHfh8sE/EU0XQ/XRnzMdn3ZErtdXrU+6vHcrbZAwAAvBtaDFPIIBAN+rOc
KSkLBcvlXDGU9VMzjG793HY2rvxw9jCbsDz9PliGGJ6XrUQErgdaHADg4MRiqL5S1X/wkRM2
+Twlet7rMa4sLZJGEs8Tw2k9+b0/VXYxfj08oTR1d8syXyWb7RHDVBDD/qDFAQAOTiiG5ivk
YAbQvDey5L7etbHrGdmyn3kC5W3ji9a0/Sh4bhsjfBVimPqaeylGQO0+9XZmXwt/fDKK4wcn
jG47YoIY9gctDgBwcOIZw46yKKGkFMSwP2hxAICDcwgx9GYmdRa+bkYM3xTEsD9ocQCAg9P1
jCF5UxDD/qDFAQAODmJI1gYx7A9aHADg4CCGZG0Qw/6gxQEADg5iSNYGMewPWhwA4OAghmRt
EMP+oMUBAA4OYkjWBjHsD1ocAKADkENybpDCPqHVAQA6ADEk5wYx7BNaHQCgE2SgRxDJUtx1
An1CywMAdIYb+AlJBfqGKwAAAAAADIghAAAAABiqxHCrqWXKKUM5ZSinDOWUoZwylFOGcspQ
TplrKmebPQAAAADA1YMYAgAAAIABMQQAAACAkWH4f80sR8QVd4/CAAAAAElFTkSuQmCC]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_ObjID_De_store_EE" version="1.1.0" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an Analog Value INT BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block enables two functionalities:&lt;/p&gt;
 &lt;ol&gt;
 &lt;li&gt;Update the EEPROM parameters containing the Device ID and Device Subnet, which together define the BACnet Device Object ID, after a change from the supervisor side.&lt;/li&gt;
 &lt;li&gt;Detect a local change of the  Device ID and Device Subnet EEPROM parameters and provide the info that a reboot is required for changes to take effect.&lt;/li&gt;
 &lt;/ol&gt;

It is supposed to be used together with the &lt;i&gt;BACnet_ObjID&lt;/i&gt; function, that will have to be called into a program assigned to the Init task.

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_ObjID_De_store_EE&lt;/span&gt; FB.&lt;/p&gt;
&lt;img src= BACnet_ObjID_De_store_EE.png  width= 670 &gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Enable/disable the FB.</descr>
					</var>
					<var name="ptrDe_BACnet" type="@BACNET_DEVICE">
						<descr>Device Object Address (use ADR)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_udiBACnet_ID" type="@UDINT">
						<descr>BACnet_ID EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_usiBACnet_Subnet" type="@USINT">
						<descr>BACnet_Subnet EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="xObjID_Changed" type="BOOL">
						<descr>BOOL that states if the ObjID has been changed from the BACnet side</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xRebootReq" type="BOOL">
						<descr>BOOL that states if a reboot is required after an EEPROM parameters change from the IEC side</descr>
						<initValue>FALSE</initValue>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="udi_currentID" type="UDINT"/>
					<var name="usi_currentSubnet" type="USINT"/>
					<var name="xRet" type="BOOL"/>
					<var name="udi_oldObjID" type="UDINT"/>
					<var name="udi_ID_old" type="UDINT"/>
					<var name="usi_Subnet_old" type="USINT"/>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_ObjID_De_store_EE											*
*																					*
* PURPOSE		: Store the ID and Subnet info used for the Device ObjectID			*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	26-03-18 	Pierpaolo Armeli	First release 								*
* 												 									*
*************************************************************************************)

IF @ptrDe_BACnet.Object_Type=BACnetObjectType#OBJECT_DEVICE AND NOT (ptrDe_BACnet=0) AND NOT (ptr_udiBACnet_ID=0) AND NOT (ptr_usiBACnet_Subnet=0) AND xEn THEN
	
	IF NOT(runCheck) THEN
		udi_oldObjID:=@ptrDe_BACnet.Object_Identifier;
		udi_ID_old := @ptr_udiBACnet_ID;
		usi_Subnet_old := @ptr_usiBACnet_Subnet;
		xRebootReq:=FALSE;
		runCheck:=TRUE;
	END_IF;
	
	IF udi_ID_old <> @ptr_udiBACnet_ID OR usi_Subnet_old <> @ptr_usiBACnet_Subnet THEN
		IF NOT(xObjID_Changed) THEN
			xRebootReq:=TRUE;
		END_IF;
	END_IF;
	
	xObjID_Changed:=FALSE;
	IF NOT(xRebootReq) THEN
		udi_currentID := @ptrDe_BACnet.Object_Identifier AND UDINT#16#FFFF;
		usi_currentSubnet := TO_USINT(SHR((@ptrDe_BACnet.Object_Identifier AND UDINT#16#3F0000),16));

		IF udi_currentID <> udi_ID_old THEN
			xRet:=sysWriteParUDINT(ptr_udiBACnet_ID,udi_currentID);
		END_IF;
		
		IF usi_currentSubnet <> usi_Subnet_old THEN
			xRet:=sysWriteParUSINT(ptr_usiBACnet_Subnet,usi_currentSubnet);
		END_IF;	
		
		IF udi_oldObjID <> @ptrDe_BACnet.Object_Identifier THEN
			xObjID_Changed:=TRUE;
		END_IF;
		
		udi_oldObjID:=@ptrDe_BACnet.Object_Identifier;
	END_IF;	
	
	udi_ID_old := @ptr_udiBACnet_ID;
	usi_Subnet_old := @ptr_usiBACnet_Subnet;

END_IF;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_objid_de_store_ee.png" width="781" height="177">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAw0AAACxCAYAAACGAVFzAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACdqSURBVHhe7Z2xbty61oX9KunOA7gJ
8gIuT5HStYs8RfwEBwEOkCaAG7dGqns7NwF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UE8e6slz
Tj0nbyE7iUynNsfu584Ei0nWJlgCQWSaB2ZYDLevxzTQymC7n9M/hLaezKttVNvC9pM//uPe
AhwCwGB74/i7n0MIGttfofbNUKnBJ0hdlmFG0980AAAAAGyR+aGhVf95f/eHv8H4quXWWwJv
qvv1rQ4GWxt0pShMxG8j+gAxZsrD9mGbtJ4jxtyFoLBtq0NgGTl+146RP4ReoH3nqLSRJTSM
i9AAAAAANVMkNKD6tISJJTSMi9AAAAAANUNoCDLefHRSbwJ2oqUMLKFhXIQGAAAAqBlCw5Vp
SfNKaBgXoQEAAABqhtBwRVrauBIaxkVoAAAAgJo5KzSgOrU0sg/LMCNCAwAAANQNTgaKQWgY
F6EBAAAAagYnA8UgNIyL0AAAAAA1g5OBYhAaxkVoAAAAgJrByUAxCA3jIjQAAABAzeBkoCgE
h6EIDAAAAFA7uBkoCqFhKEIDAAAA1A5uBoojJpnw0IUFAgMAAADsARwNLEYwzdcqAAAAgL2A
swEAAAAAgCyEBgAAAAAAyHJyaCj1sQvqyUM9eagnD/XkoZ481JOHevJQTx7qyUM9eS5ZT5k9
AwAAAADAbiE0AAAAAABAFkIDAAAAAABkITQAAAAAAEAWQgMAAAAAAGQhNAAAAAAAQBZCAwAA
AAAAZCE0AAAAAABAFkIDAAAAAABkaJr/B/GUli2KYxO5AAAAAElFTkSuQmCC]]>
				</image>
			</images>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_AV_link_iEE" version="3.1.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an Analog Value INT BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link an INT EEPROM parameter to a BACnet Analog Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Analog Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (multiplied by) using the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrAV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_iEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the iPV_scaled output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the iPV_scaled has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the iPV_scaled will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the iPV_scaled output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the iPV_scaled.&lt;/li&gt;
  &lt;/ul&gt;

&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;iRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;iRelMax&lt;/span&gt; allow to limit the value that the EEPROM parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range writes from the supervisor side.&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;In case of an out-of-range write from the supervisor on &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;, this write will not be accepted (the EEPROM does not get updated with the written value) and the value which is present in the EEPROM will be restored on the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;. The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute does not get changed in this case by the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In case of an out-of-range write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Priority_Array&lt;/span&gt;, which will cause an out-of-range &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt;, the output of the FB (&lt;span style='font-family: Courier New '&gt;iPV_scaled&lt;/span&gt;) will be saturated using the &lt;u&gt;&lt;b&gt;scaled&lt;/u&gt;&lt;/b&gt; &lt;span style='font-family: Courier New '&gt;iRelMin&lt;/span&gt; (if lower than it) or the &lt;span style='font-family: Courier New '&gt;iRelMax&lt;/span&gt; (if higher than it) and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute of the BACnet Object will be set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNDER_RANGE&lt;/span&gt; in the former case and to &lt;span style='font-family: Courier New '&gt;RELIABILITY_OVER_RANGE&lt;/span&gt; in the latter one.&lt;br&gt;
  The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; gets back into the limits.
  &lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;iRelMax&lt;/span&gt; are both scaled by multiplying them by the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; before using them for the comparisons.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_AV_link_iEE&lt;/span&gt; FB.&lt;/p&gt;
&lt;p&gt;The purpose is to implement the BACnet protocol in an existing project where the setpoint parameter which is in EEPROM has been renamed from &lt;span style='font-family: Courier New '&gt;iSetPoint&lt;/span&gt; to &lt;span style='font-family: Courier New '&gt;iSetPoint_E2&lt;/span&gt; and is now passed to the pointer to the EEPROM using the &lt;span style='font-family: Courier New '&gt;ADR&lt;/span&gt; function.&lt;/p&gt;
&lt;p&gt;A new global variable has been created using the same name of the old EEPROM parameter, which was &lt;span style='font-family: Courier New '&gt;iSetPoint&lt;/span&gt; and it is used as output of this function block, so that it will keep its value updated.&lt;/p&gt;
&lt;p&gt;Therefore, all the instances of the IEC code where the old EEPROM parameter &lt;span style='font-family: Courier New '&gt;iSetPoint&lt;/span&gt; was used will not need to be changed, as the new global variable has the same name of the old EEPROM parameter.&lt;/p&gt;
&lt;p&gt;The working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt; has to be selected according to how the developer wants to manage the priorities between the IEC side and the BACnet side. Have a look at the &lt;i&gt;Woking Mode&lt;/i&gt; section above for further details.&lt;/p&gt;
&lt;p&gt;In this example, &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; is not connected because for the PV update the &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr&lt;/span&gt; function block is used. In case &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr&lt;/span&gt; is not used, you should connect a variable to &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; and set it to TRUE.&lt;/p&gt;
&lt;img src= bacnet_reldef_av_link_iee.png  width= 800 &gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but iEE will still be written on the RelDef and passed to the iPV_scaled output.</descr>
					</var>
					<var name="ptrAV_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>Analog Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_iEE" type="@INT">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iRelMin" type="INT">
						<descr>Lower limit for Relinquish Default in INT. It is scaled by multiplying it by the rScaler.</descr>
						<initValue>-32768</initValue>
					</var>
					<var name="iRelMax" type="INT">
						<descr>Higher limit for Relinquish Default in INT. It is scaled by multiplying it by the rScaler.</descr>
						<initValue>32767</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE  RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
						<initValue>0</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="iPV_scaled" type="INT">
						<descr>Scaled INT Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_rNULL" type="REAL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AV_Description" type="STRING" length="32">
						<descr>Analog Value Description</descr>
					</var>
					<var name="rEE" type="REAL">
						<descr>REAL value to be written in the Reliquish Default</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="iRelinqScaled" type="INT">
						<descr>Scaled INT value present in the Relinquish Default</descr>
					</var>
					<var name="rPV" type="REAL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_over" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="writeRel_under" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="j_overr" type="USINT"/>
					<var name="rPV_old" type="REAL"/>
					<var name="iEE_old" type="INT"/>
					<var name="iEE" type="INT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_AV_link_iEE											*
*																					*
* PURPOSE		: Set the present value of an Analog Value INT BACnet Object.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
************************************************************************************)

(* it initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;		
 - bit 4: Priority Active (override from supervisor)						*)

IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAV_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_VALUE AND rScaler<>0.0 AND NOT (ptrAV_BACnet=0) AND NOT(ptr_iEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
		
	IF NOT(runCheck) THEN
		iEE_old:=@ptr_iEE+1;
		rPV_old:=TO_REAL(@ptr_iEE) * rScaler;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrAV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrAV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrAV_BACnet.Description:=AV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		AV_Description := @ptrAV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrAV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------

	iEE := @ptr_iEE;
	rEE := TO_REAL(iEE) * rScaler;
	
	IF iEE_old<>iEE THEN
		@ptrAV_BACnet.Relinquish_Default:=rEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
			END_FOR;
		END_IF;
	END_IF;
	
	IF @ptrAV_BACnet.Relinquish_Default<>rEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;
		
	IF xRelMod THEN
		iRelinqScaled:=BACnet_r_ROUND_i(@ptrAV_BACnet.Relinquish_Default/rScaler);
		IF @ptrAV_BACnet.Relinquish_Default>rRelMin AND @ptrAV_BACnet.Relinquish_Default<rRelMax THEN
			sysWriteRet:=sysWriteParINT(ptr_iEE,iRelinqScaled); /////////////////////////////////////////////////////////////////////////
		ELSE
			@ptrAV_BACnet.Relinquish_Default:=rEE;
		END_IF;
	END_IF;
	
	IF xLocalPV_Upd OR NOT(runCheck)	THEN	realRet := sysBACnet_AV_PresentValue(ptrAV_BACnet);	END_IF;
		
	IF @ptrAV_BACnet.Out_Of_Service=TRUE THEN 
		rPV:=rEE;  // if OOS, I write what I would have passed from IEC side
		xOOS:=TRUE;
	ELSE
		rPV:= @ptrAV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	IF rPV_old<>rPV AND usiMode=2 AND NOT(xOOS) THEN
		iPV_scaled:=BACnet_r_ROUND_i(rPV/rScaler);
		sysWriteRet:=sysWriteParINT(ptr_iEE,iPV_scaled);
		iEE_old:=iEE;
	END_IF;
	
	iEE_old:=@ptr_iEE;	
	rPV_old:=rPV;

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrAV_BACnet.Priority_Array[j_Act].choice_real)<>BACnet_rNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------	
	rRelMin:=TO_REAL(iRelMin)*rScaler;
	rRelMax:=TO_REAL(iRelMax)*rScaler;
	
	IF rPV<rRelMin THEN // I saturate rPV_scaled with Min and Max in the Out of Range case, PV side (PriorArr15 side)
		iPV_scaled := iRelMin;
		inside_limits_flag:=FALSE;
		IF writeRel_under THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNDER_RANGE;
			writeRel_under:=FALSE;
		END_IF;
	ELSIF rPV>rRelMax THEN
		iPV_scaled := iRelMax;
		inside_limits_flag:=FALSE;
		IF writeRel_over THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_OVER_RANGE;
			writeRel_over:=FALSE;
		END_IF;
	ELSE
		iPV_scaled:=BACnet_r_ROUND_i(rPV/rScaler);
		inside_limits_flag:=TRUE;
		writeRel_under:=TRUE;
		writeRel_over:=TRUE;
	END_IF;

	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF (@ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNDER_RANGE OR @ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_OVER_RANGE) AND inside_limits_flag THEN
		@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;

// --------------------    wStatus Update    --------------------------------------------------------------------------
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	IF NOT(@ptr_iEE=0) THEN
		iPV_scaled:=@ptr_iEE;
	ELSE
		iPV_scaled:=iRelMin;
	END_IF;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_AV_link_rEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an Analog Value REAL BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link a REAL EEPROM parameter to a BACnet Analog Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Analog Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (multiplied by) using the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrAV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_rEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the rPV_scaled output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the rPV_scaled has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the rPV_scaled will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the rPV_scaled output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the rPV_scaled.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt;BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;rRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;rRelMax&lt;/span&gt; allow to limit the value that the EEPROM parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range writes from the supervisor side.&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;In case of an out-of-range write from the supervisor on &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;, this write will not be accepted (the EEPROM does not get updated with the written value) and the value which is present in the EEPROM will be restored on the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;. The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute does not get changed in this case by the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In case of an out-of-range write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Priority_Array&lt;/span&gt;, which will cause an out-of-range &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt;, the output of the FB (&lt;span style='font-family: Courier New '&gt;rPV_scaled&lt;/span&gt;) will be saturated using the &lt;u&gt;&lt;b&gt;scaled&lt;/u&gt;&lt;/b&gt; &lt;span style='font-family: Courier New '&gt;rRelMin&lt;/span&gt; (if lower than it) or the &lt;span style='font-family: Courier New '&gt;rRelMax&lt;/span&gt; (if higher than it) and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute of the BACnet Object will be set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNDER_RANGE&lt;/span&gt; in the former case and to &lt;span style='font-family: Courier New '&gt;RELIABILITY_OVER_RANGE&lt;/span&gt; in the latter one.&lt;br&gt;
  The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; gets back into the limits.
  &lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;&lt;u&gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt;Note&lt;/span&gt;&lt;/u&gt;&lt;/b&gt; that &lt;span style='font-family: Courier New '&gt;rRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;rRelMax&lt;/span&gt; are both scaled by multiplying them by the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; before using them for the comparisons.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style='color:#990000;'&gt;The way this FB can be implemented is analoguous to how the BACnet_RelDef_AV_link_iEE function block has to be implemented. The only difference is that the pointed EEPROM parameter and the PV output will be REAL instead of INT. Refer to the BACnet_RelDef_AV_link_iEE description to see the example.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but rEE will still be written on the RelDef and passed to the rPV_scaled output.</descr>
					</var>
					<var name="ptrAV_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>Analog Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_rEE" type="@REAL">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0.0</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL. NOTE: It is scaled by multiplying it by the rScaler.</descr>
						<initValue>-3.40E+38</initValue>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL. NOTE: It is scaled by multiplying it by the rScaler.</descr>
						<initValue>3.40E+38</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0. NOTE: it is multiplied by the REAL Value in EEPROM to determine the Relinquish Default. It is also used to scale the Min and Max limits.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
						<initValue>0</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="rPV_scaled" type="REAL">
						<descr>Scaled REAL Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_rNULL" type="REAL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AV_Description" type="STRING" length="32">
						<descr>Analog Value Description</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRelinqScaled" type="REAL">
						<descr>Scaled REAL value present in the Relinquish Default</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_over" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="writeRel_under" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rEE" type="REAL">
						<descr>REAL Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="rRelMin_sc" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rRelMax_sc" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rPV" type="REAL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="rEE_old" type="REAL"/>
					<var name="rPV_old" type="REAL"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_AV_link_rEE											*
*																					*
* PURPOSE		: Set the present value of an Analog Value REAL BACnet Object.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
************************************************************************************)

(* it initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;		
 - bit 4: Priority Active (override from supervisor)						*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAV_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_VALUE AND rScaler<>0.0 AND NOT (ptrAV_BACnet=0) AND NOT (ptr_rEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);

	IF NOT(runCheck) THEN
		rEE_old := @ptr_rEE+1;
		rPV_old := (@ptr_rEE) * rScaler;
		xPrArrClear_OD_old := xPrArrClear_OD;
	END_IF;
	
// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrAV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrAV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrAV_BACnet.Description:=AV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		AV_Description := @ptrAV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrAV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------

	rEE := (@ptr_rEE) * rScaler;
	
	IF rEE_old<>rEE THEN
		@ptrAV_BACnet.Relinquish_Default:=rEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
			END_FOR;
		END_IF;		
	END_IF;

	IF @ptrAV_BACnet.Relinquish_Default<>rEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;
	
	IF xRelMod THEN
		rRelinqScaled:=@ptrAV_BACnet.Relinquish_Default/rScaler;
		IF @ptrAV_BACnet.Relinquish_Default>rRelMin AND @ptrAV_BACnet.Relinquish_Default<rRelMax THEN
			sysWriteRet:=sysWriteParREAL(ptr_rEE,rRelinqScaled); /////////////////////////////////////////////////////////////////////////
		ELSE
			@ptrAV_BACnet.Relinquish_Default:=rEE;
		END_IF;
	END_IF;
	
	IF xLocalPV_Upd OR NOT(runCheck)	THEN	realRet := sysBACnet_AV_PresentValue(ptrAV_BACnet);	END_IF;
	
	IF @ptrAV_BACnet.Out_Of_Service=TRUE THEN
		rPV:=rEE; // if OOS, I write what I would have passed from IEC side
		xOOS:=TRUE;
	ELSE
		rPV:= @ptrAV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;

	IF rPV_old<>rPV AND usiMode=2 AND NOT(xOOS) THEN
		rPV_scaled:=rPV/rScaler;
		sysWriteRet:=sysWriteParREAL(ptr_rEE,rPV_scaled);
		rEE_old:=rEE;
	END_IF;

	rEE_old:=(@ptr_rEE) * rScaler;
	rPV_old:=rPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;
	
// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrAV_BACnet.Priority_Array[j_Act].choice_real)<>BACnet_rNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	rRelMin_sc:=rRelMin*rScaler;
	rRelMax_sc:=rRelMax*rScaler;
	
	IF rPV<rRelMin_sc THEN // I saturate rPV_scaled with Min and Max in the Out of Range case, PV side (PriorArr15 side)
		rPV_scaled := rRelMin;
		inside_limits_flag:=FALSE;
		IF writeRel_under THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNDER_RANGE;
			writeRel_under:=FALSE;
		END_IF;
	ELSIF rPV>rRelMax_sc THEN
		rPV_scaled := rRelMax;
		inside_limits_flag:=FALSE;
		IF writeRel_over THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_OVER_RANGE;
			writeRel_over:=FALSE;
		END_IF;
	ELSE
		rPV_scaled:=rPV/rScaler;
		inside_limits_flag:=TRUE;
		writeRel_under:=TRUE;
		writeRel_over:=TRUE;
	END_IF;

	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits	
	IF (@ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNDER_RANGE OR @ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_OVER_RANGE) AND inside_limits_flag THEN
		@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------		
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	IF NOT(@ptr_rEE=0.0) THEN
		rPV_scaled:=@ptr_rEE;
	ELSE
		rPV_scaled:=rRelMin;
	END_IF;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_AV_link_uiEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an Analog Value UINT BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link an UINT EEPROM parameter to a BACnet Analog Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Analog Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (multiplied by) using the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrAV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_uiEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the uiPV_scaled output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the uiPV_scaled has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the uiPV_scaled will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the uiPV_scaled output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the uiPV_scaled.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;uiRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;uiRelMax&lt;/span&gt; allow to limit the value that the EEPROM parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range writes from the supervisor side.&lt;/p&gt;
  &lt;ul&gt;
  &lt;li&gt;In case of an out-of-range write from the supervisor on &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;, this write will not be accepted (the EEPROM does not get updated with the written value) and the value which is present in the EEPROM will be restored on the &lt;span style='font-family: Courier New '&gt;Relinquish&lt;/span&gt;. The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute does not get changed in this case by the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;In case of an out-of-range write from the supervisor on the &lt;span style='font-family: Courier New '&gt;Priority_Array&lt;/span&gt;, which will cause an out-of-range &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt;, the output of the FB (&lt;span style='font-family: Courier New '&gt;uiPV_scaled&lt;/span&gt;) will be saturated using the &lt;u&gt;&lt;b&gt;scaled&lt;/u&gt;&lt;/b&gt; &lt;span style='font-family: Courier New '&gt;uiRelMin&lt;/span&gt; (if lower than it) or the &lt;span style='font-family: Courier New '&gt;uiRelMax&lt;/span&gt; (if higher than it) and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute of the BACnet Object will be set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNDER_RANGE&lt;/span&gt; in the former case and to &lt;span style='font-family: Courier New '&gt;RELIABILITY_OVER_RANGE&lt;/span&gt; in the latter one.&lt;br&gt;
  The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the &lt;span style='font-family: Courier New '&gt;Present_Value&lt;/span&gt; gets back into the limits.
  &lt;/li&gt;
  &lt;/ul&gt;
&lt;p&gt;&lt;u&gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt;Note&lt;/span&gt;&lt;/u&gt;&lt;/b&gt; that &lt;span style='font-family: Courier New '&gt;uiRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;uiRelMax&lt;/span&gt; are both scaled by multiplying them by the &lt;span style='font-family: Courier New '&gt;rScaler&lt;/span&gt; before using them for the comparisons.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style='color:#990000;'&gt;The way this FB can be implemented is analoguous to how the BACnet_RelDef_AV_link_iEE function block has to be implemented. The only difference is that the pointed EEPROM parameter and the PV output will be UINT instead of INT. Refer to the BACnet_RelDef_AV_link_iEE description to see the example.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but uiEE will still be written on the RelDef and passed to the uiPV_scaled output.</descr>
					</var>
					<var name="ptrAV_BACnet" type="@BACNET_ANALOG_VALUE">
						<descr>Analog Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_uiEE" type="@UINT">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="uiRelMin" type="UINT">
						<descr>Lower limit for Relinquish Default in UINT. NOTE: It is scaled by multiplying it by the rScaler.</descr>
						<initValue>0</initValue>
					</var>
					<var name="uiRelMax" type="UINT">
						<descr>Higher limit for Relinquish Default in UINT. NOTE: It is scaled by multiplying it by the rScaler.</descr>
						<initValue>65535</initValue>
					</var>
					<var name="rScaler" type="REAL">
						<descr>Scaling factor. Default is 1.0. It cannot be 0.0. NOTE: it is multiplied by the UINT Value in EEPROM to determine the Relinquish Default. It is also used to scale the Min and Max limits.</descr>
						<initValue>1.0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
						<initValue>0</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="uiPV_scaled" type="UINT">
						<descr>Scaled UINT Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_rNULL" type="REAL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="AV_Description" type="STRING" length="32">
						<descr>Analog Value Description</descr>
					</var>
					<var name="rRel_to_write" type="REAL">
						<descr>REAL value to be written in the Reliquish Default</descr>
					</var>
					<var name="realRet" type="REAL">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="uiRelinqScaled" type="UINT">
						<descr>Scaled UINT value present in the Relinquish Default</descr>
					</var>
					<var name="rPV" type="REAL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_over" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="writeRel_under" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for Relinquish Default in REAL.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="rPV_old" type="REAL"/>
					<var name="uiEE_old" type="UINT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="uiEE" type="UINT"/>
					<var name="j_overr" type="USINT"/>
					<var name="rEE" type="REAL"/>
					<var name="xOOS" type="BOOL">
						<initValue>FALSE</initValue>
					</var>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_AV_link_uiEE										*
*																					*
* PURPOSE		: Set the present value of an Analog Value UINT BACnet Object.		*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;	
 - bit 4: Priority Active (override from supervisor)							*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrAV_BACnet.Object_Type=BACnetObjectType#OBJECT_ANALOG_VALUE AND rScaler<>0.0 AND NOT (ptrAV_BACnet=0) AND NOT (ptr_uiEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		uiEE_old:=@ptr_uiEE+1;
		rPV_old:=TO_REAL(uiEE) * rScaler;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;
	
// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrAV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrAV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrAV_BACnet.Description:=AV_Description;
		END_IF;
	END_IF;
		
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		AV_Description := @ptrAV_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrAV_BACnet.Description:='Disabled';
	END_IF;

	xEn_old:=xEn;


	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------
	uiEE := @ptr_uiEE;
	rEE:= TO_REAL(uiEE) * rScaler;

	IF uiEE_old<>uiEE THEN
		@ptrAV_BACnet.Relinquish_Default:=rEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
			END_FOR;
		END_IF;
	END_IF;
	
	IF @ptrAV_BACnet.Relinquish_Default<>rEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;	
	
	IF xRelMod THEN
		uiRelinqScaled:=BACnet_r_ROUND_ui(@ptrAV_BACnet.Relinquish_Default/rScaler);
		IF @ptrAV_BACnet.Relinquish_Default>rRelMin AND @ptrAV_BACnet.Relinquish_Default<rRelMax THEN
			sysWriteRet:=sysWriteParUINT(ptr_uiEE,uiRelinqScaled);
		ELSE
			@ptrAV_BACnet.Relinquish_Default:=rEE;
		END_IF;
	END_IF;
		
	IF xLocalPV_Upd OR NOT(runCheck)	THEN	realRet := sysBACnet_AV_PresentValue(ptrAV_BACnet);	END_IF;	

	IF @ptrAV_BACnet.Out_Of_Service=TRUE THEN 
		rPV:=rEE;  // if OOS, I write what I would have passed from IEC side
		xOOS:=TRUE;
	ELSE
		rPV:= @ptrAV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	IF rPV_old<>rPV AND usiMode=2 AND NOT(xOOS) THEN
		uiPV_scaled:=BACnet_r_ROUND_ui(rPV/rScaler);
		sysWriteRet:=sysWriteParUINT(ptr_uiEE,uiPV_scaled);
		uiEE_old:=uiEE;
	END_IF;
	
	uiEE_old:=@ptr_uiEE;
	rPV_old:=rPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrAV_BACnet.Priority_Array[j_overr].choice_real := BACnet_rNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrAV_BACnet.Priority_Array[j_Act].choice_real)<>BACnet_rNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	rRelMin:=TO_REAL(uiRelMin)*rScaler;
	rRelMax:=TO_REAL(uiRelMax)*rScaler;
	
	IF rPV<rRelMin THEN // I saturate rPV_scaled with Min and Max in the Out of Range case, PV side (PriorArr15 side)
		uiPV_scaled := uiRelMin;
		inside_limits_flag:=FALSE;
		IF writeRel_under THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNDER_RANGE;
			writeRel_under:=FALSE;
		END_IF;
	ELSIF rPV>rRelMax THEN
		uiPV_scaled := uiRelMax;
		inside_limits_flag:=FALSE;
		IF writeRel_over THEN
			@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_OVER_RANGE;
			writeRel_over:=FALSE;
		END_IF;
	ELSE
		uiPV_scaled:=BACnet_r_ROUND_ui(rPV/rScaler);
		inside_limits_flag:=TRUE;
		writeRel_under:=TRUE;
		writeRel_over:=TRUE;
	END_IF;

	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits	
	IF (@ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNDER_RANGE OR @ptrAV_BACnet.Reliability=BACnetReliability#RELIABILITY_OVER_RANGE) AND inside_limits_flag THEN
		@ptrAV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrAV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;

	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	IF NOT(@ptr_uiEE=0) THEN
		uiPV_scaled:=@ptr_uiEE;
	ELSE
		uiPV_scaled:=uiRelMin;
	END_IF;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_BV_link_xEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an Binary Value BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link a BOOL EEPROM parameter to a BACnet Binary Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Analog Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrBV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_xEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the xPV_current output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the xPV_current has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the xPV_current will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the xPV_current output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the xPV_current.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_BV_link_xEE&lt;/span&gt; FB.&lt;/p&gt;
&lt;p&gt;The purpose is to implement the BACnet protocol in an existing project where the machine state, which is in EEPROM, has been renamed from &lt;span style='font-family: Courier New '&gt;xMachineState&lt;/span&gt; to &lt;span style='font-family: Courier New '&gt;xMachineState_E2&lt;/span&gt; and is now passed to the pointer to the EEPROM using the &lt;span style='font-family: Courier New '&gt;ADR&lt;/span&gt; function.&lt;/p&gt;
&lt;p&gt;A new global variable has been created using the same name of the old EEPROM parameter, which was &lt;span style='font-family: Courier New '&gt;xMachineState&lt;/span&gt; and it is used as output of this function block, so that it will keep its value updated.&lt;/p&gt;
&lt;p&gt;Therefore, all the instances of the IEC code where the old EEPROM parameter &lt;span style='font-family: Courier New '&gt;xMachineState&lt;/span&gt; was used will not need to be changed, as the new global variable has the same name of the old EEPROM parameter.&lt;/p&gt;
&lt;p&gt;The working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt; has to be selected according to how the developer wants to manage the priorities between the IEC side and the BACnet side. Have a look at the &lt;i&gt;Woking Mode&lt;/i&gt; section above for further details.&lt;/p&gt;
&lt;p&gt;In this example, &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; is not connected because for the PV update the &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr&lt;/span&gt; function block is used. In case &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr&lt;/span&gt; is not used, you should connect a variable to &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; and set it to TRUE.&lt;/p&gt;
&lt;img src= bacnet_reldef_bv_link_xee.png  width= 800 &gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but xEE will still be written on the RelDef and passed to the xPV_current output.</descr>
					</var>
					<var name="ptrBV_BACnet" type="@BACNET_BINARY_VALUE">
						<descr>Binary Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_xEE" type="@BOOL">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
						<initValue>0</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="xPV_current" type="BOOL">
						<descr>BOOL Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_xNULL" type="BOOL"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="BV_Description" type="STRING" length="32">
						<descr>Binary Value Description</descr>
					</var>
					<var name="siEE" type="SINT">
						<descr>SINT value to be written in the Reliquish Default</descr>
					</var>
					<var name="dintRet" type="DINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xPV" type="BOOL">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="xEE" type="BOOL">
						<descr>BOOL Value to be written in RelinquishDefault. If iValue=32767, it is disabled and rValue is used instead.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
						<initValue>0</initValue>
					</var>
					<var name="xEE_old" type="BOOL"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="xPV_old" type="BOOL"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_BV_link_xEE											*
*																					*
* PURPOSE		: Set the present value of a Binary Value BACnet Object.			*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;		
 - bit 4: Priority Active (override from supervisor)						*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrBV_BACnet.Object_Type=BACnetObjectType#OBJECT_BINARY_VALUE AND NOT (ptrBV_BACnet=0) AND NOT (ptr_xEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		xEE_old:=NOT(@ptr_xEE);
		xPV_old:=@ptrBV_BACnet.Present_Value<>0;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrBV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrBV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrBV_BACnet.Description:=BV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		BV_Description := @ptrBV_BACnet.Description;
	END_IF;
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrBV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------

	xEE := @ptr_xEE;
	IF xEE THEN siEE := 1; ELSE siEE := 0; END_IF;
	
	IF xEE_old<>xEE THEN
		@ptrBV_BACnet.Relinquish_Default:=siEE;
		IF usiMode=1 OR usiMode=2 THEN
			FOR j_overr:=0 TO 15 DO
				@ptrBV_BACnet.Priority_Array[j_overr].choice_binary := BACnet_xNULL;
			END_FOR;
		END_IF;
	END_IF;	
	
	IF @ptrBV_BACnet.Relinquish_Default<>siEE AND NOT(usiMode=2) AND NOT(xOOS) THEN
		xRelMod:=TRUE;
	ELSE
		xRelMod:=FALSE;
	END_IF;	

	IF xRelMod THEN
		sysWriteRet:=sysWriteParBOOL(ptr_xEE,@ptrBV_BACnet.Relinquish_Default<>0);
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN dintRet := sysBACnet_BV_PresentValue(ptrBV_BACnet); END_IF;
	
	IF @ptrBV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		xPV:=xEE;
		xOOS:=TRUE;
	ELSE
		xPV:=@ptrBV_BACnet.Present_Value<>0;
		xOOS:=FALSE;
	END_IF;	

	IF xPV_old<>xPV AND usiMode=2 AND NOT(xOOS) THEN
		sysWriteRet:=sysWriteParBOOL(ptr_xEE,xPV);
		xEE_old:=xEE;
	END_IF;

	xEE_old:=@ptr_xEE;
	xPV_old:=xPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrBV_BACnet.Priority_Array[j_overr].choice_binary := BACnet_xNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;
	
// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
	IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF @ptrBV_BACnet.Priority_Array[j_Act].choice_binary<>BACnet_xNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;
	
// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	xPV_current:=xPV;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrBV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	xPV_current:=@ptr_xEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_iEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an INT Multi State Value BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link an INT EEPROM parameter to a BACnet Multi State Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Multi State Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (summed to) using the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_iEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Check the range limitations given by this setting before using this variant of the BACnet_RelDef_MV_link FBs Family.&lt;/b&gt; A &lt;u&gt;TO_UDINT conversion&lt;/u&gt; takes place before writing the INT number on the Relinquish.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the iPV_current output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the iPV_current has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the iPV_current will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the iPV_current output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the iPV_current.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_RelDef_MV_link_iEE&lt;/span&gt; FB.&lt;/p&gt;
&lt;p&gt;The purpose is to implement the BACnet protocol in an existing project where the operating mode of the machine is stored in an EEPROM parameter. This last one has been renamed from &lt;span style='font-family: Courier New '&gt;iSeasonMode&lt;/span&gt; to &lt;span style='font-family: Courier New '&gt;iSeasonMode_E2&lt;/span&gt; and is now passed to the pointer to the EEPROM using the &lt;span style='font-family: Courier New '&gt;ADR&lt;/span&gt; function. The &lt;span style='font-family: Courier New '&gt;iSeasonMode&lt;/span&gt; variable is an &lt;span style='font-family: Courier New '&gt;Enumerative&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;A new global variable has been created using the same name of the old EEPROM parameter, which was &lt;span style='font-family: Courier New '&gt;iSeasonMode&lt;/span&gt; and it is used as output of this function block, so that it will keep its value updated.&lt;/p&gt;
&lt;p&gt;Therefore, all the instances of the IEC code where the old EEPROM parameter &lt;span style='font-family: Courier New '&gt;iSeasonMode&lt;/span&gt; was used will not need to be changed, as the new global variable has the same name of the old EEPROM parameter.&lt;/p&gt;
&lt;p&gt;In this example, the value which will be written in case of wrong inputs (&lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt;) is 2, which corresponds to the  Auto  setting of the Season Mode.&lt;/p&gt;
&lt;p&gt;The working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt; has to be selected according to how the developer wants to manage the priorities between the IEC side and the BACnet side. Have a look at the &lt;i&gt;Woking Mode&lt;/i&gt; section above for further details.&lt;/p&gt;
&lt;p&gt;In this example, &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; is not connected because the &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr&lt;/span&gt; function block is used for the PV update. In case &lt;span style='font-family: Courier New '&gt;BACnet_PVUpdPr&lt;/span&gt; is not used, you should connect a variable to &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; and set it to TRUE.&lt;/p&gt;
&lt;img src= bacnet_reldef_mv_link_iee.png  width= 830 &gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but iEE will still be written on the RelDef and passed to the iPV_current output.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>Multi State Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_iEE" type="@INT">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT Offset that is summed to the EEPROM value.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
						<initValue>0</initValue>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
				</inputVars>
				<outputVars>
					<var name="iPV_current" type="INT">
						<descr>INT Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 3: BACnet not aligned with input value. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="diEE" type="DINT">
						<descr>DINT value to be written in the Reliquish Default</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="iRelinq_current_minus_Offset" type="INT">
						<descr>Scaled INT value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="iEE" type="INT">
						<descr>INT Value to be written in RelinquishDefault. If iValue=32767, it is disabled and rValue is used instead.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="udiPV_old" type="UDINT"/>
					<var name="iEE_old" type="INT"/>
					<var name="i_to_write" type="INT"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiRelDef" type="UDINT"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_iEE											*
*																					*
* PURPOSE		: Set the present value of a Multi State Value INT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_iEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		iEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;	
			
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	iEE := @ptr_iEE;
	diEE := TO_DINT(iEE)+TO_DINT(iOffset);

	// -------    diEE consistency check    ---------
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF iEE_old<>iEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			iRelinq_current_minus_Offset:=TO_INT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParINT(ptr_iEE,iRelinq_current_minus_Offset);
		ELSE
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;

	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	udiRelMax:=@ptrMV_BACnet.Number_Of_States;	
	
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			i_to_write:=TO_INT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParINT(ptr_iEE,i_to_write);
			iEE_old:=iEE;
		END_IF;
	END_IF;

	iEE_old:=@ptr_iEE;
	udiPV_old:=udiPV;

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrMV_BACnet.Priority_Array[j_Act].choice_integer)<>BACnet_udiNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------	
	IF NOT(inside_limits_flag) THEN
		iPV_current := iWrongLinkValue;
	ELSE
		iPV_current := TO_INT(udiPV);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
	
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 	
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;	

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	iPV_current:=@ptr_iEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_rEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of a REAL Multi State Value BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link a REAL EEPROM parameter to a BACnet Multi State Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Multi State Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (summed to) using the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_rEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Check the range limitations given by this setting before using this variant of the BACnet_RelDef_MV_link FBs Family.&lt;/b&gt; A &lt;u&gt;TO_UDINT conversion&lt;/u&gt; takes place before writing the REAL number on the Relinquish.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the rPV_current output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the rPV_current has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the rPV_current will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the rPV_current output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the rPV_current.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style='color:#990000;'&gt;The way this FB can be implemented is analoguous to how the BACnet_RelDef_MV_link_iEE function block has to be implemented. The only difference is that the pointed EEPROM parameter and the PV output will be REAL instead of INT. Refer to the BACnet_RelDef_MV_link_iEE description to see the example.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but rEE will still be written on the RelDef and passed to the rPV_current output.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>Multi State Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_rEE" type="@REAL">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT Offset that is summed to the EEPROM value.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="rPV_current" type="REAL">
						<descr>REAL Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 3: BACnet not aligned with input value. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="rEE_old" type="REAL">
						<descr>Last value of the iRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRelinq_current_minus_Offset" type="REAL">
						<descr>Scaled REAL value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="rEE" type="REAL">
						<descr>REAL Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="udiPV_old" type="UDINT"/>
					<var name="r_to_write" type="REAL"/>
					<var name="diEE" type="DINT"/>
					<var name="xOOS" type="BOOL"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="j_overr" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_rEE											*
*																					*
* PURPOSE		: Set the present value of a Multi State Value REAL BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_rEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		rEE_old:=0.0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;

	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	

	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
 			
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	rEE := @ptr_rEE;
	diEE := BACnet_r_ROUND_di(rEE) + TO_DINT(iOffset);

	// -------    diEE consistency check    ---------
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF rEE_old<>rEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			rRelinq_current_minus_Offset:=TO_REAL(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParREAL(ptr_rEE,rRelinq_current_minus_Offset);
		ELSE
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;
	
	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;

	udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			r_to_write:=TO_REAL(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParREAL(ptr_rEE,r_to_write);
			rEE_old:=rEE;
		END_IF;
	END_IF;

	rEE_old:=@ptr_rEE;
	udiPV_old:=udiPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrMV_BACnet.Priority_Array[j_Act].choice_integer)<>BACnet_udiNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------	
	IF NOT(inside_limits_flag) THEN
		rPV_current := TO_REAL(iWrongLinkValue);
	ELSE
		rPV_current := TO_REAL(udiPV);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
		
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;

	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;

ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	rPV_current:=@ptr_rEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_udiEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an UDINT Multi State Value BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link an UDINT EEPROM parameter to a BACnet Multi State Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Multi State Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (summed to) using the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_udiEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the udiPV_current output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the udiPV_current has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the udiPV_current will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the udiPV_current output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the udiPV_current.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;


&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style='color:#990000;'&gt;The way this FB can be implemented is analoguous to how the BACnet_RelDef_MV_link_iEE function block has to be implemented. The only difference is that the pointed EEPROM parameter and the PV output will be UDINT instead of INT. Refer to the BACnet_RelDef_MV_link_iEE description to see the example.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but udiEE will still be written on the RelDef and passed to the udiPV_current output.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>Multi State Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_udiEE" type="@UDINT">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT Offset that is summed to the EEPROM value.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="udiPV_current" type="UDINT">
						<descr>UDINT Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 3: BACnet not aligned with input value. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="udiEE_old" type="UDINT">
						<descr>Last value of the iRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="udiRelinq_current_minus_Offset" type="UDINT">
						<descr>Scaled UDINT value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="udiEE" type="UDINT">
						<descr>UDINT Value to be written in RelinquishDefault. If iValue=32767, it is disabled and rValue is used instead.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="udiPV_old" type="UDINT"/>
					<var name="udi_to_write" type="UDINT"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiEE_offs" type="UDINT"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_udiEE										*
*																					*
* PURPOSE		: Set the present value of a Multi State Value UDINT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_udiEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		udiEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
		
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;
	
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------			
	udiEE := @ptr_udiEE;
	udiEE_offs:= udiEE + TO_UDINT(iOffset);
	
	// -------    udiEE_offs consistency check    ---------
	IF (udiEE_offs<udiRelMin OR udiEE_offs>udiRelMax) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------

	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF udiEE_old<>udiEE THEN
			@ptrMV_BACnet.Relinquish_Default:=udiEE_offs;
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>udiEE_offs AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;
	
	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			udiRelinq_current_minus_Offset := TO_UDINT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParUDINT(ptr_udiEE,udiRelinq_current_minus_Offset);
		ELSE
			@ptrMV_BACnet.Relinquish_Default := udiEE_offs;
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;
	
	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(udiEE_offs);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;	

	udiRelMax:=@ptrMV_BACnet.Number_Of_States;	
		
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			udi_to_write:=TO_UDINT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParUDINT(ptr_udiEE,udi_to_write);
			udiEE_old:=udiEE;
		END_IF;
	END_IF;		

	udiEE_old:=@ptr_udiEE;
	udiPV_old:=udiPV;

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------	
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrMV_BACnet.Priority_Array[j_Act].choice_integer)<>BACnet_udiNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	IF NOT(inside_limits_flag) THEN
		udiPV_current := TO_UDINT(iWrongLinkValue);
	ELSE
		udiPV_current := udiPV;
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
		
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
 	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	udiPV_current:=@ptr_udiEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_uiEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an UINT Multi State Value BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link a UINT EEPROM parameter to a BACnet Multi State Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Multi State Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (summed to) using the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_uiEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the uiPV_current output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the uiPV_current has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the uiPV_current will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the uiPV_current output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the uiPV_current.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;


&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style='color:#990000;'&gt;The way this FB can be implemented is analoguous to how the BACnet_RelDef_MV_link_iEE function block has to be implemented. The only difference is that the pointed EEPROM parameter and the PV output will be UINT instead of INT. Refer to the BACnet_RelDef_MV_link_iEE description to see the example.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but uiEE will still be written on the RelDef and passed to the uiPV_current output.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>Multi State Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_uiEE" type="@UINT">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT Offset that is summed to the EEPROM value.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="uiPV_current" type="UINT">
						<descr>UINT Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 3: BACnet not aligned with input value. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="uiEE_old" type="UINT">
						<descr>Last value of the iRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="uiRelinq_current_minus_Offset" type="UINT">
						<descr>Scaled UINT value present in the Relinquish Default</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="uiEE" type="UINT">
						<descr>UINT Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="ui_to_write" type="UINT"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiPV" type="UDINT"/>
					<var name="udiPV_old" type="UDINT"/>
					<var name="diEE" type="DINT"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="xOOS" type="BOOL"/>
				</localVars>
				<localConsts>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_uiEE										*
*																					*
* PURPOSE		: Set the present value of a Multi State Value UINT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;	
 - bit 4: Priority Active (override from supervisor)					*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_uiEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		uiEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;

// --------------------    SERVICING    --------------------------------------------------------------------------		
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;

	xEn_old:=xEn;
		
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	uiEE := @ptr_uiEE;
	diEE := TO_DINT(uiEE)+TO_DINT(iOffset);

	// -------    diEE consistency check    ---------	
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF uiEE_old<>uiEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			uiRelinq_current_minus_Offset := TO_UINT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParUINT(ptr_uiEE,uiRelinq_current_minus_Offset);
		ELSE
			@ptrMV_BACnet.Relinquish_Default := TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;	

	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;

	udiRelMax:=@ptrMV_BACnet.Number_Of_States;

	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			ui_to_write:=TO_UINT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParUINT(ptr_uiEE,ui_to_write);
			uiEE_old:=uiEE;
		END_IF;
	END_IF;

	uiEE_old:=@ptr_uiEE;
	udiPV_old:=udiPV;
	
// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;
	
// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrMV_BACnet.Priority_Array[j_Act].choice_integer)<>BACnet_udiNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	IF NOT(inside_limits_flag) THEN
		uiPV_current := TO_UINT(iWrongLinkValue);
	ELSE
		uiPV_current := TO_UINT(udiPV);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;
		
// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;

	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	uiPV_current:=@ptr_uiEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_RelDef_MV_link_usiEE" version="3.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Set the present value of an USINT Multi State Value BACnet Object</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link an USINT EEPROM parameter to a BACnet Multi State Value Object.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where an EEPROM parameter has to be kept aligned with a BACnet Multi State Value.&lt;/p&gt;
&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;Relinquish_Default&lt;/span&gt; attribute of the BACnet Object to keep it synchronized with the EEPROM parameter, considered that it is scaled (summed to) using the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt; and re-scaled back when the PV is given as output of this FB.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are the BACnet Object address &lt;span style='font-family: Courier New '&gt;ptrMV_BACnet&lt;/span&gt;, the address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_usiEE&lt;/span&gt; and the working mode &lt;span style='font-family: Courier New '&gt;usiMode&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Working Mode&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The FB operation depends on the usiMode value. It can be:&lt;/p&gt;
&lt;b&gt;0&lt;/b&gt;: the EE parameter is linked to the RelDef and they get updated both ways (default) &lt;br&gt;
&lt;b&gt;1&lt;/b&gt;: as 0; in addition, when the EE parameter is changed from the PLC side, the PrArr is cleared (filled with null);&lt;br&gt;
&lt;b&gt;2&lt;/b&gt;: a change in PV updates the EE parameter; a change in the EE parameter originating from the PLC side updates the RelDef and the PrArr is cleared (filled with null); &lt;b&gt;&lt;span style='color:green;'&gt;This mode does not require to show necessarily the Present Value and the EE parameter on the HMI, but allows to show only the EE parameter&lt;/b&gt;&lt;/span&gt;, as the PV Is always equal to the EE parameter.&lt;span style='color:red;'&gt;&lt;b&gt; NOTE: only 100.000 value changes are guaranteed on each EEPROM location&lt;/span&gt;. The expected reliability of an EEPROM parameter has to be determined also based on the frequency with which BACnet supervisors write diverse values on the Priority Array.&lt;/b&gt;&lt;br&gt;
&lt;/p&gt;
&lt;table&gt;
  &lt;colgroup span= 5  class= columns &gt;&lt;/colgroup&gt;
  &lt;tr&gt;
    &lt;th&gt;usiMode&lt;/th&gt;
    &lt;th&gt;EE updated on variation of:&lt;/th&gt;
    &lt;th&gt; an EE variation updates:&lt;/th&gt;
    &lt;th&gt;PrArr is cleared on EE PLC side variation:&lt;/th&gt;
    &lt;th&gt;# val to show on HMI &lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;0&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;NO&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;RelDef&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt; YES, all&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;PV&lt;/td&gt;
    &lt;td&gt;RefDef&lt;/td&gt;
    &lt;td&gt;YES, all&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 1:&lt;/b&gt; consider the effect of your choice when selecting the Mode. This has an impact on the prioritization between the BACnet supervisor and the PLC (when an EE parameter is changed from the PLC/HMI).&lt;/font&gt;
&lt;p&gt;&lt;/p&gt;&lt;font size= 2 &gt;&lt;b&gt;Note 2:&lt;/b&gt;
  &lt;ul&gt;
  &lt;li&gt;If you use the FB link in &lt;b&gt;&lt;span style='color:green;'&gt;mode 2&lt;/b&gt;&lt;/span&gt;, it is not required to connect the usiPV_current output, as the EEPROM parameter will be always aligned with the PV and it is convenient to use directly the EEPROM parameter in the IEC code.&lt;/li&gt;
  &lt;p&gt;&lt;/p&gt;
  &lt;li&gt;If you use &lt;b&gt;&lt;span style='color:green;'&gt;mode 0&lt;/b&gt;&lt;/span&gt; or &lt;b&gt;&lt;span style='color:green;'&gt;mode 1&lt;/b&gt;&lt;/span&gt;, the usiPV_current has to be used in the IEC code. In this case, note that if the link FB is called in a background task, it can be possible that a timed task using the usiPV_current will receive a wrong value during the first executions, if the link FB instanced in the background task has not been executed yet for the first time. Therefore, if the link FB is called in a background task, it is important to initialize the global variable connected to the usiPV_current output in an init task, by setting it equal to the EEPROM parameter. If the link FB is called in a timed task instead, this initialization is not required, but it is important to run that task before the other timed tasks that use the usiPV_current.&lt;/li&gt;
  &lt;/ul&gt;
&lt;/font&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Priority Array Clear option On Demand&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;By changing the &lt;span style='font-family: Courier New '&gt;xPrArrClear_OD&lt;/span&gt; input from FALSE to TRUE, the Priority Array is cleared (filled with null values). This is a way to regain control over BACnet when requested. This can be useful in case the mode 0 is used and the user wants to restore the HMI local control.&lt;/p&gt;
&lt;p&gt;The input has to be manually reset to FALSE after each use of this functionality.&lt;/p&gt;



&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Present Value Update&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The present value update can be forced by setting &lt;span style='font-family: Courier New '&gt;xLocalPV_Upd&lt;/span&gt; to TRUE, which by default is set to FALSE.&lt;/p&gt;
&lt;p&gt;In case this option is set to FALSE or not configured (as in the implementation example below), the Present Value update &lt;b&gt;must&lt;/b&gt; be managed by using the &lt;font size= 2 &gt;&lt;b&gt;&lt;span style='color:#0070C0;'&gt; BACnet_PVUpdPr&lt;/span&gt;&lt;/b&gt;&lt;/font&gt; function block.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes and Reliability attribute&lt;/font&gt;&lt;/b&gt;&lt;br&gt;

&lt;p&gt;The value to be written on the PV must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;]. It is calculated by the summing the value of the local parameter to the &lt;span style='font-family: Courier New '&gt;iOffset&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;In case it is outside the allowed range, the &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; is written in place of it and the &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; attribute is set to &lt;span style='font-family: Courier New '&gt;RELIABILITY_UNRELIABLE_OTHER&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;span style='font-family: Courier New '&gt;Reliability&lt;/span&gt; is restored to &lt;span style='font-family: Courier New '&gt;RELIABILITY_NO_FAULT_DETECTED&lt;/span&gt; once the value to be written gets back into the limits.&lt;/p&gt;
&lt;p&gt;Note that &lt;span style='font-family: Courier New '&gt;iWrongLinkValue&lt;/span&gt; must be in the range [1 ... &lt;span style='font-family: Courier New '&gt;Number_Of_States&lt;/span&gt;].&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span style='color:#990000;'&gt;The way this FB can be implemented is analoguous to how the BACnet_RelDef_MV_link_iEE function block has to be implemented. The only difference is that the pointed EEPROM parameter and the PV output will be USINT instead of INT. Refer to the BACnet_RelDef_MV_link_iEE description to see the example.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="xEn" type="BOOL">
						<descr>Used to set the visibility of the BACnet Object. If xEn = FALSE, It will set Out_Of_Service to TRUE, but usiEE will still be written on the RelDef and passed to the usiPV_current output.</descr>
					</var>
					<var name="ptrMV_BACnet" type="@BACNET_MULTI_STATE_VALUE">
						<descr>Multi State Value Object Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_usiEE" type="@USINT">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="iOffset" type="INT">
						<descr>INT Offset that is summed to the EEPROM value.</descr>
					</var>
					<var name="iWrongLinkValue" type="INT">
						<descr>Value that is written on the Present Value in case of wrong input value (outside the allowed range of the object). Its value MUST be in the range 1 ... Number_Of_States.</descr>
					</var>
					<var name="xLocalPV_Upd" type="BOOL">
						<descr>Forces the local PV Update of the interested BACnet variable. By default, it is set to FALSE.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiMode" type="USINT">
						<descr>Mode 0: EE &lt;-&gt; RelDef. Mode 1: as 0 + Clear PrArr On Change from PLC. Mode 2: PV -&gt; EE, EE -&gt; RelDef + Clear PrArr On Change from PLC (max 100.000 writes on EE).</descr>
					</var>
					<var name="xPrArrClear_OD" type="BOOL">
						<descr>PrArr Clear On Demand. Only on transition FALSE -&gt; TRUE, it clears the Priority Array. It requires an external reset to FALSE.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="usiPV_current" type="USINT">
						<descr>USINT Present Value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 1: Out Of Service. Bit 2: Configuration Error. Bit 3: BACnet not aligned with input value. Bit 4: Priority Active (override from supervisor).</descr>
					</var>
					<var name="xPriorityActive" type="BOOL">
						<descr>It takes trace of eventual overrides from the Supervisor (which does it by writing in the PriorityArray).</descr>
					</var>
				</outputVars>
				<externalVars>
					<var name="BACnet_udiNULL" type="UDINT"/>
				</externalVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="xEn_old" type="BOOL">
						<descr>Records the xEn value of the previous execution.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="MV_Description" type="STRING" length="32">
						<descr>Multi State Value Description</descr>
					</var>
					<var name="usiEE_old" type="USINT">
						<descr>Last value of the usiRelinq</descr>
					</var>
					<var name="udintRet" type="UDINT">
						<descr>Output of the Present Value Update function.</descr>
					</var>
					<var name="xRelMod" type="BOOL">
						<descr>Flag that informs if the Relinquish has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="usiRelinq_current_minus_Offset" type="USINT">
						<descr>Scaled USINT value present in the Relinquish Default</descr>
					</var>
					<var name="udiPV" type="UDINT">
						<descr>Returns the Present Value</descr>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeRel_OutOfRange" type="BOOL">
						<descr>Flag to check if the Reliability field has still to be written once.</descr>
						<initValue>TRUE</initValue>
					</var>
					<var name="usiEE" type="USINT">
						<descr>USINT Value to be written in RelinquishDefault.</descr>
					</var>
					<var name="udiRelMax" type="UDINT">
						<descr>Higher limit for Relinquish Default in UDINT.</descr>
					</var>
					<var name="xActiveOne" type="BOOL">
						<descr>BOOL that states if the PriorityArray has been written also by other devices (TRUE if so).</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="j_Act" type="USINT">
						<descr>j-index of the PriorityArray scan.</descr>
					</var>
					<var name="udiPV_old" type="UDINT"/>
					<var name="xPrArrClear_OD_old" type="BOOL"/>
					<var name="diEE" type="DINT"/>
					<var name="xOOS" type="BOOL"/>
					<var name="j_overr" type="USINT"/>
					<var name="udiRelDef" type="UDINT"/>
					<var name="usi_to_write" type="USINT"/>
				</localVars>
				<localConsts>
					<const name="n_count_PrAct" type="USINT">
						<descr>Number of rows of the PriorityArray to be checked.</descr>
						<initValue>16</initValue>
					</const>
					<const name="udiRelMin" type="UDINT">
						<descr>Lower limit for Relinquish Default in UDINT.</descr>
						<initValue>1</initValue>
					</const>
				</localConsts>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_RelDef_MV_link_usiEE										*
*																					*
* PURPOSE		: Set the present value of a Multi State Value USINT BACnet Object.	*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	14-02-18 	Pierpaolo Armeli	First release 								*
* 2		26-02-18	Pierpaolo Armeli	wStatus not being restored to 16#1			*
* 3		04-05-18	Pierpaolo Armeli	Added new operat. modes & xPrClear option	*
* 4		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 1: the BACnet Object is Out Of Service;
 - bit 2: there is a configuration error;
 - bit 3: BACnet not aligned with input value;
 - bit 4: Priority Active (override from supervisor)						*)
 
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF @ptrMV_BACnet.Object_Type=BACnetObjectType#OBJECT_MULTI_STATE_VALUE AND NOT (ptrMV_BACnet=0) AND NOT (ptr_usiEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	
	IF NOT(runCheck) THEN
		usiEE_old:=0;
		udiPV_old:=@ptrMV_BACnet.Present_Value;
		xPrArrClear_OD_old:=xPrArrClear_OD;
	END_IF;
	
// --------------------    SERVICING    --------------------------------------------------------------------------	
	IF NOT(xEn) THEN // I put the BACnet Out Of Service if the function block is disabled
		@ptrMV_BACnet.Out_Of_Service:=TRUE;
		wStatus:=wStatus OR UINT#2#10;
	ELSIF (xEn AND NOT(xEn_old)) THEN // switching from FALSE to TRUE, I put it back in service and I restore the description
  		@ptrMV_BACnet.Out_Of_Service:=FALSE;
		IF runCheck THEN // description can be restored of if the code has been run at least once
			@ptrMV_BACnet.Description:=MV_Description;
		END_IF;
	END_IF;
	
	IF xEn OR NOT(runCheck) THEN // if in service, I copy the description in the memory
		MV_Description := @ptrMV_BACnet.Description;
	END_IF;	
	
	IF (xEn_old AND NOT(xEn)) OR (NOT(xEN) AND NOT(runCheck)) THEN // switching from TRUE to FALSE or if I'm in FALSE and at the first execution, I write "Disabled" as description
 		 @ptrMV_BACnet.Description:='Disabled';
	END_IF;
	
	xEn_old:=xEn;	
			
// --------------------    BACnet / PLC interactions    --------------------------------------------------------------------------	
	usiEE := @ptr_usiEE;
	diEE := TO_DINT(usiEE) + TO_DINT(iOffset);

	// -------    diEE consistency check    ---------
	IF (diEE<TO_DINT(udiRelMin) OR diEE>TO_DINT(udiRelMax)) THEN
		inside_limits_flag:=FALSE;
	ELSE
		inside_limits_flag:=TRUE;
	END_IF;
	// -------	
	
	IF NOT(inside_limits_flag) THEN // config error, iWrongLinkValue returned
		@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(iWrongLinkValue);
		IF writeRel_OutOfRange THEN
			@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER;
			writeRel_OutOfRange:=FALSE;
		END_IF;
		wStatus:=wStatus OR UINT#2#1000;
	ELSE
		// I write on the Relinquish_Default, only on variation
		IF usiEE_old<>usiEE THEN
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
			IF usiMode=1 OR usiMode=2 THEN
				FOR j_overr:=0 TO 15 DO
					@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
				END_FOR;
			END_IF;
		END_IF;	
		
		udiRelDef:=@ptrMV_BACnet.Relinquish_Default;
		IF udiRelDef<>TO_UDINT(diEE) AND NOT(usiMode=2) AND NOT(xOOS) THEN
			xRelMod:=TRUE;
		ELSE
			xRelMod:=FALSE;
		END_IF;
		
		writeRel_OutOfRange:=TRUE;
		wStatus:=wStatus AND NOT(UINT#2#1000);
	END_IF;

	IF xRelMod THEN
		IF udiRelDef>=udiRelMin AND udiRelDef<=udiRelMax THEN
			usiRelinq_current_minus_Offset:=TO_USINT(TO_DINT(udiRelDef)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParUSINT(ptr_usiEE,usiRelinq_current_minus_Offset);
		ELSE
			@ptrMV_BACnet.Relinquish_Default:=TO_UDINT(diEE);
		END_IF;
	END_IF;

	IF xLocalPV_Upd  OR NOT(runCheck)	THEN udintRet := sysBACnet_MV_PresentValue(ptrMV_BACnet); END_IF;

	IF @ptrMV_BACnet.Out_Of_Service=TRUE THEN // if OOS, I write what I would have passed from IEC side
		udiPV:=TO_UDINT(diEE);
		xOOS:=TRUE;
	ELSE
		udiPV:= @ptrMV_BACnet.Present_Value; // output updated based on the present value
		xOOS:=FALSE;
	END_IF;
	
	udiRelMax:=@ptrMV_BACnet.Number_Of_States;
	
	IF udiPV_old<>udiPV AND usiMode=2 AND NOT(xOOS) THEN
		IF udiPV>=udiRelMin AND udiPV<=udiRelMax THEN
			usi_to_write:=TO_USINT(TO_DINT(@ptrMV_BACnet.Present_Value)-TO_DINT(iOffset));
			sysWriteRet:=sysWriteParUSINT(ptr_usiEE,usi_to_write);
			usiEE_old:=usiEE;
		END_IF;
	END_IF;

	usiEE_old:=@ptr_usiEE;
	udiPV_old:=udiPV;	

// --------------------    PrArr Clear On Demand    --------------------------------------------------------------------------
	IF xPrArrClear_OD AND NOT(xPrArrClear_OD_old) THEN
		FOR j_overr:=0 TO 15 DO
			@ptrMV_BACnet.Priority_Array[j_overr].choice_integer := BACnet_udiNULL;
		END_FOR;
	END_IF;
	xPrArrClear_OD_old:=xPrArrClear_OD;

// --------------------    xPriorityActive calculation    --------------------------------------------------------------------------
IF j_Act=0 THEN
		xPriorityActive:=xActiveOne;
		xActiveOne:=FALSE;
	END_IF;
	
	IF (@ptrMV_BACnet.Priority_Array[j_Act].choice_integer)<>BACnet_udiNULL THEN
		xActiveOne:=TRUE;
	END_IF;
				
	j_Act:=(j_Act+1) MOD n_count_PrAct;

// --------------------    FB Output Calc    --------------------------------------------------------------------------		
	IF NOT(inside_limits_flag) THEN
		usiPV_current := TO_USINT(iWrongLinkValue);
	ELSE
		usiPV_current := TO_USINT(udiPV);
	END_IF;
	
	// I restore NO FAULT if I'm in error on the Reliability field and I'm back in the limits
	IF @ptrMV_BACnet.Reliability=BACnetReliability#RELIABILITY_UNRELIABLE_OTHER AND inside_limits_flag THEN
		@ptrMV_BACnet.Reliability:=BACnetReliability#RELIABILITY_NO_FAULT_DETECTED;
	END_IF;

// --------------------    wStatus Update    --------------------------------------------------------------------------	
	IF NOT(@ptrMV_BACnet.Out_Of_Service) THEN
		wStatus:=wStatus OR UINT#2#1;
 		wStatus:=wStatus AND NOT(UINT#2#10);
 	END_IF;
 
 	IF xPriorityActive THEN
		wStatus:=wStatus OR UINT#2#10000;
	ELSE
		wStatus:=wStatus AND NOT(UINT#2#10000);
	END_IF;
 	
ELSE // BACnet Object not configured properly
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	usiPV_current:=@ptr_usiEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
		</functionBlock>
		<functionBlock name="BACnet_udiValue_link_rEE" version="1.0.1" hidden="true" creationDate="0" lastModifiedDate="0">
			<title>Link a REAL EEPROM parameter to the value of an UDINT BACnet attribute</title>
			<descr>&lt;HTML&gt;&lt;b&gt;&lt;font size= 3 &gt;General description&lt;/font&gt;&lt;/b&gt;
&lt;p&gt;This function block allows to link a REAL EEPROM parameter to the value of an UDINT BACnet attribute.&lt;/p&gt;
&lt;p&gt;It can be used to implement BACnet in either new or existing projects, where you would like to keep a BACnet UDINT attribute aligned with a REAL EEPROM parameter.&lt;/p&gt;

&lt;p&gt;The FB writes and reads the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt; of a BACnet Object to keep it synchronized with the EEPROM parameter. No scaler is used.&lt;/p&gt;
&lt;p&gt;The main inputs of this FB are:
  &lt;ul&gt;
  &lt;li&gt;The UDINT value address &lt;span style='font-family: Courier New '&gt;ptrBACnet_udiAttribute&lt;/span&gt;. This is not the address of the BACnet Object, but the address of a specific attribute of it.&lt;/li&gt;
  &lt;li&gt;The address of the EEPROM parameter &lt;span style='font-family: Courier New '&gt;ptr_rEE&lt;/span&gt;.&lt;/li&gt;
  &lt;/ul&gt;

This FB can either be called in background or in timed, depending on the requirements of your application. Note that until its first execution, the value of the attribute (e.g. a Schedule Default) will not be correctly aligned. Therefore, in case you use the attribute in a timed task it is important either:
  &lt;ul&gt;
  &lt;li&gt;to call an instance of the FB also in the Init task, when it is called in a background task;&lt;/li&gt;
  &lt;li&gt;if the FB is called in a timed task, this has to be set before the other timed tasks which use the linked attribute.&lt;/li&gt;
  &lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;&lt;b&gt;&lt;font size= 3 &gt;Out-of-range writes&lt;/font&gt;&lt;/b&gt;&lt;br&gt;
&lt;p&gt;The inputs &lt;span style='font-family: Courier New '&gt;rRelMin&lt;/span&gt; and &lt;span style='font-family: Courier New '&gt;rRelMax&lt;/span&gt; allow to limit the value that the EEPROM parameter can assume and will be used to saturate the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt; in case the limits are exceeded. This avoids out-of-range writes from the supervisor side.&lt;/p&gt;
&lt;p&gt;In case of an out-of-range write from the supervisor on the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt;, this write will not be accepted (the EEPROM does not get updated with the written value) and the value which is present in the EEPROM will be restored on the &lt;span style='font-family: Courier New '&gt;attribute value&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;font size= 3 &gt;FB Implementation Example&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The following image shows an example of implementation of the &lt;span style='font-family: Courier New '&gt;BACnet_udiValue_link_rEE&lt;/span&gt; FB.&lt;/p&gt;
&lt;p&gt;The purpose is to link the &lt;span style='font-family: Courier New '&gt;rSetpoint_DefSch&lt;/span&gt; EEPROM parameter to the &lt;span style='font-family: Courier New '&gt;Schedule_Default&lt;/span&gt; value of the &lt;span style='font-family: Courier New '&gt;Sc_Setpoint_REAL_Schedule&lt;/span&gt; Schedule BACnet Object.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Note that this function block can be used for any type of BACnet Object.&lt;/b&gt;&lt;/p&gt;
&lt;img src= BACnet_udiValue_link_rEE.png  width= 670 &gt;

&lt;p&gt;&lt;/p&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Publisher:&lt;/b&gt;&lt;/span&gt; HVAC Solution Center, Alpago (BL) - Italy&lt;br&gt;
&lt;b&gt;&lt;span style='color:green;'&gt;Authors:&lt;/b&gt;&lt;/span&gt; Federico Marcassa, Pierpaolo Armeli&lt;br&gt;</descr>
			<vars>
				<inputVars>
					<var name="ptr_BACnet_udiAttribute" type="@UDINT">
						<descr>UDINT Attribute Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="ptr_rEE" type="@REAL">
						<descr>EEPROM Parameter Address (use ADR function)</descr>
						<initValue>0</initValue>
					</var>
					<var name="rRelMin" type="REAL">
						<descr>Lower limit for attribute value in REAL.</descr>
					</var>
					<var name="rRelMax" type="REAL">
						<descr>Higher limit for attribute value in REAL.</descr>
					</var>
				</inputVars>
				<outputVars>
					<var name="rValue" type="REAL">
						<descr>REAL attribute value</descr>
					</var>
					<var name="wStatus" type="WORD">
						<descr>Bit 0: OK (IEC code operating properly). Bit 2: Configuration Error.</descr>
					</var>
				</outputVars>
				<localVars>
					<var name="runCheck" type="BOOL">
						<descr>Checks if the code has been executed at least once.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="writeFlag" type="USINT">
						<descr>Takes trace of the last type of write operation on the attribute value.</descr>
						<initValue>0</initValue>
					</var>
					<var name="rRel_to_write" type="REAL">
						<descr>REAL value to be written on the attribute.</descr>
					</var>
					<var name="xModified" type="BOOL">
						<descr>Flag that informs if the attribute has been modified BACnet side.</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="sysWriteRet" type="BOOL">
						<descr>Value returned by the sysWrite function</descr>
					</var>
					<var name="inside_limits_flag" type="BOOL">
						<descr>Flag that states if the variable is inside the Min and Max limits</descr>
						<initValue>FALSE</initValue>
					</var>
					<var name="rRel_to_write_old" type="REAL"/>
					<var name="rWritten" type="REAL"/>
					<var name="rReadVal" type="REAL"/>
				</localVars>
			</vars>
			<iecDeclaration active="FALSE"/>
			<interfaces/>
			<methods/>
			<sourceCode type="ST">
				<![CDATA[(************************************************************************************
*	  																				*
*				SCHNEIDER ELECTRIC CONFIDENTIAL & PROPRIETARY						*
*																					*
*************************************************************************************
* THIS WORK CONTAINS VALUABLE CONFIDENTIAL AND PROPRIETARY INFORMATION:				*
* DISCLOSURE; USE OR REPRODUCTION OUTSIDE OF SCHNEIDER ELECTRIC AUTOMATION GMBH		*
* IS PROHIBITED EXCEPT AS AUTHORIZED IN WRITING. THIS UNPUBLISHED WORK IS			*
* PROTECTED BY THE LAWS OF THE UNITED STATES AND OTHER COUNTRIES. IN THE EVENT		*
* OF PUBLICATION THE FOLLOWING NOTICE SHALL APPLY:									*
*																					*
* "COPYRIGHT 2018 SCHNEIDER ELECTRIC AUTOMATION GMBH								*
* ALL RIGHTS RESERVED."																*
*************************************************************************************
*************************************************************************************
* APPLICATION	: HVAC&R															*
* MODULE		: BACnet_Addons														*
*************************************************************************************
* FUNCT/FB NAME : BACnet_udiValue_link_rEE											*
*																					*
* PURPOSE		: Link a REAL EEPROM parameter to the value of an					*
*		   	   	  UDINT BACnet attribute 											*
*																					*
* PARAMETER		: See Function/FB description										*
* INPUT			: See Function/FB description										*
* OUTPUT		: See Function/FB description										*
*																					*
*************************************************************************************
* REVISION HISTORY: 												 				*
* 												 									*
* Rev  	Date	  	Programmer			Comment 									*
* --------------------------------------------------------------------------------- *
* 1  	28-02-18 	Pierpaolo Armeli	First release 								*
* 2		17-05-18	Pierpaolo Armeli	Bug fix regarding init procedure			*
* 												 									*
*************************************************************************************)

(* initializes the wStatus output variable
The output variable is made of 16 bits, with the following meaning:
 - bit 0: all the config and execution is OK;
 - bit 2: there is a configuration error;
*)
IF NOT(runCheck) THEN
	wStatus:=UINT#2#0;
END_IF;

IF NOT (ptr_BACnet_udiAttribute=0) AND NOT (ptr_rEE=0) THEN
	wStatus:=wStatus AND NOT(UINT#2#100);
	wStatus:=wStatus OR UINT#2#1;

	rRel_to_write := @ptr_rEE;
		
	// I write on the BACnet attribute
	IF rRel_to_write_old<>rRel_to_write OR NOT(runCheck) THEN
		writeFlag:=1;
		rWritten:=BACnet_UdAsReal_write(ptr_BACnet_udiAttribute,rRel_to_write,TRUE);
	END_IF;	
	
	rReadVal:=BACnet_UdAsReal_read(ptr_BACnet_udiAttribute);
	
	IF rReadVal<>rRel_to_write AND NOT(runCheck) THEN
		xModified:=TRUE;
	ELSE
		xModified:=FALSE;
	END_IF;
	
	rRel_to_write_old:=rRel_to_write;
	
	IF rReadVal<rRelMin THEN // I saturate rValue with Min and Max in the Out of Range case
		rValue:=rRelMin;
		inside_limits_flag:=FALSE;
	ELSIF rReadVal>rRelMax THEN
		rValue := rRelMax;
		inside_limits_flag:=FALSE;
	ELSE
		rValue:=rReadVal;
		inside_limits_flag:=TRUE;
	END_IF;
	
	IF xModified THEN
		IF rReadVal>rRelMin AND rReadVal<rRelMax THEN
			sysWriteRet:=sysWriteParREAL(ptr_rEE,rReadVal);
		ELSE
			rWritten:=BACnet_UdAsReal_write(ptr_BACnet_udiAttribute,rRel_to_write,TRUE);
		END_IF;
	END_IF;
	
ELSE // FB not configured properly
	writeFlag := 0;	
	wStatus:=wStatus OR UINT#2#100;
	wStatus:=wStatus AND NOT(UINT#2#1);
	rValue:=@ptr_rEE;
END_IF;

runCheck:=TRUE;
]]>
			</sourceCode>
			<images>
				<image name="bacnet_udivalue_link_ree.png" width="733" height="136">
					<![CDATA[iVBORw0KGgoAAAANSUhEUgAAAt0AAACICAIAAAHDjvBeAAAAAXNSR0IArs4c6QAAAARnQU1B
AACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAACydSURBVHhe7V07TuTO1/VWyFhAJ4gN
EP6CCTvugFXQK0Aj/aVJkEhIEdGQkYxERE7wkU8yi+C7r3r60W637fbjHB2a6nr7VtWt6+py
ufgGSpiuUF6/v6+u7snxdX8l33fEotiRZ1FQtb/I37l7xlBC+d/v/wt8eLko7vxXizFhjCKU
lBbDIQvti5Z7J7BQ/v41FsWdd8fcbP5kPsr9u3O/WwTfmbMqxtQIHlkodavr4o5qQp3rxwP7
kONWgoriJ4Xyp3ha6O6DU5VouXdCIpReqMiqGJNC//vvP41GyEL7ouXeCR2HT1aDmG0ijCmU
rM1i1inpU4VSXL5c76ljd9ejF5cvNCgoIeVzRzmIW/imOZPnRfFIX51/LW9vqBoUjWNq5nTZ
QQpPz9viFzn2mzse70/PQwmlTIvRGlnyvmi5dwILRQVJbfL+9/tpe7ffsDj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>
		</functionBlock>
	</functionBlocks>
	<programs/>
	<macros/>
	<structs/>
	<typedefs/>
	<enums/>
	<subranges/>
	<interfaces/>
</lib>