<root>
<document schema='101' license='1,,*****' title='' description='' target='PIC16.24F.24FJ256GA106' >
	<config data='!0,ffff!10,ba9d!20,3f7f%0,1%1,1%2,1%3,1%4,1%5,1%6,1%7,1%8,1%9,f%d,1%e,1%f,1%10,1%12,1%13,1%14,1%15,0%16,2%18,2%1b,7%1f,1%20,f%24,1%25,1%26,1%27,0%28,3%2a,1%2b,1%2c,1%2d,1%2e,0%2f,0' clkspd='18432000' simspd='6' usewdt='0' constif='0' />
	<plugins >
		<dll_dbg_icd enabled='0' >
			<data name='debug' value='1' />
			<data name='userpins' value='0' />
			<data name='speed' value='0' />
			<data name='usev9' value='0' />
			<data name='breaks' value='8' />
			<data name='stacks' value='8' />
			<data name='clkport' value='1' />
			<data name='clkbit' value='6' />
			<data name='dataport' value='1' />
			<data name='databit' value='7' />
			<data name='ghostype' value='0' />
			<data name='monitor' value='1' />
			<data name='ictloop' value='0' />
			<data name='ictrate' value='20000' />
			<data name='ictmask' value='0' />
			<data name='anlpres' value='19' />
			<data name='digmask1' value='-1' />
			<data name='digmask2' value='-1' />
		</dll_dbg_icd>
		<dll_models enabled='1' />
		<dll_upgrader enabled='1' />
	</plugins>
	<supplement use='0' head='' body='' />
	<debug />
	<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='1' />
			<data name='ClockPin' value='6' />
			<data name='DataPort' value='1' />
			<data name='DataPin' value='7' />
			<data name='UseDefaultPins' value='1' />
			<data name='WrapEnabled' value='1' />
			<data name='CommsDelayOverridden' value='0' />
			<data name='CommsDelay' value='10' />
			<data name='CalculatedCommsDelay' value='10' />
		</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='9cde7a17-9eab-4154-abe9-e7cc0542b337' vstate='40' vmin='0' vmaj='1' srcleaf='' visiblename='' description='' category='' catenable='1' author='' manuname='' manucode='' sysinfo='0' keywords='' dynamic='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' interactive='1' solid='1' layer='0' poslock='0' >
			<resources />
			<properties />
			<values />
			<events />
			<apis />
			<variables >
				<variable public='0' >
					<def class_type='variable' name='measure' type='f32' description='' isconst='0' isinit='0' usrinit='0.0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='connect' type='b1' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='status' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</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='AnVal' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='socket' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='DataPointer' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RetVal' type='u8' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='sensor4' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='sensor3' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='RegVal' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='sensor2' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='sensor1' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='ret' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='CompareString' type='T8' description='' isconst='0' isinit='0' usrinit='&quot;&quot;' setinit='' >
						<array size='20' />
					</def>
				</variable>
				<variable public='0' >
					<def class_type='variable' name='DataLength' type='u16' description='' isconst='0' isinit='0' usrinit='0' setinit='' />
				</variable>
				<variable public='0' >
					<def class_type='variable' name='measureint' type='u16' 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='Main' description='' >
						<return name='Return' type='v0' description='' isconst='0' isinit='0' usrinit='' setinit='' />
						<command class_type='call' title='Startup the ENC28J60 Module - LEDs flash' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='Initialise' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='NetworkComms1' macro='Initialise' />
						<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='ModbusTCPSlave1' macro='Initialise' />
						<command class_type='loop' title='Loop' cmdcolor='12615680' cmdcolor_sec='15376912' type='0' exp='1' >
							<flowline >
								<command class_type='call' title='Check For Incoming Data' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='PacketReceive' >
									<return exp='DataLength' />
								</command>
								<command class_type='decision' title='Data Available?' cmdcolor='12615680' cmdcolor_sec='15376912' exp='DataLength &gt; 0' swap='0' >
									<flowline >
										<command class_type='call' title='Check For ARP Request' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='CheckForARP' >
											<return exp='RetVal' />
											<argument exp='DataLength' />
										</command>
										<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal' swap='0' >
											<flowline >
												<command class_type='call' title='ARP Reply' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='MakeArpAnswerFromRequest' />
												<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
											</flowline>
											<flowline />
										</command>
										<command class_type='call' title='Check For IP Request' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='CheckForIp' >
											<return exp='RetVal' />
											<argument exp='DataLength' />
										</command>
										<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal' swap='0' >
											<flowline >
												<command class_type='call' title='Check for Ping request' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='CheckForPing' >
													<return exp='RetVal' />
												</command>
												<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal' swap='0' >
													<flowline >
														<command class_type='call' title='Send Ping Response' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='MakeEchoReplyFromRequest' >
															<argument exp='DataLength' />
														</command>
														<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
													</flowline>
													<flowline />
												</command>
												<command class_type='call' title='Check the request is destined for our server port' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='CheckForTCPPort' >
													<return exp='RetVal' />
													<argument exp='80' />
												</command>
												<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal' swap='0' >
													<flowline >
														<command class_type='call' title='Check for the TCP type of request' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='CheckForTCPType' >
															<return exp='RetVal' />
														</command>
														<command class_type='decision' title='Synchronise?' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal &amp; 0x02' swap='0' >
															<flowline >
																<command class_type='call' title='Service Acknowledge' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='MakeTcpSynackFromSyn' >
																	<argument exp='80' />
																</command>
																<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
															</flowline>
															<flowline />
														</command>
														<command class_type='decision' title='Ack?' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal &amp; 0x10' swap='0' >
															<flowline >
																<command class_type='call' title='Check incoming data length after headers' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='InitialiseDataLengthInfo' />
																<command class_type='call' title='Get Current Data Pointer' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='GetTcpDataPointer' >
																	<return exp='DataPointer' />
																</command>
																<command class_type='decision' title='If there is no inbound data' cmdcolor='12615680' cmdcolor_sec='15376912' exp='DataPointer = 0' swap='0' >
																	<flowline >
																		<command class_type='decision' title='Ack with no data' cmdcolor='12615680' cmdcolor_sec='15376912' exp='RetVal &amp; 0x01' swap='0' >
																			<flowline >
																				<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='MakeTcpAckFromAny' >
																					<argument exp='80' />
																				</command>
																			</flowline>
																			<flowline />
																		</command>
																		<command class_type='goto' title='Goto Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='' />
																	</flowline>
																	<flowline />
																</command>
																<command class_type='delay' title='Delay' cmdcolor='12632064' cmdcolor_sec='16769676' exp='100' type='1' />
																<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='ModbusTCPSlave1' macro='CheckForIncoming' >
																	<return exp='status' />
																</command>
																<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='status' swap='0' >
																	<flowline >
																		<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='ModbusTCPSlave1' macro='ReadCoilStates' >
																			<return exp='status' />
																			<argument exp='0' />
																			<argument exp='1' />
																		</command>
																		<command class_type='decision' title='Decision' cmdcolor='12615680' cmdcolor_sec='15376912' exp='status' swap='0' >
																			<flowline >
																				<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='8' exp='1' />
																			</flowline>
																			<flowline >
																				<command class_type='output' title='Output' cmdcolor='16762795' cmdcolor_sec='13879979' mode='1' port='1048577' mask='8' exp='0' />
																			</flowline>
																		</command>
																		<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='ModbusTCPSlave1' macro='ReadAnalogueInput' >
																			<return exp='AnVal' />
																			<argument exp='0' />
																		</command>
																		<command class_type='call' title='Call Component Macro' cmdcolor='1879295' cmdcolor_sec='5751039' component='ModbusTCPSlave1' macro='SetAnalogueInput' >
																			<argument exp='0' />
																			<argument exp='AnVal + 1' />
																		</command>
																	</flowline>
																	<flowline />
																</command>
																<command class_type='call' title='Assemble TCP Ack Header' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='MakeTcpAckFromAny' >
																	<argument exp='80' />
																</command>
																<command class_type='call' title='Add data to the buffer' cmdcolor='1879295' cmdcolor_sec='5751039' component='TCPIP_ENC28J60' macro='MakeTcpAckWithData' >
																	<argument exp='DataLength' />
																</command>
															</flowline>
															<flowline />
														</command>
													</flowline>
													<flowline />
												</command>
											</flowline>
											<flowline />
										</command>
									</flowline>
									<flowline />
								</command>
								<command class_type='label' title='Connection Point' cmdcolor='12615680' cmdcolor_sec='15376912' labelid='0' labelname='RxDone' />
							</flowline>
						</command>
					</flowline>
				</macro>
			</macros>
			<component class_type='ref' guid='8aab4b54-a912-449c-b11a-7c1a5db8d591' vmin='2' vmaj='2' codename='TCPIP_ENC28J60' x='10' y='180' z='2.995' xsz='25' ysz='25' zsz='25' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Port' data='80' />
					<value target='BufferSize' data='500' />
					<value target='cal_spi::CHANNEL' data='001' />
					<value target='cal_spi::PR_SCALE' data='002' />
					<value target='cal_spi::MOSI' data='$PORTG.6' />
					<value target='cal_spi::MOSIPins' data='000' />
					<value target='cal_spi::MISO' data='$PORTG.7' />
					<value target='cal_spi::MISOPins' data='026' />
					<value target='cal_spi::CLK' data='$PORTG.8' />
					<value target='cal_spi::CLKPins' data='002' />
					<value target='cal_spi::SS' data='$PORTG.9' />
					<value target='ResetPin' data='$PORTB.2' />
					<value target='MAC0' data='100' />
					<value target='MAC1' data='101' />
					<value target='MAC2' data='102' />
					<value target='MAC3' data='103' />
					<value target='MAC4' data='104' />
					<value target='MAC5' data='105' />
					<value target='IP0' data='192' />
					<value target='IP1' data='168' />
					<value target='IP2' data='1' />
					<value target='IP3' data='7' />
					<value target='label' data='ENC28J60' />
					<value target='SimType' data='1' />
					<value target='cal_spi::ScopeTraces' data='1' />
					<value target='cal_spi::ConsoleData' data='1' />
					<value target='cal_spi::Injector' data='000' />
					<value target='TCP_Base1::interface' data='000' />
					<value target='RemapIndex' data='4' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
			<component class_type='ref' guid='1ecb9b0a-53e7-45c9-ab6f-7a0d4a0c47e1' vmin='1' vmaj='2' codename='ModbusTCPSlave1' x='10' y='80' z='3.74999' xsz='66' ysz='34' zsz='7.5' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Component' data='NetworkComms1' />
					<value target='Status' data='Simulation Only' />
					<value target='Port' data='80' />
					<value target='ReceiveBufferSize' data='20' />
					<value target='ReceiveTimeout' data='100' />
					<value target='SlaveAddress' data='1' />
					<value target='label' data='Modbus TCP Slave' />
					<value target='StartAdrCoil' data='0' />
					<value target='NumAdrCoil' data='8' />
					<value target='StartAdrDI' data='0' />
					<value target='NumAdrDI' data='8' />
					<value target='StartAdrAI' data='0' />
					<value target='NumAdrAI' data='1' />
					<value target='StartAdrReg' data='0' />
					<value target='NumAdrReg' 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='10' y='130' z='3.75' xsz='1' ysz='1' zsz='1' xang='0' yang='0' zang='0' xquat='0' yquat='0' zquat='0' wquat='1' visible='1' interactive='1' solid='1' layer='1' poslock='0' >
				<resources />
				<properties />
				<values >
					<value target='Component' data='TCPIP_ENC28J60' />
					<value target='RemapIndex' data='4' />
					<value target='Status' data='Not Yet Supported' />
					<value target='Sim' data='0' />
					<value target='SimControl' data='000' />
					<value target='NetworkInterface' data='' />
					<value target='IPAddress' data='192.168.1.8' />
				</values>
				<events />
				<apis />
				<variables />
				<macros />
			</component>
		</component>
	</components>
	<keymap />
	<panel2d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='7292207' img='' style='0' />
		<camera xe='2.75082' ye='112.78' ze='154.555' xt='2.75082' yt='112.78' zt='0' xquat='0' yquat='0' zquat='0' wquat='1' />
	</panel2d>
	<panel3d shadows='0' lighting='2' brightness='0' perspective='0' >
		<background rgb='8409120' img='' style='0' />
		<table rgb='7360576' img='' style='0' size='0' />
		<camera xe='24.4588' ye='-28.4323' ze='1756.52' xt='24.4588' yt='-28.4323' 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---------------------wUAAAAYAAAAmAIAADYCAAA' zoom='60' scrollx='0' scrolly='0' flags='0' />
	</layout>
</document>
</root>
