--[[
---------------------------------------------------------------------------
Remote Train Control Program for Windows

© Copyright 2019 by Mark DiVecchio

	This file is part of Remote Train Control.

	Remote Train Control is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Remote Train Control is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

 Home Page : http://www.silogic.com/trains/RTC_Running.html
---------------------------------------------------------------------------]]
-- Semicolons are not required in Lua code
-- This script measures the distance between the tags on the layout.
-- 
title = "Tag DTO-DOD-DCH Distance Test"
require("defines");
require("functions");

local TagCount = 0;
-- Counter Labels
Counter01Label = "tags()";
Counter02Label = "nametags()";
Counter03Label = "uidtags()";
Counter04Label = "response()";

local Tags = {};		-- table to hold all of the tags detected in sequence

local SoundOn = false;	-- start with annoying beep() off

DTOLast = 0;
DODLast = 0;
DTOCurrent = 0;
DODCurrent = 0;
DetectorLast = 0;
ReaderLast = 0;

Accuracy= 0.015;

-- Configuration Variables
local AutoBellWhistle = true;

-- Constructor output example
-- distance between two tag readers in inches. Tag reader number is ((Detector * 10) + Reader).
-- Distance given by TestOut[R1][R2].
TestOut = {[20] = {[40] = 139.80496371955, }, [40] = {[50] = 280.15344086518, }, [50] = {[30] = 40.563848962425, }, [30] = {[51] = 56.647409529972, }, [51] = {[10] = 207.28936543883, }, [10] = {[41] = 952.71802930166, }, [41] = {[21] = 146.69316448676, }, [21] = {[20] = 286.09326616444, }, };
--
-- Measured Distances substituted into TestOut for segment that I measured with a tape measure
--
MeasuredDistance = {[20] = {[40] = 139.25, }, [40] = {[50] = 278.5, }, [50] = {[30] = 40.5, }, [30] = {[51] = 56.647409529972, }, [51] = {[10] = 207.28936543883, }, [10] = {[41] = 952.71802930166, }, [41] = {[21] = 147.25, }, [21] = {[20] = 286.09326616444, }, };

--[[---------------------------------------------------------------------------------------]]
function setup(Engine, TIU)
	-- this function is called once when the [Run Script] button is pushed
	-- Engine : Engine number selected on the RTC Main window
	-- TIU : TIU number selected on the RTC Main window
	print("setup()");

	-- make sure that RFID is connected
	TIUSerialPortConnected, TIUConnected, RFIDSerialPortConnected = CommStatus();	
	--print("TIUSerialPortConnected : " .. tostring(TIUSerialPortConnected) .. " - TIUConnected : " .. tostring(TIUConnected) .. " - RFIDSerialPortConnected : " .. tostring(RFIDSerialPortConnected));
	if (not RFIDSerialPortConnected) then
		print("RFID Port must be enabled for this script");
		return false;	-- false=setup failed
		end
	TableConstructor = "{";
	MyEngineNo = Engine;	-- Engine number selected on the RTC Main window
	MyTIUNo = TIU;		-- TIU number selected on the RTC Main window
	-- debug level as selected on the Debug window, values 0 (off) to 9 (maximum)
	if (Debug() > 0) then 
		print(string.format("setup(): Debug level %d", Debug())); 
		print("setup(): Engine Number ", MyEngineNo ," TIU Number ", MyTIUNo);
		end
	Name, PS = GetName(MyEngineNo);
	print("Engine#" .. MyEngineNo .. " " .. Name .. " PS" .. PS);
	print("TIU : " .. MyTIUNo);
	print("Accuracy Limit = " .. Accuracy * 100 .. "%");
	Title(title .. " - " .. GetName(Engine));
	assert((MyTIUNo >= 1 and MyTIUNo <= 5),"TIU Number out of range");
	--
	print(string.format("Run Time = %.2f Seconds", RunTime()));
	Smoke(OFF, 0, MyEngineNo, MyTIUNo);
	StartUp(0, MyEngineNo, MyTIUNo);	-- start selected engine
	-- let engine startup
	Sleep(11.4);
	print(string.format("Run Time = %.2f Seconds", RunTime()));
	
	Acc, Dec = GetRate(MyEngineNo, MyTIUNo);	-- save current accel and decel rates
	print("Acc = " .. Acc .. " Dec = " .. Dec);
	--Rate(10, 10, 0, MyEngineNo, MyTIUNo);	-- set High accel and decel rates
	
	-- read up initial RunTime, DCH, DTO and DOD
	RunTimeInitial = RunTime();
	RunTimeLast = 0;
	DTOInitial = DTO(MyEngineNo, MyTIUNo);
	DTOLast = 0
	DODInitial = DOD(MyEngineNo, MyTIUNo);
	DODLast = 0
	DCHInitial = DCH(MyEngineNo, MyTIUNo);
	DCHLast = 0

	EngSpeed = 20;
	print("setup : Set speed to " .. EngSpeed);
	Throttle(EngSpeed, 0, MyEngineNo, MyTIUNo); -- set Speed to EngSpeed
	return true;		-- false=setup failed, true=setup succeeded
	end
--[[---------------------------------------------------------------------------------------]]
function tag(Detector, Reader, EngineNo, TagLocation, CarModel, Railroad, CarNumber, TagPacket)
	-- This function is called each time a tag programmed with 32 bytes of data is detected (TAGDATABLOCK4)
	-- TagPacket contains 8 characters (4 hex digits) of UID and 32 characters
	-- of block 4 data from the programmed tag.
	if (EngineNo ~= MyEngineNo) then return true; end;
	if (SoundOn) then Beep(DEFAULT_BEEP); end;	-- sound a tone
	BumpCounter(COUNTER01);	
	PacketLen = #TagPacket;

	if (Debug() >= 2) then print("Packet Length = ", PacketLen); end;
	if (Debug() >= 5) then print(TagPacket);	end;
---[=[
---------------------------------------------------------------------------	
	-- index the table Tags[] by tag ID, value is the tag packet itself
	Tags[string.sub(TagPacket, 1, 8)] = string.sub(TagPacket, 9, 40);	-- remove checksum and EOP
	TagCount = TagCount + 1;	-- count the number of tags
	
	if (isEngine(EngineNo) and isTagFront(TagLocation)) then	-- its an engine and front tag
		-- next line shows a different way to quote a string using brackets
		if (Debug() >= 1) then 
			print(string.format([[tag(%.2fs) : Detector %d Reader %d Eng#%d %s %s #%s %s]],
				RunTime(), Detector, Reader, EngineNo, GetRailroadName(Railroad), GetEngineName(CarModel), CarNumber, GetTagLocation(TagLocation)));
			end;
		-- find distance between tags
		if (DTOLast == 0) then
			-- its the first detector
			RunTimeLast = RunTime() - RunTimeInitial;			
			DTOLast = DTO(MyEngineNo, MyTIUNo) - DTOInitial;
			DODLast = DOD(MyEngineNo, MyTIUNo) - DODInitial;
			DCHLast = DCH(MyEngineNo, MyTIUNo) - DCHInitial;

			DetectorLast = Detector;
			ReaderLast = Reader;
			print(string.format("(%.2fs) Detector = %d Reader = %d DTO = %.3f Seconds DOD = %.3f Seconds", RunTime(), Detector, Reader, 0, 0));
			print(string.format("   DCH = %.3f Seconds", DCHLast));
			else
			-- following tags
			RunTimeCurrent = RunTime() - RunTimeInitial;			
			DTOCurrent = DTO(MyEngineNo, MyTIUNo) - DTOInitial;
			DODCurrent = DOD(MyEngineNo, MyTIUNo) - DODInitial;
			DCHCurrent = DCH(MyEngineNo, MyTIUNo) - DCHInitial;

			RunTimeDelta = RunTimeCurrent - RunTimeLast;
			DTODelta = DTOCurrent - DTOLast;
			DODDelta = DODCurrent - DODLast;
			DCHDelta = DCHCurrent - DCHLast;
			DTOInches = DTODelta * 5280 * 12 / 48;	-- convert Smiles to real inches
			print(string.format("(%.2fs) Detector = %d Reader = %d DTO = %.3f Smiles DOD = %.3f Smiles Delta DTO = %.3f Smiles (%.3f inches) Delta DOD = %.3f Smiles Error = %.3f Smiles ",
				RunTime(), Detector, Reader, DTOCurrent, DODCurrent, DTODelta, DTOInches, DODDelta, DTODelta - DODDelta));
			Calc1 = (DTODelta/DCHDelta) * 3600;
			Calc2 = (DTODelta/RunTimeDelta) * 3600;
			print(string.format("   DCH      = %.3f Seconds - DCH      Calculated Smph = %.3f Error = %.3f Smph", DCHCurrent, Calc1, Calc1 - EngSpeed));
			print(string.format("   Run Time = %.3f Seconds - Run Time Calculated Smph = %.3f Error = %.3f Smph", RunTimeCurrent, Calc2, Calc2 - EngSpeed));
			ExpectedInches = TestOut[(DetectorLast * 10) + ReaderLast][(Detector * 10) + Reader];
			ErrorInches = DTOInches - ExpectedInches;
			Message =  string.format("   Inches   = %.3f         -          Expected Inches = %.3f Error = %.3f Inches (%.3f%%)",
				DTOInches, ExpectedInches, ErrorInches, (100 * ErrorInches/ExpectedInches));
			if (math.abs(ErrorInches) > (ExpectedInches * Accuracy)) then 		-- accuracy 1.5%
				Beep();
				printc(clGreen, Message); 
				else
				printc(clBlack, Message); 
				end;
			TableConstructor = TableConstructor .. "[" .. (DetectorLast * 10) + ReaderLast .. "] = {[" .. (Detector * 10) + Reader .. "] = " .. DTOInches .. ", }, ";
			RunTimeLast = RunTimeCurrent;
			DTOLast = DTOCurrent;
			DODLast = DODCurrent;
			DCHLast = DCHCurrent;

			DetectorLast = Detector;
			ReaderLast = Reader;
			end
		else	-- it's a car
		--print(string.format([[tag(%.2f) : Detector %d Reader %d Car %s %s #%s]],
		--	RunTime(), Detector, Reader, GetRailroadName(Railroad), GetCarName(CarModel), CarNumber));
		-- ignore non engine tags
		return true;	-- true=continue to process tags, false=stop processing tags
		end

	-- The complete packet received is in TagPacket 
	-- (all of the fields have already been extracted into the first parameters to tag()
	--   First 8 digits are the 4 byte Tag UID in hexidecimal
	--   Next 32 digits are the 16 bytes of Block 4 Information read from the Tag in hexidecimal
	if (Debug() >= 3) then print(string.format("Packet  %s  %s", string.sub(TagPacket, 1, 8),
		string.sub(TagPacket,9,40) )); end

	return true;	-- true=continue to process tags, false=stop processing tags
	end
---------------------------------------------------------------------------]=]
function nametag(Detector, Reader, UID, CarName)
	-- This function is called each time a tag programmed with 32 bytes of car name is detected (TAGDATABLOCK5)
	-- UID contains 8 characters (4 hex digits) of UID and CarName contains 32 characters of car name
	-- of block 5 data from the programmed tag. 
	Beep(QUESTION);	-- sound a tone
	BumpCounter(COUNTER02);	
	UIDLen = #UID;
	CarNameLen = #CarName
	if (Debug() >= 2) then print("UID Length = ", UIDLen); end;
	if (Debug() >= 2) then print("CarName Length = ", CarNameLen); end;
	print(string.format([[nametag(%.2f) : Detector %d Reader %d]], RunTime(), Detector, Reader));
	if (Debug() >= 3) then print(string.format("UID  %s", string.sub(UID, 1, 8))); end	
	if (Debug() >= 3) then print(string.format("Car Name  %s", string.sub(CarName, 1, 16))); end	
	return true;	-- true=continue to process tags, false=stop processing tags
	end
--[[---------------------------------------------------------------------------------------]]
	
function uidtag(Detector, Reader, UID)
	-- This function is called each time an unprogrammed tag (TAGDETECTED) is detected
	-- Only the tag UID is returned
	-- UID contains 8 characters (4 hex digits) of UID	.
	-- When used as an error catch all, it could call EmergencyStop().	
	Beep(CRITICAL_STOP);	-- sound a tone
	BumpCounter(COUNTER03);	
	UIDLen = #UID;
	if (Debug() >= 2) then print("UID Length = ", UIDLen); end;
	print(string.format([[uidtag(%.2f) : Detector %d Reader %d]], RunTime(), Detector, Reader));
	--   8 digits are the 4 byte Tag UID in hexidecimal
	if (Debug() >= 3) then print(string.format("UID  %s", string.sub(UID, 1, 8))); end		
	TagCount = TagCount + 1;	-- count the number of tags	
	return true;	-- true=continue to process tags, false=stop processing tags
	end
--[[---------------------------------------------------------------------------------------]]
function response(Detector, Reader, Type, RespPacket)
	-- This function is called for all response from the Detectors
	-- This means that for regular block 4 tags (TAGDATABLOCK4) and for UID only tags (TAGDETECTED), this
	-- function is called right after tag() or uidtag() is called.
	-- It is up the user to skip those responses if he does want to do additional processing.
	-- RespPacket may contain a variable number of characters - inlcudes all header fields, data fields and trailer fields 
	-- THIS IS ONLY USEFUL WHEN DEBUGGING.
	-- Using this function requires an understanding of the RAW Tag Packet format.
	-- When used as an error catch all, it could call EmergencyStop() except for packets
	-- which called tag() (TAGDATABLOCK4) and uidtag() (TAGDETECTED).
	--Beep();	-- sound a tone
	BumpCounter(COUNTER04);	
	if (Debug() < 1) then return true; end;
	PacketLen = #RespPacket;
	-- Packet Types are defined in defines.lua
	if (Debug() >= 2) then print(string.format("Packet Length = %d Packet Type = 0x%02X", PacketLen, Type)); end;
	print(string.format([[response(%.2f) : Detector %d Reader %d Packet Type = 0x%02X]], RunTime(), Detector, Reader, Type));
	-- The complete packet received is in "RespPacket" - inlcudes all header fields, data fields and trailer fields 
	if (Debug() >= 3) then print(string.format("Response Packet  %s", RespPacket)); end		
	return true;	-- true=continue to process tags, false=stop processing tags
	end
--[[---------------------------------------------------------------------------------------]]
function cleanup(Engine, TIU)
	-- this function is called once when the user presses the [STOP] button
	--if (Acc >= 0 and Dec >= 0 ) then
	--	Rate(Acc, Dec, 0, MyEngineNo, MyTIUNo);	-- restore accel and decel rates	
	--	end;
	Sleep(2);
	Throttle(0, 0, MyEngineNo, MyTIUNo);
	Sleep(12);
	DTOFinish = DTO(MyEngineNo, MyTIUNo);
	-- wait for dispatch list to empty
	while(CountDispatchList() > 0) do Sleep(1); end
	print(string.format("Run Time = %.2f Seconds", RunTime()));
	print(string.format("Trip Odometer Finish %.2f Smiles", DTOFinish));
	ShutDown(0, MyEngineNo, MyTIUNo);

	if (TableConstructor ~= nil) then
		TableConstructor = TableConstructor .. "}"; 
		print (TableConstructor);
		end;
	
	print("All Newly Detected Tags:");
	for k,v in  pairs(Tags) do		-- dump out the Tags table
		--                           . . . . . . . . . . . . . . . .
		-- print format:  6619044A  88080101030108011B02202031353536
		print(k .. "  " .. v);
		end
	print(string.format("cleanup() Complete at %.2f", RunTime()));
	--
	return true;		-- false=cleanup failed, true=cleanup succeeded
	end
--[[---------------------------------------------------------------------------------------]]
function tick(Engine, TIU)
	-- this is called once per second while waiting for RFID tags to arrive
	-- Do not call Sleep() from this function
	if (Debug() > 6) then print(string.format("RunTime = %.2f Seconds", RunTime())); end;
	return true;
	end
--[[---------------------------------------------------------------------------------------]]
--[[---------------------------------------------------------------------------------------]]
function DTOButton(Eng, TIU)
	print(string.format("Engine %d Trip Odometer %.3f Smiles", Eng, DTO(Eng, TIU)));
	return true;
end
Function01Name, Function01Label = DTOButton, "Show DTO";
--[[---------------------------------------------------------------------------------------]]
function DODButton(Eng, TIU)
	print(string.format("Engine %d Odometer %.3f Smiles", Eng, DOD(Eng, TIU)));
	return true;
end
Function02Name, Function02Label = DODButton, "Show DOD";
--[[---------------------------------------------------------------------------------------]]
function DCHButton(Eng, TIU)
	print(string.format("Engine %d Chronometer %.3f Seconds", Eng, DCH(Eng, TIU)));
	return true;
end
Function03Name, Function03Label = DCHButton, "Show DCH";
--[[---------------------------------------------------------------------------------------]]
--[[---------------------------------------------------------------------------------------]]
function BeepOffButton(Eng, TIU)
	print("Beep Off");
	SoundOn = false;
	return true;
end
Function04Name, Function04Label = BeepOffButton, "Beep Off";
--[[---------------------------------------------------------------------------------------]]
function BeepOnButton(Eng, TIU)
	print("Beep On");
	SoundOn = true;
	return true;
end
Function05Name, Function05Label = BeepOnButton, "Beep On";
--[[---------------------------------------------------------------------------------------]]
function IncAcc(Eng, TIU)
Accuracy = Accuracy + 0.001;
print("Accuracy = " .. Accuracy);
return true;
end;
Function06Name, Function06Label = IncAcc, "Accuracy +0.001";
--[[---------------------------------------------------------------------------------------]]
function DecAcc(Eng, TIU)
Accuracy = Accuracy - 0.001;
print("Accuracy = " .. Accuracy);
return true;
end;
Function07Name, Function07Label = DecAcc, "Accuracy -0.001";
--[[---------------------------------------------------------------------------------------]]
--[[
---------------------------------------------------------------------------
Success compiling C:\trains\MTH\PC Control\Scripts\Tag Distance Recording Test.lua
setup()
Engine#12 P&LE GP38-2#2057 PS3
TIU : 1
Run Time = 0.00 seconds
Run Time = 14.40 seconds
setup : Set speed to 20
Waiting for RFID Tag Detection
(29.60s) Detector 1 Reader 0 DTO 0.000 DOD 0.000
(158.90s) Detector 4 Reader 1 DTO 0.776 DOD 0.777 Delta DTO 0.719 (948.775 inches) Delta DOD 0.718 Error 0.000
(178.90s) Detector 2 Reader 1 DTO 0.887 DOD 0.888 Delta DTO 0.111 (146.915 inches) Delta DOD 0.112 Error -0.001
(217.80s) Detector 2 Reader 0 DTO 1.103 DOD 1.104 Delta DTO 0.216 (284.979 inches) Delta DOD 0.215 Error 0.001
(236.70s) Detector 4 Reader 0 DTO 1.208 DOD 1.209 Delta DTO 0.105 (138.563 inches) Delta DOD 0.105 Error -0.000
(274.90s) Detector 5 Reader 0 DTO 1.420 DOD 1.422 Delta DTO 0.212 (279.948 inches) Delta DOD 0.213 Error -0.001
(280.40s) Detector 3 Reader 0 DTO 1.450 DOD 1.452 Delta DTO 0.030 (40.187 inches) Delta DOD 0.030 Error 0.000
(287.90s) Detector 5 Reader 1 DTO 1.493 DOD 1.495 Delta DTO 0.042 (55.716 inches) Delta DOD 0.043 Error -0.001
(316.20s) Detector 1 Reader 0 DTO 1.649 DOD 1.650 Delta DTO 0.157 (206.846 inches) Delta DOD 0.155 Error 0.002
[STOP]
Run Time = 371.90 seconds
Trip Odometer Finish 1.92 Smiles
All Newly Detected Tags:
56D61A4A  88005000505002011903383930323735
16790A4A  880002FF03FF01031B03313532323830
B654134A  88005000505001071D03353637343237
D6BD144A  880C0101030101012602202032303537
56ED134A  88000200030004011B03202020353038
B6BE144A  880C0201030101012602202032303537
cleanup() Complete at 371.90
---------------------------------------------------------------------------
Success compiling C:\trains\MTH\PC Control\Scripts\Tag Distance Recording Test.lua
setup()
Engine#16 P&LE RS-3 #8356  PS3
TIU : 1
Run Time = 0.00 seconds
Run Time = 14.40 seconds
setup : Set speed to 20
Waiting for RFID Tag Detection
(36.20s) Detector 1 Reader 0 DTO 0.000 DOD 0.000
(165.90s) Detector 4 Reader 1 DTO 0.815 DOD 0.817 Delta DTO 0.721 (952.075 inches) Delta DOD 0.721 Error 0.001
(186.00s) Detector 2 Reader 1 DTO 0.926 DOD 0.929 Delta DTO 0.111 (146.954 inches) Delta DOD 0.112 Error -0.001
(225.00s) Detector 2 Reader 0 DTO 1.143 DOD 1.144 Delta DTO 0.217 (286.132 inches) Delta DOD 0.215 Error 0.002
(244.10s) Detector 4 Reader 0 DTO 1.249 DOD 1.252 Delta DTO 0.106 (139.716 inches) Delta DOD 0.108 Error -0.002
(282.20s) Detector 5 Reader 0 DTO 1.461 DOD 1.463 Delta DTO 0.212 (280.142 inches) Delta DOD 0.211 Error 0.001
(287.80s) Detector 3 Reader 0 DTO 1.492 DOD 1.493 Delta DTO 0.031 (40.531 inches) Delta DOD 0.030 Error 0.001
(295.40s) Detector 5 Reader 1 DTO 1.534 DOD 1.536 Delta DTO 0.042 (56.015 inches) Delta DOD 0.043 Error -0.001
(323.70s) Detector 1 Reader 0 DTO 1.691 DOD 1.693 Delta DTO 0.157 (207.262 inches) Delta DOD 0.157 Error -0.000
[STOP]
Run Time = 458.20 seconds
Trip Odometer Finish 4.38 Smiles
All Newly Detected Tags:
66DA1A4A  880001FF03FF01031A05313539383936
F62E144A  88005000505006011D06203430353930
A66D0A4A  880002FF03FF06031D03373439353932
B62E144A  8810020103010D012302202038333536
363F1A4A  88000201030104011907202020353137
E63F1A4A  8810010103010D012302202038333536
cleanup() Complete at 458.20

Success compiling C:\trains\MTH\PC Control\Scripts\Tag Distance Recording Test.lua
setup()
Engine#16 P&LE RS-3 #8356  PS3
TIU : 1
Run Time = 0.00 seconds
Run Time = 7.40 seconds
setup : Set speed to 20
Waiting for RFID Tag Detection
(46.40s) Detector 2 Reader 0 DTO 0.000 DOD 0.000
(65.50s) Detector 4 Reader 0 DTO 0.295 DOD 0.299 Delta DTO 0.106 (139.805 inches) Delta DOD 0.108 Error -0.002
(103.70s) Detector 5 Reader 0 DTO 0.507 DOD 0.510 Delta DTO 0.212 (280.153 inches) Delta DOD 0.211 Error 0.001
(109.20s) Detector 3 Reader 0 DTO 0.538 DOD 0.542 Delta DTO 0.031 (40.564 inches) Delta DOD 0.032 Error -0.002
(116.90s) Detector 5 Reader 1 DTO 0.581 DOD 0.583 Delta DTO 0.043 (56.647 inches) Delta DOD 0.041 Error 0.002
(145.20s) Detector 1 Reader 0 DTO 0.738 DOD 0.740 Delta DTO 0.157 (207.289 inches) Delta DOD 0.157 Error 0.000
(275.10s) Detector 4 Reader 1 DTO 1.460 DOD 1.463 Delta DTO 0.722 (952.718 inches) Delta DOD 0.723 Error -0.001
(295.10s) Detector 2 Reader 1 DTO 1.571 DOD 1.575 Delta DTO 0.111 (146.693 inches) Delta DOD 0.112 Error -0.001
(334.10s) Detector 2 Reader 0 DTO 1.788 DOD 1.790 Delta DTO 0.217 (286.093 inches) Delta DOD 0.215 Error 0.002
[STOP]
Run Time = 349.90 seconds
Trip Odometer Finish 3.59 Smiles
{[20] = {[40] = 139.80496371955, }, [40] = {[50] = 280.15344086518, }, [50] = {[30] = 40.563848962425, }, [30] = {[51] = 56.647409529972, }, [51] = {[10] = 207.28936543883, }, [10] = {[41] = 952.71802930166, }, [41] = {[21] = 146.69316448676, }, [21] = {[20] = 286.09326616444, }, }
All Newly Detected Tags:
B62E144A  8810020103010D012302202038333536
66DA1A4A  880001FF03FF01031A05313539383936
363F1A4A  88000201030104011907202020353137
A66D0A4A  880002FF03FF06031D03373439353932
E63F1A4A  8810010103010D012302202038333536
F62E144A  88005000505006011D06203430353930
cleanup() Complete at 349.90


Success compiling C:\trains\MTH\PC Control\Scripts\Tag Distance Recording Test.lua
setup()
Engine#16 P&LE RS-3 #8356  PS3
TIU : 1
Run Time = 0.10 Seconds
Run Time = 7.50 Seconds
Acc = 1 Dec = 1
setup : Set speed to 30
Waiting for RFID Tag Detection
(19.50s) Detector = 5 Reader = 0 DTO = 0.000 Seconds DOD = 0.000 Seconds
   DCH = 10.153 Seconds
(23.20s) Detector = 3 Reader = 0 DTO = 0.070 Smiles DOD = 0.073 Smiles Delta DTO = 0.031 Smiles (40.686 inches) Delta DOD = 0.030 Smiles Error = 0.001 Smiles 
   DCH      = 13.857 Seconds - DCH      Calculated Smph = 29.959 Error = -0.041 Smph
   Run Time = 13.800 Seconds - Run Time Calculated Smph = 29.990 Error = -0.010 Smph
(28.30s) Detector = 5 Reader = 1 DTO = 0.113 Smiles DOD = 0.116 Smiles Delta DTO = 0.043 Smiles (56.226 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 18.902 Seconds - DCH      Calculated Smph = 30.397 Error = 0.397 Smph
   Run Time = 18.900 Seconds - Run Time Calculated Smph = 30.067 Error = 0.067 Smph
(47.20s) Detector = 1 Reader = 0 DTO = 0.270 Smiles DOD = 0.273 Smiles Delta DTO = 0.157 Smiles (207.495 inches) Delta DOD = 0.157 Smiles Error = 0.000 Smiles 
   DCH      = 37.836 Seconds - DCH      Calculated Smph = 29.888 Error = -0.112 Smph
   Run Time = 37.800 Seconds - Run Time Calculated Smph = 29.941 Error = -0.059 Smph
(133.70s) Detector = 4 Reader = 1 DTO = 0.991 Smiles DOD = 0.994 Smiles Delta DTO = 0.721 Smiles (952.041 inches) Delta DOD = 0.721 Smiles Error = 0.001 Smiles 
   DCH      = 124.331 Seconds - DCH      Calculated Smph = 30.019 Error = 0.019 Smph
   Run Time = 124.300 Seconds - Run Time Calculated Smph = 30.017 Error = 0.017 Smph
(147.00s) Detector = 2 Reader = 1 DTO = 1.102 Smiles DOD = 1.106 Smiles Delta DTO = 0.111 Smiles (146.826 inches) Delta DOD = 0.112 Smiles Error = -0.001 Smiles 
   DCH      = 137.645 Seconds - DCH      Calculated Smph = 30.076 Error = 0.076 Smph
   Run Time = 137.600 Seconds - Run Time Calculated Smph = 30.108 Error = 0.108 Smph
(173.00s) Detector = 2 Reader = 0 DTO = 1.319 Smiles DOD = 1.321 Smiles Delta DTO = 0.217 Smiles (285.999 inches) Delta DOD = 0.215 Smiles Error = 0.002 Smiles 
   DCH      = 163.635 Seconds - DCH      Calculated Smph = 30.011 Error = 0.011 Smph
   Run Time = 163.600 Seconds - Run Time Calculated Smph = 30.000 Error = -0.000 Smph
(186.70s) Detector = 4 Reader = 0 DTO = 1.433 Smiles DOD = 1.437 Smiles Delta DTO = 0.114 Smiles (150.648 inches) Delta DOD = 0.116 Smiles Error = -0.002 Smiles 
   DCH      = 177.332 Seconds - DCH      Calculated Smph = 29.995 Error = -0.005 Smph
   Run Time = 177.300 Seconds - Run Time Calculated Smph = 29.990 Error = -0.010 Smph
(211.30s) Detector = 5 Reader = 0 DTO = 1.638 Smiles DOD = 1.641 Smiles Delta DTO = 0.205 Smiles (270.193 inches) Delta DOD = 0.204 Smiles Error = 0.000 Smiles 
   DCH      = 201.918 Seconds - DCH      Calculated Smph = 29.973 Error = -0.027 Smph
   Run Time = 201.900 Seconds - Run Time Calculated Smph = 29.955 Error = -0.045 Smph
(214.90s) Detector = 3 Reader = 0 DTO = 1.668 Smiles DOD = 1.671 Smiles Delta DTO = 0.030 Smiles (40.015 inches) Delta DOD = 0.030 Smiles Error = 0.000 Smiles 
   DCH      = 205.558 Seconds - DCH      Calculated Smph = 29.982 Error = -0.018 Smph
   Run Time = 205.500 Seconds - Run Time Calculated Smph = 30.314 Error = 0.314 Smph
(220.00s) Detector = 5 Reader = 1 DTO = 1.711 Smiles DOD = 1.715 Smiles Delta DTO = 0.043 Smiles (56.559 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 210.698 Seconds - DCH      Calculated Smph = 30.007 Error = 0.007 Smph
   Run Time = 210.600 Seconds - Run Time Calculated Smph = 30.245 Error = 0.245 Smph
(239.00s) Detector = 1 Reader = 0 DTO = 1.868 Smiles DOD = 1.872 Smiles Delta DTO = 0.157 Smiles (207.151 inches) Delta DOD = 0.157 Smiles Error = -0.000 Smiles 
   DCH      = 229.600 Seconds - DCH      Calculated Smph = 29.889 Error = -0.111 Smph
   Run Time = 229.600 Seconds - Run Time Calculated Smph = 29.735 Error = -0.265 Smph
(325.50s) Detector = 4 Reader = 1 DTO = 2.589 Smiles DOD = 2.592 Smiles Delta DTO = 0.721 Smiles (952.363 inches) Delta DOD = 0.721 Smiles Error = 0.001 Smiles 
   DCH      = 316.127 Seconds - DCH      Calculated Smph = 30.018 Error = 0.018 Smph
   Run Time = 316.100 Seconds - Run Time Calculated Smph = 30.027 Error = 0.027 Smph
(338.80s) Detector = 2 Reader = 1 DTO = 2.701 Smiles DOD = 2.704 Smiles Delta DTO = 0.111 Smiles (146.804 inches) Delta DOD = 0.112 Smiles Error = -0.001 Smiles 
   DCH      = 329.409 Seconds - DCH      Calculated Smph = 30.143 Error = 0.143 Smph
   Run Time = 329.400 Seconds - Run Time Calculated Smph = 30.103 Error = 0.103 Smph
(364.80s) Detector = 2 Reader = 0 DTO = 2.917 Smiles DOD = 2.919 Smiles Delta DTO = 0.216 Smiles (285.666 inches) Delta DOD = 0.215 Smiles Error = 0.001 Smiles 
   DCH      = 355.431 Seconds - DCH      Calculated Smph = 29.940 Error = -0.060 Smph
   Run Time = 355.400 Seconds - Run Time Calculated Smph = 29.965 Error = -0.035 Smph
   
(377.50s) Detector = 4 Reader = 0 DTO = 3.023 Smiles DOD = 3.027 Smiles Delta DTO = 0.106 Smiles (140.398 inches) Delta DOD = 0.108 Smiles Error = -0.001 Smiles 
   DCH      = 368.171 Seconds - DCH      Calculated Smph = 30.056 Error = 0.056 Smph
   Run Time = 368.100 Seconds - Run Time Calculated Smph = 30.150 Error = 0.150 Smph
   
(403.00s) Detector = 5 Reader = 0 DTO = 3.236 Smiles DOD = 3.238 Smiles Delta DTO = 0.212 Smiles (280.120 inches) Delta DOD = 0.211 Smiles Error = 0.001 Smiles 
   DCH      = 393.650 Seconds - DCH      Calculated Smph = 29.984 Error = -0.016 Smph
   Run Time = 393.600 Seconds - Run Time Calculated Smph = 29.959 Error = -0.041 Smph
   
(406.70s) Detector = 3 Reader = 0 DTO = 3.266 Smiles DOD = 3.270 Smiles Delta DTO = 0.031 Smiles (40.331 inches) Delta DOD = 0.032 Smiles Error = -0.002 Smiles 
   DCH      = 397.354 Seconds - DCH      Calculated Smph = 29.698 Error = -0.302 Smph
   Run Time = 397.300 Seconds - Run Time Calculated Smph = 29.728 Error = -0.272 Smph
(411.80s) Detector = 5 Reader = 1 DTO = 3.309 Smiles DOD = 3.313 Smiles Delta DTO = 0.043 Smiles (56.226 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 402.462 Seconds - DCH      Calculated Smph = 30.017 Error = 0.017 Smph
   Run Time = 402.400 Seconds - Run Time Calculated Smph = 30.067 Error = 0.067 Smph
[STOP]
Run Time = 429.40 Seconds
Trip Odometer Finish 3.40 Smiles
{[50] = {[30] = 40.685862180524, }, [30] = {[51] = 56.225909321995, }, [51] = {[10] = 207.49456948745, }, [10] = {[41] = 952.04141054675, }, [41] = {[21] = 146.82626981559, }, [21] = {[20] = 285.99898322318, }, [20] = {[40] = 150.64750196423, }, [40] = {[50] = 270.19272542404, }, [50] = {[30] = 40.014789480982, }, [30] = {[51] = 56.558672644082, }, [51] = {[10] = 207.15071405463, }, [10] = {[41] = 952.3630817581, }, [41] = {[21] = 146.80408559412, }, [21] = {[20] = 285.6662199011, }, [20] = {[40] = 140.39839164394, }, [40] = {[50] = 280.12016453298, }, [50] = {[30] = 40.330914636965, }, [30] = {[51] = 56.225909321995, }, }
All Newly Detected Tags:
B62E144A  8810020103010D012302202038333536
E63F1A4A  8810010103010D012302202038333536
cleanup() Complete at 429.40


Error 3 : ...s\MTH\PC Control\Scripts\Tag Distance Recording Test.lua:167: ')' expected near ';'
Success compiling C:\trains\MTH\PC Control\Scripts\Tag Distance Recording Test.lua
setup()
Engine#16 P&LE RS-3 #8356  PS3
TIU : 1
Run Time = 0.00 Seconds
Run Time = 7.40 Seconds
Acc = 1 Dec = 1
setup : Set speed to 30
Waiting for RFID Tag Detection
(23.50s) Detector = 1 Reader = 0 DTO = 0.000 Seconds DOD = 0.000 Seconds
   DCH = 13.953 Seconds
(110.00s) Detector = 4 Reader = 1 DTO = 0.792 Smiles DOD = 0.794 Smiles Delta DTO = 0.721 Smiles (952.008 inches) Delta DOD = 0.721 Smiles Error = 0.001 Smiles 
   DCH      = 100.480 Seconds - DCH      Calculated Smph = 30.007 Error = 0.007 Smph
   Run Time = 100.900 Seconds - Run Time Calculated Smph = 30.016 Error = 0.016 Smph
   Inches   = 952.008         -          Expected Inches = 952.718 Error = 0.710 Inches
(123.40s) Detector = 2 Reader = 1 DTO = 0.903 Smiles DOD = 0.906 Smiles Delta DTO = 0.111 Smiles (147.142 inches) Delta DOD = 0.112 Smiles Error = -0.000 Smiles 
   DCH      = 113.826 Seconds - DCH      Calculated Smph = 30.068 Error = 0.068 Smph
   Run Time = 114.200 Seconds - Run Time Calculated Smph = 30.173 Error = 0.173 Smph
   Inches   = 147.142         -          Expected Inches = 146.693 Error = -0.449 Inches
(149.40s) Detector = 2 Reader = 0 DTO = 1.120 Smiles DOD = 1.123 Smiles Delta DTO = 0.216 Smiles (285.661 inches) Delta DOD = 0.217 Smiles Error = -0.001 Smiles 
   DCH      = 139.848 Seconds - DCH      Calculated Smph = 29.939 Error = -0.061 Smph
   Run Time = 140.200 Seconds - Run Time Calculated Smph = 29.964 Error = -0.036 Smph
   Inches   = 285.661         -          Expected Inches = 286.093 Error = 0.433 Inches
(162.10s) Detector = 4 Reader = 0 DTO = 1.225 Smiles DOD = 1.228 Smiles Delta DTO = 0.106 Smiles (139.761 inches) Delta DOD = 0.105 Smiles Error = 0.000 Smiles 
   DCH      = 152.524 Seconds - DCH      Calculated Smph = 30.070 Error = 0.070 Smph
   Run Time = 152.900 Seconds - Run Time Calculated Smph = 30.013 Error = 0.013 Smph
   Inches   = 139.761         -          Expected Inches = 139.805 Error = 0.044 Inches
(187.60s) Detector = 5 Reader = 0 DTO = 1.438 Smiles DOD = 1.441 Smiles Delta DTO = 0.212 Smiles (280.447 inches) Delta DOD = 0.213 Smiles Error = -0.001 Smiles 
   DCH      = 178.035 Seconds - DCH      Calculated Smph = 29.981 Error = -0.019 Smph
   Run Time = 178.400 Seconds - Run Time Calculated Smph = 29.994 Error = -0.006 Smph
   Inches   = 280.447         -          Expected Inches = 280.153 Error = -0.294 Inches
(191.30s) Detector = 3 Reader = 0 DTO = 1.468 Smiles DOD = 1.471 Smiles Delta DTO = 0.031 Smiles (40.348 inches) Delta DOD = 0.030 Smiles Error = 0.000 Smiles 
   DCH      = 181.739 Seconds - DCH      Calculated Smph = 29.710 Error = -0.290 Smph
   Run Time = 182.100 Seconds - Run Time Calculated Smph = 29.740 Error = -0.260 Smph
   Inches   = 40.348         -          Expected Inches = 40.564 Error = 0.216 Inches
(196.30s) Detector = 5 Reader = 1 DTO = 1.511 Smiles DOD = 1.514 Smiles Delta DTO = 0.042 Smiles (55.899 inches) Delta DOD = 0.043 Smiles Error = -0.001 Smiles 
   DCH      = 186.783 Seconds - DCH      Calculated Smph = 30.220 Error = 0.220 Smph
   Run Time = 187.200 Seconds - Run Time Calculated Smph = 29.892 Error = -0.108 Smph
   Inches   = 55.899         -          Expected Inches = 56.647 Error = 0.749 Inches
(215.30s) Detector = 1 Reader = 0 DTO = 1.669 Smiles DOD = 1.671 Smiles Delta DTO = 0.158 Smiles (208.465 inches) Delta DOD = 0.157 Smiles Error = 0.001 Smiles 
   DCH      = 205.717 Seconds - DCH      Calculated Smph = 30.028 Error = 0.028 Smph
   Run Time = 206.000 Seconds - Run Time Calculated Smph = 30.242 Error = 0.242 Smph
   Inches   = 208.465         -          Expected Inches = 207.289 Error = -1.176 Inches
(301.80s) Detector = 4 Reader = 1 DTO = 2.390 Smiles DOD = 2.392 Smiles Delta DTO = 0.721 Smiles (951.659 inches) Delta DOD = 0.721 Smiles Error = 0.000 Smiles 
   DCH      = 292.276 Seconds - DCH      Calculated Smph = 29.985 Error = -0.015 Smph
   Run Time = 292.600 Seconds - Run Time Calculated Smph = 29.970 Error = -0.030 Smph
   Inches   = 951.659         -          Expected Inches = 952.718 Error = 1.059 Inches
(315.10s) Detector = 2 Reader = 1 DTO = 2.500 Smiles DOD = 2.504 Smiles Delta DTO = 0.111 Smiles (146.161 inches) Delta DOD = 0.112 Smiles Error = -0.001 Smiles 
   DCH      = 305.527 Seconds - DCH      Calculated Smph = 30.084 Error = 0.084 Smph
   Run Time = 305.900 Seconds - Run Time Calculated Smph = 29.971 Error = -0.029 Smph
   Inches   = 146.161         -          Expected Inches = 146.693 Error = 0.532 Inches
(341.00s) Detector = 2 Reader = 0 DTO = 2.717 Smiles DOD = 2.721 Smiles Delta DTO = 0.217 Smiles (285.999 inches) Delta DOD = 0.217 Smiles Error = -0.001 Smiles 
   DCH      = 331.517 Seconds - DCH      Calculated Smph = 30.011 Error = 0.011 Smph
   Run Time = 331.900 Seconds - Run Time Calculated Smph = 30.000 Error = -0.000 Smph
   Inches   = 285.999         -          Expected Inches = 286.093 Error = 0.094 Inches
(353.80s) Detector = 4 Reader = 0 DTO = 2.823 Smiles DOD = 2.827 Smiles Delta DTO = 0.106 Smiles (139.755 inches) Delta DOD = 0.105 Smiles Error = 0.000 Smiles 
   DCH      = 344.224 Seconds - DCH      Calculated Smph = 29.994 Error = -0.006 Smph
   Run Time = 344.600 Seconds - Run Time Calculated Smph = 30.012 Error = 0.012 Smph
   Inches   = 139.755         -          Expected Inches = 139.805 Error = 0.050 Inches
(380.30s) Detector = 5 Reader = 0 DTO = 3.036 Smiles DOD = 3.040 Smiles Delta DTO = 0.213 Smiles (280.769 inches) Delta DOD = 0.213 Smiles Error = -0.000 Smiles 
   DCH      = 370.725 Seconds - DCH      Calculated Smph = 28.895 Error = -1.105 Smph
   Run Time = 370.100 Seconds - Run Time Calculated Smph = 30.029 Error = 0.029 Smph
   Inches   = 280.769         -          Expected Inches = 280.153 Error = -0.616 Inches
(383.00s) Detector = 3 Reader = 0 DTO = 3.066 Smiles DOD = 3.070 Smiles Delta DTO = 0.030 Smiles (40.009 inches) Delta DOD = 0.030 Smiles Error = 0.000 Smiles 
   DCH      = 373.439 Seconds - DCH      Calculated Smph = 40.206 Error = 10.206 Smph
   Run Time = 373.800 Seconds - Run Time Calculated Smph = 29.491 Error = -0.509 Smph
   Inches   = 40.009         -          Expected Inches = 40.564 Error = 0.555 Inches
(388.00s) Detector = 5 Reader = 1 DTO = 3.109 Smiles DOD = 3.113 Smiles Delta DTO = 0.043 Smiles (56.243 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 378.484 Seconds - DCH      Calculated Smph = 30.406 Error = 0.406 Smph
   Run Time = 378.900 Seconds - Run Time Calculated Smph = 30.076 Error = 0.076 Smph
   Inches   = 56.243         -          Expected Inches = 56.647 Error = 0.405 Inches
(408.00s) Detector = 1 Reader = 0 DTO = 3.275 Smiles DOD = 3.278 Smiles Delta DTO = 0.166 Smiles (219.158 inches) Delta DOD = 0.166 Smiles Error = 0.000 Smiles 
   DCH      = 398.439 Seconds - DCH      Calculated Smph = 29.952 Error = -0.048 Smph
   Run Time = 397.800 Seconds - Run Time Calculated Smph = 31.625 Error = 1.625 Smph
   Inches   = 219.158         -          Expected Inches = 207.289 Error = -11.869 Inches
(493.50s) Detector = 4 Reader = 1 DTO = 3.987 Smiles DOD = 3.990 Smiles Delta DTO = 0.713 Smiles (940.955 inches) Delta DOD = 0.712 Smiles Error = 0.001 Smiles 
   DCH      = 483.945 Seconds - DCH      Calculated Smph = 30.013 Error = 0.013 Smph
   Run Time = 484.300 Seconds - Run Time Calculated Smph = 29.668 Error = -0.332 Smph
   Inches   = 940.955         -          Expected Inches = 952.718 Error = 11.763 Inches
(506.80s) Detector = 2 Reader = 1 DTO = 4.098 Smiles DOD = 4.102 Smiles Delta DTO = 0.111 Smiles (146.494 inches) Delta DOD = 0.112 Smiles Error = -0.001 Smiles 
   DCH      = 497.323 Seconds - DCH      Calculated Smph = 29.864 Error = -0.136 Smph
   Run Time = 497.700 Seconds - Run Time Calculated Smph = 29.816 Error = -0.184 Smph
   Inches   = 146.494         -          Expected Inches = 146.693 Error = 0.200 Inches
(532.80s) Detector = 2 Reader = 0 DTO = 4.316 Smiles DOD = 4.320 Smiles Delta DTO = 0.217 Smiles (286.665 inches) Delta DOD = 0.217 Smiles Error = -0.000 Smiles 
   DCH      = 523.313 Seconds - DCH      Calculated Smph = 30.081 Error = 0.081 Smph
   Run Time = 523.700 Seconds - Run Time Calculated Smph = 30.070 Error = 0.070 Smph
   Inches   = 286.665         -          Expected Inches = 286.093 Error = -0.571 Inches
(545.90s) Detector = 4 Reader = 0 DTO = 4.424 Smiles DOD = 4.427 Smiles Delta DTO = 0.109 Smiles (143.366 inches) Delta DOD = 0.108 Smiles Error = 0.001 Smiles 
   DCH      = 536.404 Seconds - DCH      Calculated Smph = 29.868 Error = -0.132 Smph
   Run Time = 536.300 Seconds - Run Time Calculated Smph = 31.032 Error = 1.032 Smph
   Inches   = 143.366         -          Expected Inches = 139.805 Error = -3.561 Inches
tag(569.40s) : Detector 5 Reader 0 Eng#16 P&LE RS-3 #8356 Front Truck
FetchDTO=4.633902 raw=1102901 DTOFACTOR=11.000000 ScaleFactor=21637.00 
FetchDOD=176.335788 raw=81971 DODFACTOR=46.545455 ScaleFactor=21637.00 
FetchDCH=675580.928298 raw=21158992 DCH FACTOR=31.319700
(571.00s) Detector = 5 Reader = 0 DTO = 4.634 Smiles DOD = 4.638 Smiles Delta DTO = 0.210 Smiles (276.831 inches) Delta DOD = 0.211 Smiles Error = -0.001 Smiles 
   DCH      = 561.532 Seconds - DCH      Calculated Smph = 30.046 Error = 0.046 Smph
   Run Time = 561.900 Seconds - Run Time Calculated Smph = 29.492 Error = -0.508 Smph
   Inches   = 276.831         -          Expected Inches = 280.153 Error = 3.322 Inches
response(571.10) : Detector 5 Reader 0 Packet Type = 0x21
response(571.10) : Detector 5 Reader 0 Packet Type = 0x21
response(571.10) : Detector 5 Reader 0 Packet Type = 0x21
response(572.00) : Detector 5 Reader 0 Packet Type = 0x21
tag(573.10s) : Detector 3 Reader 0 Eng#16 P&LE RS-3 #8356 Front Truck
FetchDTO=4.664968 raw=1110295 DTOFACTOR=11.000000 ScaleFactor=21637.00 
FetchDOD=176.365905 raw=81985 DODFACTOR=46.545455 ScaleFactor=21637.00 
FetchDCH=675584.695894 raw=21159110 DCH FACTOR=31.319700
(574.80s) Detector = 3 Reader = 0 DTO = 4.665 Smiles DOD = 4.668 Smiles Delta DTO = 0.031 Smiles (41.008 inches) Delta DOD = 0.030 Smiles Error = 0.001 Smiles 
   DCH      = 565.299 Seconds - DCH      Calculated Smph = 29.684 Error = -0.316 Smph
   Run Time = 565.600 Seconds - Run Time Calculated Smph = 30.227 Error = 0.227 Smph
   Inches   = 41.008         -          Expected Inches = 40.564 Error = -0.444 Inches
response(574.80) : Detector 3 Reader 0 Packet Type = 0x21
response(574.80) : Detector 5 Reader 0 Packet Type = 0x21
response(574.80) : Detector 3 Reader 0 Packet Type = 0x21
response(574.80) : Detector 5 Reader 0 Packet Type = 0x21
response(574.80) : Detector 3 Reader 0 Packet Type = 0x21
response(575.60) : Detector 3 Reader 0 Packet Type = 0x21
response(577.20) : Detector 3 Reader 0 Packet Type = 0x21
response(578.10) : Detector 3 Reader 0 Packet Type = 0x21
tag(578.20s) : Detector 5 Reader 1 Eng#16 P&LE RS-3 #8356 Front Truck
FetchDTO=4.707311 raw=1120373 DTOFACTOR=11.000000 ScaleFactor=21637.00 
FetchDOD=176.408929 raw=82005 DODFACTOR=46.545455 ScaleFactor=21637.00 
FetchDCH=675589.740642 raw=21159268 DCH FACTOR=31.319700
(579.90s) Detector = 5 Reader = 1 DTO = 4.707 Smiles DOD = 4.711 Smiles Delta DTO = 0.042 Smiles (55.893 inches) Delta DOD = 0.043 Smiles Error = -0.001 Smiles 
   DCH      = 570.344 Seconds - DCH      Calculated Smph = 30.217 Error = 0.217 Smph
   Run Time = 570.700 Seconds - Run Time Calculated Smph = 29.889 Error = -0.111 Smph
   Inches   = 55.893         -          Expected Inches = 56.647 Error = 0.754 Inches
response(579.90) : Detector 5 Reader 1 Packet Type = 0x21
response(579.90) : Detector 5 Reader 1 Packet Type = 0x21
response(579.90) : Detector 5 Reader 1 Packet Type = 0x21
response(580.70) : Detector 5 Reader 1 Packet Type = 0x21
response(582.30) : Detector 5 Reader 1 Packet Type = 0x21
response(583.20) : Detector 5 Reader 1 Packet Type = 0x21
(598.90s) Detector = 1 Reader = 0 DTO = 4.865 Smiles DOD = 4.868 Smiles Delta DTO = 0.157 Smiles (207.783 inches) Delta DOD = 0.157 Smiles Error = 0.000 Smiles 
   DCH      = 589.342 Seconds - DCH      Calculated Smph = 29.829 Error = -0.171 Smph
   Run Time = 589.600 Seconds - Run Time Calculated Smph = 29.983 Error = -0.017 Smph
   Inches   = 207.783         -          Expected Inches = 207.289 Error = -0.494 Inches
(685.80s) Detector = 4 Reader = 1 DTO = 5.589 Smiles DOD = 5.593 Smiles Delta DTO = 0.725 Smiles (956.634 inches) Delta DOD = 0.725 Smiles Error = -0.000 Smiles 
   DCH      = 676.252 Seconds - DCH      Calculated Smph = 30.020 Error = 0.020 Smph
   Run Time = 676.200 Seconds - Run Time Calculated Smph = 30.127 Error = 0.127 Smph
   Inches   = 956.634         -          Expected Inches = 952.718 Error = -3.916 Inches
(698.70s) Detector = 2 Reader = 1 DTO = 5.698 Smiles DOD = 5.701 Smiles Delta DTO = 0.108 Smiles (143.183 inches) Delta DOD = 0.108 Smiles Error = 0.001 Smiles 
   DCH      = 689.183 Seconds - DCH      Calculated Smph = 30.198 Error = 0.198 Smph
   Run Time = 689.600 Seconds - Run Time Calculated Smph = 29.142 Error = -0.858 Smph
   Inches   = 143.183         -          Expected Inches = 146.693 Error = 3.511 Inches
(724.80s) Detector = 2 Reader = 0 DTO = 5.915 Smiles DOD = 5.918 Smiles Delta DTO = 0.217 Smiles (286.365 inches) Delta DOD = 0.217 Smiles Error = -0.000 Smiles 
   DCH      = 715.269 Seconds - DCH      Calculated Smph = 29.939 Error = -0.061 Smph
   Run Time = 715.600 Seconds - Run Time Calculated Smph = 30.038 Error = 0.038 Smph
   Inches   = 286.365         -          Expected Inches = 286.093 Error = -0.272 Inches
(737.40s) Detector = 4 Reader = 0 DTO = 6.020 Smiles DOD = 6.023 Smiles Delta DTO = 0.106 Smiles (139.406 inches) Delta DOD = 0.105 Smiles Error = 0.000 Smiles 
   DCH      = 727.912 Seconds - DCH      Calculated Smph = 30.070 Error = 0.070 Smph
   Run Time = 728.300 Seconds - Run Time Calculated Smph = 29.937 Error = -0.063 Smph
   Inches   = 139.406         -          Expected Inches = 139.805 Error = 0.399 Inches
(764.00s) Detector = 5 Reader = 0 DTO = 6.242 Smiles DOD = 6.245 Smiles Delta DTO = 0.221 Smiles (291.850 inches) Delta DOD = 0.222 Smiles Error = -0.000 Smiles 
   DCH      = 754.509 Seconds - DCH      Calculated Smph = 29.927 Error = -0.073 Smph
   Run Time = 753.800 Seconds - Run Time Calculated Smph = 31.214 Error = 1.214 Smph
   Inches   = 291.850         -          Expected Inches = 280.153 Error = -11.697 Inches
(766.70s) Detector = 3 Reader = 0 DTO = 6.264 Smiles DOD = 6.266 Smiles Delta DTO = 0.022 Smiles (29.555 inches) Delta DOD = 0.022 Smiles Error = 0.001 Smiles 
   DCH      = 757.191 Seconds - DCH      Calculated Smph = 30.054 Error = 0.054 Smph
   Run Time = 757.500 Seconds - Run Time Calculated Smph = 21.785 Error = -8.215 Smph
   Inches   = 29.555         -          Expected Inches = 40.564 Error = 11.009 Inches
(771.80s) Detector = 5 Reader = 1 DTO = 6.307 Smiles DOD = 6.309 Smiles Delta DTO = 0.043 Smiles (56.592 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 762.268 Seconds - DCH      Calculated Smph = 30.402 Error = 0.402 Smph
   Run Time = 762.600 Seconds - Run Time Calculated Smph = 30.263 Error = 0.263 Smph
   Inches   = 56.592         -          Expected Inches = 56.647 Error = 0.055 Inches
(790.70s) Detector = 1 Reader = 0 DTO = 6.464 Smiles DOD = 6.466 Smiles Delta DTO = 0.157 Smiles (207.434 inches) Delta DOD = 0.157 Smiles Error = 0.000 Smiles 
   DCH      = 781.170 Seconds - DCH      Calculated Smph = 29.930 Error = -0.070 Smph
   Run Time = 781.500 Seconds - Run Time Calculated Smph = 29.933 Error = -0.067 Smph
   Inches   = 207.434         -          Expected Inches = 207.289 Error = -0.144 Inches
(877.40s) Detector = 4 Reader = 1 DTO = 7.186 Smiles DOD = 7.189 Smiles Delta DTO = 0.722 Smiles (953.006 inches) Delta DOD = 0.723 Smiles Error = -0.001 Smiles 
   DCH      = 867.856 Seconds - DCH      Calculated Smph = 29.983 Error = -0.017 Smph
   Run Time = 868.100 Seconds - Run Time Calculated Smph = 30.013 Error = 0.013 Smph
   Inches   = 953.006         -          Expected Inches = 952.718 Error = -0.288 Inches
(890.70s) Detector = 2 Reader = 1 DTO = 7.297 Smiles DOD = 7.301 Smiles Delta DTO = 0.111 Smiles (147.165 inches) Delta DOD = 0.112 Smiles Error = -0.000 Smiles 
   DCH      = 881.171 Seconds - DCH      Calculated Smph = 30.145 Error = 0.145 Smph
   Run Time = 881.500 Seconds - Run Time Calculated Smph = 29.952 Error = -0.048 Smph
   Inches   = 147.165         -          Expected Inches = 146.693 Error = -0.471 Inches
(917.00s) Detector = 2 Reader = 0 DTO = 7.514 Smiles DOD = 7.518 Smiles Delta DTO = 0.217 Smiles (286.027 inches) Delta DOD = 0.217 Smiles Error = -0.001 Smiles 
   DCH      = 907.480 Seconds - DCH      Calculated Smph = 29.650 Error = -0.350 Smph
   Run Time = 907.500 Seconds - Run Time Calculated Smph = 30.003 Error = 0.003 Smph
   Inches   = 286.027         -          Expected Inches = 286.093 Error = 0.067 Inches
(929.40s) Detector = 4 Reader = 0 DTO = 7.620 Smiles DOD = 7.624 Smiles Delta DTO = 0.106 Smiles (140.049 inches) Delta DOD = 0.105 Smiles Error = 0.001 Smiles 
   DCH      = 919.868 Seconds - DCH      Calculated Smph = 30.831 Error = 0.831 Smph
   Run Time = 920.200 Seconds - Run Time Calculated Smph = 30.075 Error = 0.075 Smph
   Inches   = 140.049         -          Expected Inches = 139.805 Error = -0.244 Inches
(954.90s) Detector = 5 Reader = 0 DTO = 7.833 Smiles DOD = 7.837 Smiles Delta DTO = 0.212 Smiles (280.420 inches) Delta DOD = 0.213 Smiles Error = -0.001 Smiles 
   DCH      = 945.411 Seconds - DCH      Calculated Smph = 29.941 Error = -0.059 Smph
   Run Time = 945.800 Seconds - Run Time Calculated Smph = 29.874 Error = -0.126 Smph
   Inches   = 280.420         -          Expected Inches = 280.153 Error = -0.266 Inches
(958.60s) Detector = 3 Reader = 0 DTO = 7.863 Smiles DOD = 7.867 Smiles Delta DTO = 0.031 Smiles (40.320 inches) Delta DOD = 0.030 Smiles Error = 0.000 Smiles 
   DCH      = 949.115 Seconds - DCH      Calculated Smph = 29.690 Error = -0.310 Smph
   Run Time = 949.400 Seconds - Run Time Calculated Smph = 30.545 Error = 0.545 Smph
   Inches   = 40.320         -          Expected Inches = 40.564 Error = 0.244 Inches
(963.70s) Detector = 5 Reader = 1 DTO = 7.906 Smiles DOD = 7.910 Smiles Delta DTO = 0.043 Smiles (56.265 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 954.160 Seconds - DCH      Calculated Smph = 30.418 Error = 0.418 Smph
   Run Time = 954.500 Seconds - Run Time Calculated Smph = 30.088 Error = 0.088 Smph
   Inches   = 56.265         -          Expected Inches = 56.647 Error = 0.383 Inches
(983.50s) Detector = 1 Reader = 0 DTO = 8.072 Smiles DOD = 8.076 Smiles Delta DTO = 0.166 Smiles (218.825 inches) Delta DOD = 0.166 Smiles Error = 0.000 Smiles 
   DCH      = 974.051 Seconds - DCH      Calculated Smph = 30.002 Error = 0.002 Smph
   Run Time = 973.400 Seconds - Run Time Calculated Smph = 31.577 Error = 1.577 Smph
   Inches   = 218.825         -          Expected Inches = 207.289 Error = -11.536 Inches
(1069.20s) Detector = 4 Reader = 1 DTO = 8.785 Smiles DOD = 8.788 Smiles Delta DTO = 0.713 Smiles (941.648 inches) Delta DOD = 0.712 Smiles Error = 0.001 Smiles 
   DCH      = 1059.684 Seconds - DCH      Calculated Smph = 29.990 Error = -0.010 Smph
   Run Time = 1060.000 Seconds - Run Time Calculated Smph = 29.655 Error = -0.345 Smph
   Inches   = 941.648         -          Expected Inches = 952.718 Error = 11.070 Inches
(1082.50s) Detector = 2 Reader = 1 DTO = 8.896 Smiles DOD = 8.900 Smiles Delta DTO = 0.111 Smiles (146.810 inches) Delta DOD = 0.112 Smiles Error = -0.001 Smiles 
   DCH      = 1073.063 Seconds - DCH      Calculated Smph = 29.929 Error = -0.071 Smph
   Run Time = 1073.400 Seconds - Run Time Calculated Smph = 29.880 Error = -0.120 Smph
   Inches   = 146.810         -          Expected Inches = 146.693 Error = -0.116 Inches
(1108.50s) Detector = 2 Reader = 0 DTO = 9.113 Smiles DOD = 9.117 Smiles Delta DTO = 0.217 Smiles (286.398 inches) Delta DOD = 0.217 Smiles Error = -0.000 Smiles 
   DCH      = 1099.053 Seconds - DCH      Calculated Smph = 30.053 Error = 0.053 Smph
   Run Time = 1099.400 Seconds - Run Time Calculated Smph = 30.042 Error = 0.042 Smph
   Inches   = 286.398         -          Expected Inches = 286.093 Error = -0.305 Inches
(1121.20s) Detector = 4 Reader = 0 DTO = 9.219 Smiles DOD = 9.222 Smiles Delta DTO = 0.106 Smiles (139.395 inches) Delta DOD = 0.105 Smiles Error = 0.000 Smiles 
   DCH      = 1111.728 Seconds - DCH      Calculated Smph = 29.992 Error = -0.008 Smph
   Run Time = 1112.100 Seconds - Run Time Calculated Smph = 29.934 Error = -0.066 Smph
   Inches   = 139.395         -          Expected Inches = 139.805 Error = 0.410 Inches
(1146.80s) Detector = 5 Reader = 0 DTO = 9.432 Smiles DOD = 9.435 Smiles Delta DTO = 0.213 Smiles (281.113 inches) Delta DOD = 0.213 Smiles Error = -0.000 Smiles 
   DCH      = 1137.303 Seconds - DCH      Calculated Smph = 29.977 Error = -0.023 Smph
   Run Time = 1137.600 Seconds - Run Time Calculated Smph = 30.066 Error = 0.066 Smph
   Inches   = 281.113         -          Expected Inches = 280.153 Error = -0.959 Inches
(1150.50s) Detector = 3 Reader = 0 DTO = 9.463 Smiles DOD = 9.465 Smiles Delta DTO = 0.031 Smiles (40.669 inches) Delta DOD = 0.030 Smiles Error = 0.001 Smiles 
   DCH      = 1141.007 Seconds - DCH      Calculated Smph = 29.947 Error = -0.053 Smph
   Run Time = 1141.300 Seconds - Run Time Calculated Smph = 29.977 Error = -0.023 Smph
   Inches   = 40.669         -          Expected Inches = 40.564 Error = -0.105 Inches
(1155.60s) Detector = 5 Reader = 1 DTO = 9.505 Smiles DOD = 9.508 Smiles Delta DTO = 0.043 Smiles (56.559 inches) Delta DOD = 0.043 Smiles Error = -0.000 Smiles 
   DCH      = 1146.116 Seconds - DCH      Calculated Smph = 30.194 Error = 0.194 Smph
   Run Time = 1146.400 Seconds - Run Time Calculated Smph = 30.245 Error = 0.245 Smph
   Inches   = 56.559         -          Expected Inches = 56.647 Error = 0.089 Inches
(1174.50s) Detector = 1 Reader = 0 DTO = 9.662 Smiles DOD = 9.665 Smiles Delta DTO = 0.157 Smiles (207.134 inches) Delta DOD = 0.157 Smiles Error = -0.000 Smiles 
   DCH      = 1164.986 Seconds - DCH      Calculated Smph = 29.937 Error = -0.063 Smph
   Run Time = 1165.300 Seconds - Run Time Calculated Smph = 29.889 Error = -0.111 Smph
   Inches   = 207.134         -          Expected Inches = 207.289 Error = 0.155 Inches
(1261.10s) Detector = 4 Reader = 1 DTO = 10.385 Smiles DOD = 10.388 Smiles Delta DTO = 0.722 Smiles (953.361 inches) Delta DOD = 0.723 Smiles Error = -0.001 Smiles 
   DCH      = 1251.640 Seconds - DCH      Calculated Smph = 30.005 Error = 0.005 Smph
   Run Time = 1251.900 Seconds - Run Time Calculated Smph = 30.024 Error = 0.024 Smph
   Inches   = 953.361         -          Expected Inches = 952.718 Error = -0.643 Inches
(1274.40s) Detector = 2 Reader = 1 DTO = 10.496 Smiles DOD = 10.500 Smiles Delta DTO = 0.111 Smiles (146.821 inches) Delta DOD = 0.112 Smiles Error = -0.001 Smiles 
   DCH      = 1264.955 Seconds - DCH      Calculated Smph = 30.074 Error = 0.074 Smph
   Run Time = 1265.300 Seconds - Run Time Calculated Smph = 29.882 Error = -0.118 Smph
   Inches   = 146.821         -          Expected Inches = 146.693 Error = -0.128 Inches
(1300.40s) Detector = 2 Reader = 0 DTO = 10.712 Smiles DOD = 10.715 Smiles Delta DTO = 0.217 Smiles (286.016 inches) Delta DOD = 0.215 Smiles Error = 0.002 Smiles 
   DCH      = 1290.977 Seconds - DCH      Calculated Smph = 29.976 Error = -0.024 Smph
   Run Time = 1291.300 Seconds - Run Time Calculated Smph = 30.002 Error = 0.002 Smph
   Inches   = 286.016         -          Expected Inches = 286.093 Error = 0.078 Inches
(1313.20s) Detector = 4 Reader = 0 DTO = 10.819 Smiles DOD = 10.823 Smiles Delta DTO = 0.106 Smiles (140.376 inches) Delta DOD = 0.108 Smiles Error = -0.001 Smiles 
   DCH      = 1303.748 Seconds - DCH      Calculated Smph = 29.976 Error = -0.024 Smph
   Run Time = 1304.000 Seconds - Run Time Calculated Smph = 30.145 Error = 0.145 Smph
   Inches   = 140.376         -          Expected Inches = 139.805 Error = -0.571 Inches
[STOP]
Run Time = 1341.00 Seconds
Trip Odometer Finish 10.99 Smiles
{[10] = {[41] = 952.00813421454, }, [41] = {[21] = 147.14239497158, }, [21] = {[20] = 285.66067384573, }, [20] = {[40] = 139.76059527661, }, [40] = {[50] = 280.44738179969, }, [50] = {[30] = 40.347552803069, }, [30] = {[51] = 55.898692055276, }, [51] = {[10] = 208.46512917687, }, [10] = {[41] = 951.65873272635, }, [41] = {[21] = 146.16074317142, }, [21] = {[20] = 285.99898322318, }, [20] = {[40] = 139.75504922124, }, [40] = {[50] = 280.76905301105, }, [50] = {[30] = 40.009243425614, }, [30] = {[51] = 56.242547488099, }, [51] = {[10] = 219.15792392661, }, [10] = {[41] = 940.95484586588, }, [41] = {[21] = 146.49350649351, }, [21] = {[20] = 286.66450986736, }, [20] = {[40] = 143.36553126589, }, [40] = {[50] = 276.83135369968, }, [50] = {[30] = 41.007533391874, }, [30] = {[51] = 55.893145999908, }, [51] = {[10] = 207.78296436659, }, [10] = {[41] = 956.63354439155, }, [41] = {[21] = 143.18251143874, }, [21] = {[20] = 286.36502287748, }, [20] = {[40] = 139.40564773305, }, [40] = {[50] = 291.85007163655, }, [50] = {[30] = 29.554929056708, }, [30] = {[51] = 56.591948976291, }, [51] = {[10] = 207.4335628784, }, [10] = {[41] = 953.0064241808, }, [41] = {[21] = 147.16457919305, }, [21] = {[20] = 286.02671350002, }, [20] = {[40] = 140.04899015575, }, [40] = {[50] = 280.41965152286, }, [50] = {[30] = 40.319822526228, }, [30] = {[51] = 56.264731709571, }, [51] = {[10] = 218.82516060452, }, [10] = {[41] = 941.64810278689, }, [41] = {[21] = 146.80963164949, }, [21] = {[20] = 286.39829920969, }, [20] = {[40] = 139.39455562231, }, [40] = {[50] = 281.11290844387, }, [50] = {[30] = 40.66922401442, }, [30] = {[51] = 56.558672644084, }, [51] = {[10] = 207.13407588852, }, [10] = {[41] = 953.36137172436, }, [41] = {[21] = 146.82072376023, }, [21] = {[20] = 286.01562138929, }, [20] = {[40] = 140.37620742247, }, }
All Newly Detected Tags:
B62E144A  8810020103010D012302202038333536
E63F1A4A  8810010103010D012302202038333536
cleanup() Complete at 1341.00


--------------------------------------------------------------------------------]]
