//---------------------------------------------------------------------------
/*
 * RTCMegaMaster.h
 *
Remote Train Control Program for Windows

(c) Copyright 2018 by Mark DiVecchio <markd@silogic.com>

    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/.
*/
//---------------------------------------------------------------------------
/*
 * Author: Mark DiVecchio
 * Creation date: 26 Mar 2018
 *
 * Description: Header file
 *
 */
//---------------------------------------------------------------------------

#ifndef _RTCMEGAMASTER_H
#define _RTCMEGAMASTER_H

/**
 * Firmware version
 */
#define V1 '0'
#define V2 '4'
#define V3 '2'
#define V4 '1'

#define SERIAL_BUF_LEN           128     // Maximum length for any serial string being transmitted

#define TIMER1_TICK_PERIOD_US    100000L  // Timer1 tick in microseconds
#define TICKSPERSECOND (1000000L/TIMER1_TICK_PERIOD_US) // Ticks per second
#define MAX_SERIAL_SILENCE_MS    1000    // Maximum serial silence between serial command characters in milliseconds
#define MAX_SERIAL_SILENCE_TK    MAX_SERIAL_SILENCE_MS / (TIMER1_TICK_PERIOD_US / 1000)  // Max serial silence in ticks
#define MAX_LED_MS    200                                           // LED hold time ms
#define MAX_LED_TK    MAX_LED_MS / (TIMER1_TICK_PERIOD_US / 1000)   // LED hold time in ticks
#define MAX_DETECT_MS 500                                             // Tag detection hold time ms
#define MAX_DETECT_TK MAX_DETECT_MS / (TIMER1_TICK_PERIOD_US / 1000)  // Tag Detection hold time in ticks

// Record Flags
#define RECORD_OK true
#define NO_RECORD false

#define LASHUP_ENGINE_LIST_LENGTH 128
#define CMDMAX 512						// max size of any comand to/from the TIU in characters

//---------------------------------------------------------------------------
// Delayed commands
enum DCommand {DC_NULL = 0, DC_BELLOFF, DC_PFA_DIR, DC_PFA_PFA, DC_PFA_DONE, DC_BELLON, DC_XING, DC_8SHORT, DC_2LONG,
	DC_1LONG, DC_1LONG_2SHORT, DC_2SHORT, DC_3SHORT, DC_SETSPEED,
    DC_DIR, DC_DIR_FORWARD, DC_DIR_REVERSE, DC_HDLT_ON, DC_HDLT_OFF,
    DC_HDLT_OFF_IF_STOPPED, DC_SXS,
    DC_BEACON, DC_BEACON_ON, DC_BEACON_OFF,
    DC_MARS, DC_MARS_ON, DC_MARS_OFF,
    DC_MARKERS_ON, DC_MARKERS_OFF,
    DC_HORN_WHISTLE_ON, DC_HORN_WHISTLE_OFF,
    DC_BELLOFF_WITH_HORN, DC_BELLON_WITH_HORN,
    DC_MASTER_VOLUME_OFF, DC_MASTER_VOLUME,
    DC_ENGINE_VOLUME_OFF, DC_ENGINE_VOLUME,
    DC_ACCENT_VOLUME_OFF, DC_ACCENT_VOLUME,
    DC_HORN_WHISTLE_VOLUME_OFF, DC_HORN_WHISTLE_VOLUME,
    DC_BELL_VOLUME_OFF, DC_BELL_VOLUME,
    DC_PLAY_SOUND, DC_AB, DC_MPH,
    DC_CPLR_F, DC_CPLR_R,
    DC_AUX1_ON, DC_AUX1_OFF,
    DC_AUX2_ON, DC_AUX2_OFF,
    DC_AUX3_ON, DC_AUX3_OFF,
    DC_SMOKE_ON, DC_SMOKE_OFF,
    DC_SOUNDS_ON, DC_SOUNDS_OFF,
    DC_CHUFF_RATE_2, DC_CHUFF_RATE_4,
    DC_PROTO_CHUFF_ON, DC_PROTO_CHUFF_OFF,
    DC_BRAKE_SQUEAL_ON, DC_BRAKE_SQUEAL_OFF,
    DC_CAB_CHAT_ON, DC_CAB_CHAT_OFF,
    DC_CPLR_SLACK_ON, DC_CPLR_SLACK_OFF,
    DC_CLICK_CLACK_ON, DC_CLICK_CLACK_OFF,
    DC_PROTO_WHISTLE_ON, DC_PROTO_WHISTLE_OFF, DC_PROTO_WHISTLE,
    DC_SMOKE_WHISTLE_ON, DC_SMOKE_WHISTLE_OFF,
    DC_SWINGING_BELL_ON, DC_SWINGING_BELL_OFF,
	DC_SWITCH_NORMAL, DC_ACCESSORY_ON, DC_SWITCH_REVERSE, DC_ACCESSORY_OFF,
    DC_ENDOFLIST};
    
#define DSTRINGS {"DC_NULL", "DC_BELLOFF", "DC_PFA_DIR", "DC_PFA_PFA", "DC_PFA_DONE", "DC_BELLON", "DC_XING", "DC_8SHORT", "DC_2LONG",\
	"DC_1LONG", "DC_1LONG_2SHORT", "DC_2SHORT", "DC_3SHORT", "DC_SETSPEED",\
    "DC_DIR", "DC_DIR_FORWARD", "DC_DIR_REVERSE", "DC_HDLT_ON", "DC_HDLT_OFF",\
    "DC_HDLT_OFF_IF_STOPPED", "DC_SXS",\
    "DC_BEACON", "DC_BEACON_ON", "DC_BEACON_OFF",\
    "DC_MARS", "DC_MARS_ON", "DC_MARS_OFF",\
    "DC_MARKERS_ON", "DC_MARKERS_OFF",\
    "DC_HORN_WHISTLE_ON", "DC_HORN_WHISTLE_OFF",\
    "DC_BELLOFF_WITH_HORN", "DC_BELLON_WITH_HORN",\
    "DC_MASTER_VOLUME_OFF", "DC_MASTER_VOLUME",\
    "DC_ENGINE_VOLUME_OFF", "DC_ENGINE_VOLUME",\
    "DC_ACCENT_VOLUME_OFF", "DC_ACCENT_VOLUME",\
    "DC_HORN_VOLUME_OFF", "DC_HORN_VOLUME",\
    "DC_BELL_VOLUME_OFF", "DC_BELL_VOLUME",\
    "DC_PLAY_SOUND", "DC_AB", "DC_MPH",\
    "DC_CPLR_F", "DC_CPLR_R",\
    "DC_AUX1_ON", "DC_AUX1_OFF",\
    "DC_AUX2_ON", "DC_AUX2_OFF",\
    "DC_AUX3_ON", "DC_AUX3_OFF",\
    "DC_SMOKE_ON", "DC_SMOKE_OFF",\
    "DC_SOUNDS_ON", "DC_SOUNDS_OFF",\
    "DC_CHUFF_RATE_2", "DC_CHUFF_RATE_4",\
    "DC_PROTO_CHUFF_ON", "DC_PROTO_CHUFF_OFF",\
    "DC_BRAKE_SQUEAL_ON", "DC_BRAKE_SQUEAL_OFF",\
    "DC_CAB_CHAT_ON", "DC_CAB_CHAT_OFF",\
    "DC_CPLR_SLACK_ON", "DC_CPLR_SLACK_OFF",\
    "DC_CLICK_CLACK_ON", "DC_CLICK_CLACK_OFF",\
    "DC_PROTO_WHISTLE_ON", "DC_PROTO_WHISTLE_OFF", "DC_PROTO_WHISTLE",\
    "DC_SMOKE_WHISTLE_ON", "DC_SMOKE_WHISTLE_OFF",\
    "DC_SWINGING_BELL_ON", "DC_SWINGING_BELL_OFF",\
    "DC_SWITCH_NORMAL", "DC_ACCESSORY_ON", "DC_SWITCH_REVERSE", "DC_ACCESSORY_OFF",\
    "DC_ENDOFLIST"}

//---------------------------------------------------------------------------

// Forward Declarations
class TOp;

//---------------------------------------------------------------------------
/**
 * AT command set
 */
#define AT_ATTENTION           "at"   // Basic Attention command
// examples:
// at   RetroXFMR responds with "OK"
#define AT_RESET               "atz"  // Reset the CC1101
// atz
#define AT_HVERSION            "athv" // Report Hardware version
// athv
#define AT_FVERSION            "atfv" // Report Firmware version
// atfw
#define AT_FREQCHANNEL         "atch" // Frequency channel
// atch      report the channel in use (in hex)
// atch=xx   set channel to xx (where xx is channel in hexadecimal)
#define AT_STATUSREG           "atsr" // Status Register
// atsr xx    dump status register xx (where xx is register number in hex)
#define AT_CONFIGREG           "atcr" // Config Register
// examples:
// atcr xx      dump configuration register xx (where xx is register number in hex)
// atcr=xxyy    set configuration register xx with yy (where xx is register number in hex, yy is value to load in hex)
//              xxyy must be 4 characters, use leading zero if necessary
#define AT_DUMPCONFREG         "atdc"      // Dump All Configuration Registers
// atdc
#define AT_DUMPSTATREG         "atds" // Dump All Status Registers
// atds
#define AT_VOLTAGE             "atdv" // VCC in mV
// not working
#define AT_RX                  "atrx" // Go into RX State
// atrx
#define AT_TX                  "attx" // Go into TX State
// attx
#define AT_IDLE                "atid" // Go into Idle State
// atid
#define AT_DUMPPOWER           "atdp" // Dump all power registers
// atdp
#define AT_BELL                "atbl" // Bell
// examples:
// atbl     report whistle status
// atbl=1   set bell on
// abbl=0   set bell off
#define AT_WHISTLE             "atwh" // Whistle/Horn
// examples:
// atwh     report whistle status
// atwh=1   set whistle on
// atwh=0   set whistle off
#define AT_SS                  "atss" // Startup/Shutdown
// examples:
// atss     report engine status
// atss=1   Startup
// atss=0   Shutdown
#define AT_SPEED               "atsp" // Speed
// examples:
// atsp     report engine speed
// atsp=xx  set speed to xx where xx is speed in decimal
#define AT_DIR                 "atdr" // Direction
// examples:
// atdr     report engine direction
// atdr=0   set direction to reverse
// atdr=1   set direction to forward
#define AT_ENGINE              "aten" // Engine number
// examples:
// atco      report engine number (in decimal) to receive DCS commands
// atco=xx   set engine number to xx (where xx is engine number (1-99) in decimal)
#define AT_TIU                 "attu" // TIU Number
// examples:
// attu     report TIU number (in decimal) to receive DCS commands
// attu=x   set TIU number to x (where x is 1 to 5)
#define AT_REMOTE              "atrm" // Remote Number
// examples:
// atrm     report remote number (in decimal) emulated by RTCMegaMaster
// atrm=xx  set emulated remote number to xx (where xx is remote number (1-15) in decimal)
#define AT_SOUND               "atnn" // Play builtin sound
// example:
// atnn=x   play sound x (where x is a sound number (1-255) in decimal)
#define AT_V                    "atv" // set volume 
// example:
// atv0=100 set master volume to 100%
// atv1=90 set Engine volume to 90%
// atv2=0 set Accent volume to 0% (Mute)
// atv3=100 set Horn  volume to 100%
// atv4=50 set Bell volume to 50%

/**
 * Serial modes
 */
enum SERMODE
{
  SERMODE_DATA,
  SERMODE_COMMAND  
};

/**
 * Type of AT query
 */
enum ATQUERY
{
  ATQUERY_COMMAND = 0,
  ATQUERY_REQUEST
};
//---------------------------------------------------------------------------
/*
 * Structure that defines each entry in the dispatcher linked list
 *
 * Must queue up all of the information needed for:

 bool __fastcall TMainForm::TIUSendWaitforResponse(unsigned char Consist, byte * Command,
	int ExpectedCount, int WaitTime, unsigned char Remote, unsigned char TIU, int * RespCode,
    int * SWResponseCount, byte * SWResponseBuffer)
 * 
 *
 * About the Dispatch List
 * 
 * A command to the engine can be queued for future transmission. When such a delay is
 * needed, an entry in a dispatch list is created. The list entry is defined by the
 * struct Dispatch in RTCMegaMaster.h
 *
 * Two pointers at the top level of the sketch "first" and "last" are used by the
 * list manager to keep track of the list.
 *
 * Each entry contains:
 * DispatchItem * nxt;   // Pointer to next list item (NULL for tail of list).
 * DispatchItem * prv;   // Pointer to previous list item (NULL for head of list).
 * unsigned int  TVal;  // Timer value in milliseconds - always positive or zero - decremented in ESR.
 * byte EngineNo;        // Engine number for packet.
 * byte TIUNo;           // TIU number for packet.
 * char Command[CMDSIZE];    // Command to send, in ASCII, eg: "d0" or "s22" or "Ac2", NULL terminated.
 * int * Flag;           // Flag to set when Command is executed - must be int.
 * int FlagValue;        // Value to set into *Flag.
 * 
 * nxt and prv are pointers used the list manager to keep track of the list.
 * TVal is the number of milliseconds in the future to actually send the command.
 * EngineNo, TIUNo, and Command are used to build the command to send.
 * FlagValue and *Flag are a value and a pointer to a "int". When the command is sent,
 *    the FlagValue is stored into *Flag
 * 
 *
 * Routines:
 * AddToPCDispatchList() - add an item to the dispatch list (uses "new" to create the item)
 *    and increment PCDispatchListCount.
 * RemoveFromPCDispatchList() - remove an item from the dispatch list (uses "delete" to destory the item)
 *    and decrement PCDispatchListCount.
 * DumpPCDispatchList() - prints out the dispatch list
 * ClearPCDispatchList() - clears the dispatch list and frees all memory. Sets PCDispatchListCount to zero.
 * 
 * Timer Event Service Routine (ESR):
 * Each second, the ESR traverses the dispatch list and decrements TVal if it is not zero already.
 * The ESR uses ((!PCDispatchListClearInProgress) && (PCDispatchListCount != 0)) to enable this traversing.
 * If (PCDispatchListCount != 0), the main loop traverses the dispatch list
 * and if an item's TVal is zero, it sends the item's command to the engine and then removes the item
 * from the Program Control Dispatch List, decrementing PCDispatchListCount.
 * 
 */
struct DispatchItem {
  int Type;				// indicate the type of item in the dispatch list
  						// CMD_Type_SendString : requires all of the formating done by Send_String()
                        // CMD_Type_WaitForResponse : requires all of the formating done by TIUSendWaitForResponse()
                        // CMD_Type_SendHex : requires all of the work done by SendHexStr()
                        // CMD_Type_DelayedCommand : Not Used : Delayed commands are listed as regular commands in the Dispatch List
  DispatchItem * nxt;   // Pointer to next list item (NULL for tail of list).
  DispatchItem * prv;   // Pointer to previous list item (NULL for head of list).
  unsigned int TVal;	// Timer value in milliseconds - always positive or zero - decremented in ISR.
  byte ConsistNo;       // Engine/Consist number for packet.
  byte TIUNo;           // TIU number for packet.
  char Command[CMDMAX];	// 256 bytes - Command to send, encoded
  int Len;				// length of command - needed only by Type = 2
  byte Remote;			// Remote number to impersonate
  int * ipFlag;           // Pointer to flag to set when Command is executed - must be int.
  int FlagValue;        // Value to set into *Flag
  int ExpectedCount;	// Number of return bytes expected
  int WaitTime;			// Wait time for response in milliseconds
  bool Record_Flag;		// Recording in progress flag
  int * ptrRespCode;		// Pointer to return response code
  int * ResponseCount;		// Pointer to return actual number of bytes returned
  byte * ResponseBuffer;	// Pointer to return the actual response
  byte cLashUpEngineList[LASHUP_ENGINE_LIST_LENGTH];		// Lashup Engine List
  // next 4 items for DL_Type_DelayedCommand
  DCommand DelayedCommand;		// Delayed command
  int iParameter;  				// parameter for some delayed commands
  HWND Parent;					// Parent of window to take windows messages
  TOp * CallingOp;				// Handle of calling operations window

  DispatchItem() {
    Type = 0;
  	nxt = NULL;
    prv = NULL;
    TVal = 0;
    ConsistNo = 1;
    TIUNo = 1;
    Command[0] = '\0';
    ipFlag = NULL;
    FlagValue = 0;
    ExpectedCount = 11;
    WaitTime = 200;
    ptrRespCode = (int *) NULL;
    ResponseCount = (int *) NULL;
    ResponseBuffer = (byte *) NULL;
    Record_Flag = RECORD_OK;
    cLashUpEngineList[0] = '\0';
	//
    DelayedCommand = DC_NULL;		// Delayed command
	iParameter = 0; 				// parameter for some delayed commands
  	Parent = NULL;					// Parent of window to take windows messages
	CallingOp = NULL;				// Handle of calling operations window
    }
  ~DispatchItem() {
  	}
  };
//---------------------------------------------------------------------------
struct FIFOItem {
  int Type;				// indicate the type of item in the dispatch list
  						// CMD_Type_SendString : requires all of the formatting done by Send_String()
                        // CMD_Type_WaitForResponse : requires all of the formatting done by TIUSendWaitForResponse()
                        // CMD_Type_SendHex : requires all of the work done by SendHexStr()
                        // CMD_Type_DelayedCommand : go directly in to the Dispatch List
  unsigned int TVal;	// Timer value in milliseconds - always positive or zero - decremented in ISR.
  byte ConsistNo;       // Engine/Consist number for packet.
  byte TIUNo;           // TIU number for packet.
  char Command[CMDMAX];	// 256 bytes - Command to send, encoded
  int Len;				// length of command - needed only by Type = 2
  byte Remote;			// Remote number to impersonate
  int ExpectedCount;	// Number of return bytes expected
  int WaitTime;			// Wait time for response in milliseconds
  bool Record_Flag;		// Recording in progress flag
  int * ptrRespCode;			// Pointer to return response code
  int * ResponseCount;			// Pointer to return actual number of bytes returned
  byte * ResponseBuffer;		// Pointer to return the actual response
  byte cLashUpEngineList[LASHUP_ENGINE_LIST_LENGTH];		// Lashup Engine List
  HANDLE CommEvent;				// Handle to operation complete event

  FIFOItem() {
    Type = 0;
    TVal = 0;
    ConsistNo = 1;
    TIUNo = 1;
    Command[0] = '\0';
    ExpectedCount = 11;
    WaitTime = 200;
    ptrRespCode = (int *) NULL;
    ResponseCount = (int *) NULL;
    ResponseBuffer = (byte *) NULL;
    Record_Flag = RECORD_OK;
    cLashUpEngineList[0] = '\0';
    CommEvent = (HANDLE) NULL;
    }
  ~FIFOItem() {
  	}
  };
//---------------------------------------------------------------------------
#define BELL_ON "w4"
#define BELL_OFF "bFFFB"
#define HDLT_ON "ab1"
#define HDLT_OFF "ab0"
#define WHISTLE_ON "w2"
#define WHISTLE_OFF "bFFFD"
#define DIRECTION_FORWARD "d0"
#define DIRECTION_REVERSE "d1"
#define DIRECTION_CHANGE "d%d"
#define CONVENTIONAL_MODE "m2"
#define COMMAND_MODE "m4"
#define COMMAND_STARTUP "u4"
#define COMMAND_SHUTDOWN "u5"
#define COMMAND_STARTUP_EXTENDED "u6"
#define COMMAND_SHUTDOWN_EXTENDED "u7"
#define COMMAND_CREATE_LASHUP "U"
#define COMMAND_STOP "s0"
#define COUPLER_FRONT "c0"
#define COUPLER_REAR "c1"
#define SMOKE_EXHAUST_MIN "ab12"
#define SMOKE_EXHAUST_MED "ab11"
#define SMOKE_EXHAUST_MAX "ab10"
#define SMOKE_EXHAUST_ON "abF"
#define SMOKE_EXHAUST_OFF "abE"
#define MARKERS_ON "ab1C"
#define MARKERS_OFF "ab1D"
#define BEACON_ON "abD"
#define BEACON_OFF "abC"
#define CAB_CHAT_ON "ab13"
#define CAB_CHAT_OFF "ab14"
#define CHUFF_RATE_2 "g2"
#define CHUFF_RATE_4 "g4"
#define COUPLER_CLASH "h1"

#define AUX1_ON "ab3"
#define AUX1_OFF "ab2"
#define AUX2_ON "ab4"
#define AUX2_OFF "ab5"
#define AUX3_ON "ab6"
#define AUX3_OFF "ab7"
//
#define CMD_PROTOWHISTLE_ON "ab20"
#define CMD_PROTOWHISTLE_OFF "ab21"
#define CMD_SMOKEWHISTLE_ON "ab22"
#define CMD_SMOKEWHISTLE_OFF "ab23"
#define CMD_SWINGINGBELL_ON "ab24"
#define CMD_SWINGINGBELL_OFF "ab25"
//
#define ACC_ON  "Ae%02d"
#define ACC_OFF "Af%02d"
#define ACC_ALL_ON  "AaFFFFFFFFFFFFFF"
#define ACC_ALL_OFF "Aa00000000000000"
#define SWITCH_NORMAL  "Ac%02d"
#define SWITCH_REVERSE "Ad%02d"
#define SWITCH_ALL_NORMAL  "Ab05555555555555555555555555"
#define SWITCH_ALL_REVERSE "Ab0AAAAAAAAAAAAAAAAAAAAAAAAA"
#define SPEED_SET "s%d"
#define PLAY_SOUND "n%d"
#define SINGLE_TOOT "n41"
#define CROSSING "n42"
#define DOUBLE_TOOT "n43"
#define TRIPLE_TOOT "n44"
#define IDLE_SOUND "i%d"
#define VOLUME_CHANGE "v%1d%03d"
  #define MASTER_VOLUME 0
  #define ENGINE_VOLUME 1
  #define ACCENT_VOLUME 2
  #define HORN_VOLUME 3
  #define BELL_VOLUME 4
#define COUPLER_CMD "c%d"
  #define FRONT 0
  #define REAR 1
#define SETCMD "ab%X"
  #define CMD_HDLT_OFF 0x00
  #define CMD_HDLT_ON 0x01
  #define CMD_INT_OFF 0x02
  #define CMD_INT_ON 0x03
  #define CMD_MARS_OFF 0x04
  #define CMD_NUMBERBOARDS_OFF 0x04
  #define CMD_MARS_ON 0x05
  #define CMD_NUMBERBOARDS_ON 0x05
  #define CMD_DITCH_OFF 0x06
  #define CMD_DITCH_ON 0x07
  #define CMD_BEACON_ON 0x0D
  #define CMD_BEACON_OFF 0x0C
  #define CMD_SMOKE_OFF 0x0E
  #define CMD_SMOKE_ON 0x0F
  #define CMD_SMOKE_MAX 0x10
  #define CMD_SMOKE_MED 0x11
  #define CMD_SMOKE_MIN 0x12
  #define CMD_MARKERS_ON 0x1C
  #define CMD_MARKERS_OFF 0x1D

#define ACC_RATE "Da%d"
#define DEC_RATE "Dd%d"
#define EMERGENCY_STOP "o0"
#define LABOR_REV_UP "r16"
#define LABOR_REV_DOWN "r17"
#define LABOR_REV_NORMAL "r15"

#define QUERY "q%04X"
#define QUERYATOM "V%1d%X"
    
//---------------------------------------------------------------------------

#define STARTED true    // Engine state
#define SHUTDOWN false
#define ON true         // AIU Accessory State
#define OFF false
#define ENG_FORWARD true    // Engine direction
#define ENG_REVERSE false
#define STRAIGHT true   // AIU Switch State
#define DIVERGE false
#define CLOSED true   	// AIU Switch State
#define THROWN false
#define NORMAL true		// AIU Switch State
#define REVERSE false   // AIU Switch State


#define isDetector(x) (Packet.Data_Packet.Header.Board == x)
#define isReader(x) (Packet.Data_Packet.Header.Reader == x)
#define isTagFront (Packet.Data_Packet.EngineData.TagLocation == TAG_ON_FRONT_TRUCK)
#define isTagRear (Packet.Data_Packet.EngineData.TagLocation == TAG_ON_REAR_TRUCK)
#define isEngine (Packet.Data_Packet.EngineData.EngineNo > 0)
#define notEngine (Packet.Data_Packet.EngineData.EngineNo == 0)
#define isCarModel(x) (Packet.Data_Packet.EngineData.CarModel == x)

#define RAMMING_SPEED 15	// speed in Smph the helps assure successful coupling

#endif    // _RTCMEGAMASTER_H

//---------------------------------------------------------------------------


