<root>
<document scada='0' schema='102' license='1,James Hill,UT1N03' title='' description='' fcversion='524800' target='RPI.RPI.RPI1+' >
	<config data='' clkspd='76800000' simspd='1' usewdt='0' constif='0' SSH_IP='01652BBCDF86326BDB50D9E49E95D4CF' SSH_Sudo='1' Use3V3='0' />
	<plugins >
		<dll_models enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<traces />
	<ghost >
		<FK2 >
			<data name='FK2D0' port='4294967295' pin='4294967295' />
			<data name='FK2D1' port='4294967295' pin='4294967295' />
			<data name='FK2D2' port='4294967295' pin='4294967295' />
			<data name='FK2D3' port='4294967295' pin='4294967295' />
			<data name='FK2D4' port='4294967295' pin='4294967295' />
			<data name='FK2D5' port='4294967295' pin='4294967295' />
			<data name='FK2D6' port='4294967295' pin='4294967295' />
			<data name='FK2D7' port='4294967295' pin='4294967295' />
			<data name='FK2D8' port='4294967295' pin='4294967295' />
			<data name='FK2D9' port='4294967295' pin='4294967295' />
			<data name='FK2D10' port='4294967295' pin='4294967295' />
			<data name='FK2D11' port='4294967295' pin='4294967295' />
			<data name='FK2D12' port='4294967295' pin='4294967295' />
			<data name='FK2D13' port='4294967295' pin='4294967295' />
			<data name='FK2D14' port='4294967295' pin='4294967295' />
			<data name='FK2D15' port='4294967295' pin='4294967295' />
			<data name='FK2A0' port='4294967295' pin='4294967295' />
			<data name='FK2A1' port='4294967295' pin='4294967295' />
			<data name='FK2A2' port='4294967295' pin='4294967295' />
			<data name='FK2A3' port='4294967295' pin='4294967295' />
			<data name='FK2A4' port='4294967295' pin='4294967295' />
			<data name='FK2A5' port='4294967295' pin='4294967295' />
		</FK2>
		<ICD >
			<data name='AnalogPrescaleValue' value='19' />
			<data name='DigitalSampleRate' value='100000' />
			<data name='BreakpointCount' value='8' />
			<data name='CallStackDepthCount' value='8' />
			<data name='ClockPort' value='6' />
			<data name='ClockPin' value='26' />
			<data name='DataPort' value='6' />
			<data name='DataPin' value='16' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='14' />
			<data name='CalculatedCommsDelay' value='14' />
			<data name='AnalogEB2PrescaleValue' value='2' />
			<data name='DigitalEB2SampleRate' value='100000' />
		</ICD>
		<pins >
			<digital A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
			<analog A='0' B='0' C='0' D='0' E='0' F='0' G='0' H='0' I='0' J='0' K='0' L='0' M='0' N='0' O='0' P='0' Q='0' R='0' S='0' T='0' U='0' V='0' W='0' X='0' Y='0' Z='0' />
		</pins>
	</ghost>
	<components >
		<settings autoimg='1' center='1' unitscale='0' fixedscale='0' fixedx='1' fixedy='1' fixedz='1' headcode='0' />
		<definition guid='f533d40a-1b58-4080-b8eb-99412d9c9b4e' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='1' scadaCompatible='0' embeddedCompatible='1' iconpath='' />
		<component class_type='root' codename='panel' x='0' y='0' z='0' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='printstring' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='20' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='false' type='b1' description='' isconst='1' isinit='1' usrinit='0' setinit='0' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='SPIbuffer' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='10' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='OK' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='true' type='b1' description='' isconst='1' isinit='1' usrinit='1' setinit='1' />
				</variable>
			</variables>
			<macros >
				<macro >
					<flowline name='ConfigureMQTT' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='State' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
					</flowline>
				</macro>
				<macro >
					<flowline name='ServiceMQTT' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='Counter' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Exit' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='MessageSize' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Payload' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='64' />
						</local>
						<local name='State' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='Topic' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='64' />
						</local>
						<local name='Value' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='updateflag' type='b1' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
					</flowline>
				</macro>
				<macro >
					<flowline name='PrintLastError' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='ErrorCode' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='ErrorText' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='32' />
						</local>
					</flowline>
				</macro>
				<macro >
					<flowline name='Servicei2c' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
					</flowline>
				</macro>
				<macro >
					<flowline name='serviceSPI_ADC' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='spibuffer' type='u8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='10' />
						</local>
						<local name='ok' type='b1' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<local name='printstring' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
							<array size='20' />
						</local>
					</flowline>
				</macro>
				<macro >
					<flowline name='configuredio' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
					</flowline>
				</macro>
				<macro >
					<flowline name='Main' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<local name='printstring' type='u32' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='cal_spi1' macro='Master_Init' />
						<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='OK = 1' swap='0' >
							<flowline >
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
									<argument exp='&quot;SPI init OK&quot;' />
								</command>
								<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
									<exp exp='SPIbuffer[0] = 0x06' />
									<exp exp='SPIbuffer[1] = 0x00' />
									<exp exp='SPIbuffer[2] = 0x00' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
									<argument exp='&quot;Start read...&quot;' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='cal_spi1' macro='Master_Enable_CS' />
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='cal_spi1' macro='Master_Transaction' >
									<return exp='OK' />
									<argument exp='SPIbuffer' />
									<argument exp='3' />
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='cal_spi1' macro='Master_Disable_CS' />
								<command class_type='delay' title='Delay' cmdcolor='12632064' cmdcolor_sec='16769676' exp='100' type='1' />
								<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='ok = 1' swap='0' >
									<flowline >
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
											<argument exp='&quot;OK&quot;' />
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='printstring = ToString$ (SPIbuffer[0])' />
										</command>
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
											<argument exp='printstring' />
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='printstring = ToString$ (SPIbuffer[1])' />
										</command>
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
											<argument exp='printstring' />
										</command>
										<command class_type='calculation' title='Calculation' cmdcolor='16760919' cmdcolor_sec='16760832' >
											<exp exp='printstring = ToString$ (SPIbuffer[2])' />
										</command>
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
											<argument exp='printstring' />
										</command>
									</flowline>
									<flowline >
										<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
											<argument exp='&quot;Fail&quot;' />
										</command>
									</flowline>
								</command>
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='cal_spi1' macro='Master_Uninit' />
							</flowline>
							<flowline >
								<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='DebugPrint1' macro='println' >
									<argument exp='&quot;SPI Init Fail&quot;' />
								</command>
							</flowline>
						</command>
						<command class_type='loop' title='Loop' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='1' >
							<flowline />
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='459c9cfb-82e3-40ad-9456-54fc40ba5e6c' vmin='1' vmaj='1' codename='MQTT_Client1' x='-30' y='0' z='0' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='HOST' data='192.168.100.108' />
					<value target='PORT' data='1883' />
					<value target='CLIENT' data='Flowcode' />
					<value target='TIMEOUT' data='100' />
					<value target='KEEP_ALIVE' data='20' />
					<value target='NETWORK_COMPONENT' data='NetworkComms1' />
					<value target='AUTHENTICATION' data='001' />
					<value target='NAME' data='emonpi' />
					<value target='PASSWORD' data='emonpimqtt2016' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='a1da060c-e74a-4e12-bb90-3ddb43265592' vmin='0' vmaj='1' codename='DebugPrint1' x='-30' y='30' z='0' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
				<resources />
				<properties />
				<values />
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='0341d84f-f7fd-473c-8076-b38b2d563e13' vmin='9' vmaj='1' codename='TCP_IP_Pi1' x='-10' y='-40' z='0' xsz='66' ysz='34' zsz='7.5' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='label' data='RPi TCP/IP' />
					<value target='RemapIndex' data='1' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='91049bf5-2436-42dc-947a-c30c86463d98' vmin='2' vmaj='1' codename='NetworkComms1' x='0' y='0' z='0' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='0' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Component' data='TCP_IP_Pi1' />
					<value target='RemapIndex' data='1' />
					<value target='Status' data='Supported' />
					<value target='Sim' data='0' />
					<value target='SimControl' data='000' />
					<value target='NetworkInterface' data='' />
					<value target='IPAddress' data='192.168.100.114' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='ed3a5141-43bb-43e0-86b0-2243fd1147ca' vmin='0' vmaj='2' codename='cal_i2c1' x='80' y='10' z='10.27' xsz='20' ysz='20' zsz='20' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='ENABLED' data='1' />
					<value target='REF' data='1' />
					<value target='CHANNEL' data='001' />
					<value target='Mode' data='000' />
					<value target='SDA' data='$PORTG.2' />
					<value target='SDAPins' data='000' />
					<value target='SCL' data='$PORTG.3' />
					<value target='SCLPins' data='001' />
					<value target='StopDel' data='1' />
					<value target='BAUD_LIST' data='002' />
					<value target='BAUD' data='400000' />
					<value target='SRC' data='000' />
					<value target='SMB' data='001' />
					<value target='ClockStretching' data='1' />
					<value target='BMODE' data='2' />
					<value target='SDA_PORT' data='$PORTG.2' />
					<value target='SDA_TRIS' data='$PORTG.2' />
					<value target='SDA_PIN' data='2' />
					<value target='SCL_PORT' data='$PORTG.3' />
					<value target='SCL_TRIS' data='$PORTG.3' />
					<value target='SCL_PIN' data='3' />
					<value target='MASTER' data='1' />
					<value target='ScopeTraces' data='1' />
					<value target='ConsoleData' data='1' />
					<value target='Injector' data='000' />
					<value target='InjectorHandle' data='0' />
					<value target='REMAPPABLE' data='' />
					<value target='SDABank' data='b' />
					<value target='SDABank2' data='c' />
					<value target='SCLBank' data='b' />
					<value target='SCLBank2' data='c' />
					<value target='SDARPNUM' data='21' />
					<value target='SCLRPNUM' data='20' />
					<value target='SDARPREG' data='SSP1DATPPS' />
					<value target='SCLRPREG' data='SSP1CLKPPS' />
					<value target='SDAREG' data='000' />
					<value target='SCLREG' data='001' />
					<value target='Sim' data='1' />
					<value target='ParentName' data='' />
					<value target='BitDelay' data='2' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='c67171df-0ad6-4b11-8361-cfe14b072847' vmin='1' vmaj='2' codename='cal_spi1' x='0' y='0' z='0' xsz='20' ysz='20' zsz='20' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' scadavisible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='ENABLED' data='1' />
					<value target='REF' data='1' />
					<value target='CHANNEL' data='001' />
					<value target='MOSI' data='$PORTG.10' />
					<value target='MOSIPins' data='008' />
					<value target='MISO' data='$PORTG.9' />
					<value target='MISOPins' data='013' />
					<value target='CLK' data='$PORTG.11' />
					<value target='CLKPins' data='004' />
					<value target='UseAutoCS' data='1' />
					<value target='UseCS' data='0' />
					<value target='SS' data='$PORTG.8' />
					<value target='SSPins' data='000' />
					<value target='AltSSPin' data='0' />
					<value target='Mode' data='000' />
					<value target='PR_SCALE' data='004' />
					<value target='CKE' data='001' />
					<value target='CKP' data='000' />
					<value target='SMP' data='000' />
					<value target='ScopeTraces' data='1' />
					<value target='ConsoleData' data='1' />
					<value target='Injector' data='000' />
					<value target='InjectorHandle' data='0' />
					<value target='BMODE' data='2' />
					<value target='MOSI_PORT' data='$PORTG.10' />
					<value target='MOSI_TRIS' data='$PORTG.10' />
					<value target='MOSI_PIN' data='10' />
					<value target='MISO_PORT' data='$PORTG.9' />
					<value target='MISO_TRIS' data='$PORTG.9' />
					<value target='MISO_PIN' data='9' />
					<value target='SCK_PORT' data='$PORTG.11' />
					<value target='SCK_TRIS' data='$PORTG.11' />
					<value target='SCK_PIN' data='11' />
					<value target='SS_PORT' data='$PORTG.8' />
					<value target='SS_TRIS' data='$PORTG.8' />
					<value target='SS_PIN' data='8' />
					<value target='Remappable' data='' />
					<value target='MOSIReg' data='008' />
					<value target='CLKREG' data='004' />
					<value target='MOSIRPNUM' data='21' />
					<value target='MOSIBank' data='b' />
					<value target='MOSIBank2' data='c' />
					<value target='CLKRPNUM' data='20' />
					<value target='CLKBank' data='b' />
					<value target='MISORPREG' data='SSP1DATPPS' />
					<value target='MISOBank' data='b' />
					<value target='SPIName' data='' />
					<value target='MISOReg' data='000' />
					<value target='SPIClock' data='' />
					<value target='MISOBank2' data='c' />
					<value target='CLKBank2' data='c' />
					<value target='ParentName' data='' />
					<value target='BitDelay' data='0' />
					<value target='ClockSpeed' data='76800000' />
					<value target='MasterDivider' data='8' />
					<value target='Sim' data='1' />
					<value target='CLKRPREG' data='' />
					<value target='SSRPREG' data='' />
					<value target='SSBank' data='' />
					<value target='SSBank2' data='' />
					<value target='AltSSReg' data='' />
					<value target='AltSSMask' data='0' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<scadaresourcelookup />
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' >
		<background rgb='2105930' img='' style='0' />
		<camera xe='-0.125999' ye='-4.59305' ze='667.546' xt='-0.125999' yt='-4.59305' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='0' perspective='1' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<camera xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey0 xe='0' ye='0' ze='300' xt='0' yt='0' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
		<camerakey1 xe='-3.67394e-14' ye='0' ze='-300' xt='0' yt='0' zt='0' xquat='0' yquat='1' zquat='0' wquat='6.12323e-17' />
		<camerakey2 xe='0' ye='-300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.707107' yquat='0' zquat='0' wquat='0.707107' />
		<camerakey3 xe='-3.67394e-14' ye='300' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-4.32978e-17' yquat='0.707107' zquat='0.707107' wquat='4.32978e-17' />
		<camerakey4 xe='-300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='0.5' zquat='0.5' wquat='0.5' />
		<camerakey5 xe='300' ye='-6.66134e-14' ze='6.66134e-14' xt='0' yt='0' zt='0' xquat='-0.5' yquat='-0.5' zquat='-0.5' wquat='0.5' />
		<camerakey6 xe='-173.205' ye='-173.205' ze='173.205' xt='0' yt='0' zt='0' xquat='-0.424708' yquat='0.17592' zquat='0.339851' wquat='0.820473' />
	</panel3d>
	<layout >
		<view type='0' name='Main' mode='0' placement='LAAAAAAAAAABAAAA---------------------wUAAAAYAAAAQAoAACwDAAA' zoom='75' scrollx='0' scrolly='50' flags='0' />
	</layout>
</document>
</root>
