// icsSpyData.h - Vehicle Spy Data Structures
// Created 9/25/99
// Copyright 1999 Intrepid Control Systems, Inc.
// Converted to Delphi by Robert Marquardt (rom)  2 Jan 2004

unit icsSpyData;

interface

(*
Public Enum icsspyHardwareTimeStampID
    icsspyTimeStampNone
    icsspyTimeStampVSI
    icsspyTimeStampAVT_716
    icsspyTimeStampNICAN
End Enum *)

// timestamp id fields
const
  HARDWARE_TIMESTAMP_ID_NONE       = 0;
  HARDWARE_TIMESTAMP_ID_VSI        = 1;
  HARDWARE_TIMESTAMP_ID_AVT_716    = 2;
  HARDWARE_TIMESTAMP_ID_NI_CAN     = 3;
  HARDWARE_TIMESTAMP_ID_NEOVI      = 4;
  HARDWARE_TIMESTAMP_ID_AVT_717    = 5;
  HARDWARE_TIMESTAMP_ID_NEOv6_VCAN = 6;
(*
'// protocols
Public Enum icsspyHardwareProtocol
    icsspyProtocolCustom
    icsspyProtocolCAN
    icsspyProtocolGMLAN
    icsspyProtocolJ1850VPW
    icsspyProtocolJ1850PWM
    icsspyProtocolISO9141
    icsspyProtocolKeyword2000
    icsspyProtocolGM_ALDL_UART
    icsspyProtocolChryslerCCD
    icsspyProtocolChryslerSCI
    icsspyProtocolFordUBP
    icsspyProtocolBean
End Enum *)

  SPY_PROTOCOL_CUSTOM        = 0;
  SPY_PROTOCOL_CAN           = 1;
  SPY_PROTOCOL_GMLAN         = 2;
  SPY_PROTOCOL_J1850VPW      = 3;
  SPY_PROTOCOL_J1850PWM      = 4;
  SPY_PROTOCOL_ISO9141       = 5;
  SPY_PROTOCOL_Keyword2000   = 6;
  SPY_PROTOCOL_GM_ALDL_UART  = 7;
  SPY_PROTOCOL_CHRYSLER_CCD  = 8;
  SPY_PROTOCOL_CHRYSLER_SCI  = 9;
  SPY_PROTOCOL_FORD_UBP      = 10;
  SPY_PROTOCOL_BEAN          = 11;
  SPY_PROTOCOL_LIN           = 12;
  SPY_PROTOCOL_J1708         = 13;
  SPY_PROTOCOL_CHRYSLER_JVPW = 14;
  SPY_PROTOCOL_J1939         = 15;

(*
'// these are bitmasks for the status bitfield
Public Enum icsSpyDataStatusBitfield
    icsSpyStatusGlobalError = 2 ^ 0
    icsSpyStatusTx = 2 ^ 1
    icsSpyStatusXtdFrame = 2 ^ 2
    icsSpyStatusRemoteFrame = 2 ^ 3
    icsSpyStatusErrCRCError = 2 ^ 4
    icsSpyStatusCANErrorPassive = 2 ^ 5
    icsSpyStatusErrIncompleteFrame = 2 ^ 6
    icsSpyStatusErrLostArbitration = 2 ^ 7
    icsSpyStatusErrUndefined = 2 ^ 8
    icsSpyStatusErrCANBusOff = 2 ^ 9
    icsSpyStatusErrCANErrorWarning = 2 ^ 10
    icsSpyStatusBusShortedPlus = 2 ^ 11
    icsSpyStatusBusShortedGnd = 2 ^ 12
    icsSpyStatusCheckSumError = 2 ^ 13
    icsSpyStatusErrBadMessageBitTimeError = 2 ^ 14
    icsSpyStatusIFRData = 2 ^ 15
    icsSpyStatusHardwareCommError = 2 ^ 16
    icsSpyStatusExpectedLengthError = 2 ^ 17
    icsSpyStatusIncomingNoMatch = 2 ^ 18
    icsSpyStatusBreak = 2 ^ 19
    icsSpyStatusAVT_VSIRecOverflow = 2 ^ 20
    icsSpyStatusTestTrigger = 2 ^ 21
    icsSpyStatusAudioCommentType = 2 ^ 22
    icsSpyStatusGPSDataValue = 2 ^ 23
    icsSpyStatusAnalogDigitalInputValue = 2 ^ 24
    icsSpyStatusTextCommentType = 2 ^ 25
    icsSpyStatusNetworkMessageType = 2 ^ 26
    icsSpyStatusVSI_TxUnderRun = 2 ^ 27
    icsSpyStatusVSI_IFR_CRCBit = 2 ^ 28
    icsSpyStatusInitMessage = 2 ^ 29
    icsSpyStatusHighSpeed = 2 ^ 30
End Enum
*)

// constants for the status bitfield
const 
  SPY_STATUS_GLOBAL_ERR                 = $01;
  SPY_STATUS_TX_MSG                     = $02;
  SPY_STATUS_XTD_FRAME                  = $04;
  SPY_STATUS_REMOTE_FRAME               = $08;

  SPY_STATUS_CRC_ERROR                  = $10;
  SPY_STATUS_CAN_ERROR_PASSIVE          = $20;
  SPY_STATUS_INCOMPLETE_FRAME           = $40;
  SPY_STATUS_LOST_ARBITRATION           = $80;

  SPY_STATUS_UNDEFINED_ERROR            = $100;
  SPY_STATUS_CAN_BUS_OFF                = $200;
  SPY_STATUS_CAN_ERROR_WARNING          = $400;
  SPY_STATUS_BUS_SHORTED_PLUS           = $800;

  SPY_STATUS_BUS_SHORTED_GND            = $1000;
  SPY_STATUS_CHECKSUM_ERROR             = $2000;
  SPY_STATUS_BAD_MESSAGE_BIT_TIME_ERROR = $4000;
  SPY_STATUS_IFR_DATA                   = $8000;

  SPY_STATUS_HARDWARE_COMM_ERROR        = $10000;
  SPY_STATUS_EXPECTED_LEN_ERROR         = $20000;
  SPY_STATUS_INCOMING_NO_MATCH          = $40000;
  SPY_STATUS_BREAK                      = $80000;

  SPY_STATUS_AVSI_REC_OVERFLOW          = $100000;
  SPY_STATUS_TEST_TRIGGER               = $200000;
  SPY_STATUS_AUDIO_COMMENT              = $400000;
  SPY_STATUS_GPS_DATA                   = $800000;

  SPY_STATUS_ANALOG_DIGITAL_INPUT       = $1000000;
  SPY_STATUS_TEXT_COMMENT               = $2000000;
  SPY_STATUS_NETWORK_MESSAGE_TYPE       = $4000000;
  SPY_STATUS_VSI_TX_UNDERRUN            = $8000000;

  SPY_STATUS_VSI_IFR_CRC_Bit            = $10000000;
  SPY_STATUS_INIT_MESSAGE               = $20000000;
  SPY_STATUS_HIGH_SPEED_MESSAGE         = $40000000;

// The second status bitfield
(*
Public Enum icsSpyDataStatusBitfield2
    icsSpyStatusHasValue = 2 ^ 0
    icsSpyStatusValueIsBoolean = 2 ^ 1
End Enum
*)

  SPY_STATUS2_HAS_VALUE        = 1;
  SPY_STATUS2_VALUE_IS_BOOLEAN = 2;
  SPY_STATUS2_HIGH_VOLTAGE     = 4;
  SPY_STATUS2_LONG_MESSAGE     = 8;

  // these are used in status2 for Vehicle Spy 3
  icsspystatusChangeLength  = $10;
  icsspystatusChangeBitH1   = $20;
  icsspystatusChangeBitH2   = $40;
  icsspystatusChangeBitH3   = $80;
  icsspystatusChangeBitB1   = $100;
  icsspystatusChangeBitB2   = $200;
  icsspystatusChangeBitB3   = $400;
  icsspystatusChangeBitB4   = $800;
  icsspystatusChangeBitB5   = $1000;
  icsspystatusChangeBitB6   = $2000;
  icsspystatusChangeBitB7   = $4000;
  icsspystatusChangeBitB8   = $8000;
  icsspystatusChangedGlobal = $10000;

(*
Public Type icsSpyMessage
    StatusBitField As Long '4
    StatusBitField2 As Long 'new '4
    TimeHardware As Long ' 4
    TimeHardware2 As Long 'new ' 4
    TimeSystem As Long ' 4
    TimeSystem2 As Long
    TimeStampID As Byte 'new ' 1
    TimeStampSystemID As Byte
    NetworkID As Byte 'new ' 1
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte ' 1
    ColorID As Byte '1
    NumberBytesHeader As Byte ' 1
    NumberBytesData As Byte ' 1
    DescriptionID As Integer ' 2
    ArbIDOrHeader As Long    '// Holds (up to 3 byte 1850 header or 29 bit CAN header) '4
    Data(1 To 8) As Byte '8
    AckBytes(1 To 8) As Byte 'new '8
    Value As Single ' 4
    MiscData As Byte
End Type *)

type
  PicsSpyMessage = ^icsSpyMessage;
  icsSpyMessage = packed record // matching Delphi structure
    StatusBitField: Cardinal;   // 4
    StatusBitField2: Cardinal;  // 4
    TimeHardware: Cardinal;     // 4
    TimeHardware2: Cardinal;    // 4
    TimeSystem: Cardinal;       // 4
    TimeSystem2: Cardinal;      // 4
    TimeStampHardwareID: Byte;  // 1
    TimeStampSystemID: Byte;
    NetworkID: Byte;            // 1
    NodeID: Byte;
    Protocol: Byte;
    MessagePieceID: Byte;       // 1
    ColorID: Byte;              // 1
    NumberBytesHeader: Byte;    // 1
    NumberBytesData: Byte;      // 1
    DescriptionID: Smallint;    // 2
    ArbIDOrHeader: Integer;     // 4
    Data: array [0..7] of Byte;
    AckBytes: array [0..7] of Byte;
    Value: Single;
    MiscData: Byte;
  end;

(*
Public Type icsSpyMessageLong
    StatusBitField As Long ' 4
    StatusBitField2 As Long 'new '4
    TimeHardware As Long
    TimeHardware2 As Long 'new ' 4
    TimeSystem As Long '4
    TimeSystem2 As Long
    TimeStampID As Byte 'new ' 1
    TimeStampSystemID As Byte
    NetworkID As Byte 'new ' 1
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte ' 1
    ColorID As Byte ' 1
    NumberBytesHeader As Byte '
    NumberBytesData As Byte '2
    DescriptionID As Integer '2
    ArbIDOrHeader As Long    '// Holds (up to 3 byte 1850 header or 29 bit CAN header)
    DataMsb As Long
    DataLsb As Long
    AckBytes(1 To 8) As Byte 'new '8
    Value As Single
    MiscData As Byte

End Type*)

  PicsSpyMessageLong = ^icsSpyMessageLong;
  icsSpyMessageLong = packed record // matching Delphi structure
    StatusBitField: Cardinal;   // 4
    StatusBitField2: Cardinal;  // 4
    TimeHardware: Cardinal;     // 4
    TimeHardware2: Cardinal;    // 4
    TimeSystem: Cardinal;       // 4
    TimeSystem2: Cardinal;      // 4
    TimeStampHardwareID: Byte;  // 1
    TimeStampSystemID: Byte;    // 1
    NetworkID: Byte;            // 1
    NodeID: Byte;               // 1
    Protocol: Byte;             // 1
    MessagePieceID: Byte;       // 1
    ColorID: Byte;              // 1
    NumberBytesHeader: Byte;    // 1
    NumberBytesData: Byte;      // 1
    DescriptionID: Smallint;    // 2
    ArbIDOrHeader: Integer;     // 4
    DataMsb: Cardinal;
    DataLsb: Cardinal;
    AckBytes: array [0..7] of Byte;
    Value: Single;
    MiscData: Byte;
  end;

(*
Public Type icsSpyMessageJ1850
    StatusBitField As Long '4
    StatusBitField2 As Long 'new '4
    TimeHardware As Long '4
    TimeHardware2 As Long 'new ' 4
    TimeSystem As Long '4
    TimeSystem2 As Long
    TimeStampID As Byte 'new ' 1
    TimeStampSystemID As Byte
    NetworkID As Byte 'new ' 1
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte ' 1 new
    ColorID As Byte ' 1
    NumberBytesHeader As Byte '1
    NumberBytesData As Byte '1
    DescriptionID As Integer '2
    Header(1 To 4) As Byte  '4  '// Holds (up to 3 byte 1850 header or 29 bit CAN header)
    Data(1 To 8) As Byte '8
    AckBytes(1 To 8) As Byte 'new '8
    Value As Single '4
    MiscData As Byte
End Type *)

  PicsSpyMessageJ1850 = ^icsSpyMessageJ1850;
  icsSpyMessageJ1850 = packed record // matching Delphi structure
    StatusBitField: Cardinal;      // 4
    StatusBitField2: Cardinal;     // 4
    TimeHardware: Cardinal;        // 4
    TimeHardware2: Cardinal;       // 4
    TimeSystem: Cardinal;          // 4
    TimeSystem2: Cardinal;         // 4
    TimeStampHardwareID: Byte;     // 1
    TimeStampSystemID: Byte;       // 1
    NetworkID: Byte;               // 1
    NodeID: Byte;                  // 1
    Protocol: Byte;                // 1
    MessagePieceID: Byte;          // 1
    ColorID: Byte;                 // 1
    NumberBytesHeader: Byte;       // 1
    NumberBytesData: Byte;         // 1
    DescriptionID: Smallint;       // 2
    Header: array [0..3] of Byte;  // 4
    Data: array [0..7] of Byte;
    AckBytes: array [0..7] of Byte;
    Value: Single;
    MiscData: Byte;
  end;

(*
Public Type icsSpyMessageGPS
    StatusBitField As Long  '4
    StatusBitField2 As Long 'new '4
    TimeHardware As Long    '4
    TimeHardware2 As Long 'new ' 4
    TimeSystem As Long '4
    TimeSystem2 As Long
    TimeStampID As Byte 'new ' 1
    TimeStampSystemID As Byte
    NetworkID As Byte 'new ' 1
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte ' 1
    ColorID As Byte ' 1
    GPSDataID As Integer    '2
    DescriptionID As Integer '2
    AckBytes(1 To 8) As Byte 'new '8
    Value1 As Double '8
    Value2 As Double '8
    MiscData As Byte
End Type *)

  PicsSpyMessageGPS = ^icsSpyMessageGPS;
  icsSpyMessageGPS = packed record // matching Delphi structure
    StatusBitField: Cardinal;   // 4
    StatusBitField2: Cardinal;  // 4
    TimeHardware: Cardinal;     // 4
    TimeHardware2: Cardinal;    // 4
    TimeSystem: Cardinal;       // 4
    TimeSystem2: Cardinal;      // 4
    TimeStampHardwareID: Byte;  // 1
    TimeStampSystemID: Byte;
    NetworkID: Byte;            // 1
    NodeID: Byte;               // 1
    Protocol: Byte;             // 1
    MessagePieceID: Byte;       // 1
    ColorID: Byte;              // 1
    GPSDataID: Smallint;
    DescriptionID: Smallint;    // 2
    AckBytes: array [0..7] of Byte;
    Value1: Double;             // 8
    Value2: Double;             // 8
    MiscData: Byte;
  end;

(*
Public Type icsSpyMessageAnalog
    StatusBitField As Long  '4
    StatusBitField2 As Long 'new '4
    TimeHardware As Long    '4
    TimeHardware2 As Long 'new ' 4
    TimeSystem As Long '4
    TimeSystem2 As Long
    TimeStampID As Byte 'new ' 1
    TimeStampSystemID As Byte
    NetworkID As Byte 'new ' 1
    NodeID As Byte
    Protocol As Byte
    MessagePieceID As Byte ' 1
    ColorID As Byte ' 1
    AIDataID As Integer    '2
    DescriptionID As Integer '2
    Value As Double '8
    HardwareIndex As Integer '2
    AckBytes(1 To 8) As Byte 'new '8
    iDummy As Integer '2
    lDummy As Long '4
    MiscData As Byte
End Type
 *)

  PicsSpyMessageAnalog = ^icsSpyMessageAnalog;
  icsSpyMessageAnalog = packed record // matching Delphi structure
    StatusBitField: Cardinal;   // 4
    StatusBitField2: Cardinal;  // 4
    TimeHardware: Cardinal;     // 4
    TimeHardware2: Cardinal;    // 4
    TimeSystem: Cardinal;       // 4
    TimeSystem2: Cardinal;      // 4
    TimeStampHardwareID: Byte;  // 1
    TimeStampSystemID: Byte;    // 1
    NetworkID: Byte;            // 1
    NodeID: Byte;               // 1
    Protocol: Byte;
    MessagePieceID: Byte;       // 1
    ColorID: Byte;              // 1
    AIDataID: Smallint;
    DescriptionID: Smallint;    // 2
    Value: Double;
    HardwareIndex: Smallint;
    AckBytes: array [0..7] of Byte;
    iDummy: Smallint;
    lDummy: Integer;
    MiscData: Byte;
  end;

(*
Public Enum icsspySystemTimeStampID
    icsspyTimeStampNone
    icsspyTimeStampTimeGetTimeAPI
End Enum*)

const
  SYSTEM_TIMESTAMP_ID_NONE = Byte(0);
  SYSTEM_TIMESTAMP_ID_TIMEGETTIME_API = Byte(1);

(*
Public Type icsspyMsgTime
    SystemTimeStampID As Long
    SystemTime1 As Long
    SystemTime2 As Long
    HardwareTimeStampID As Long
    HardwareTime1 As Long
    HardwareTime2 As Long
End Enum *)

type
  PicsSpyMsgTime = ^icsSpyMsgTime;
  icsSpyMsgTime = packed record // matching Delphi structure
    SystemTimeStampID: Cardinal;    // 4
    SystemTime1: Cardinal;          // 4
    SystemTime2: Cardinal;          // 4
    HardwareTimeStampID: Cardinal;  // 4
    HardwareTime1: Cardinal;        // 4
    HardwareTime2: Cardinal;        // 4
  end;

(* Public Type spyFilterBytes
    StatusValue As Long
    StatusMask As Long
    Status2Value As Long
    Status2Mask As Long
    Header(1 To 4) As Byte
    HeaderMask(1 To 4) As Byte
    MiscData As Long
    MiscDataMask As Long
    ByteData(1 To 8) As Byte
    ByteDataMask(1 To 8) As Byte
    HeaderLength As Long
    ByteDataLength As Long
    NetworkID As Long
    FrameMaster As Boolean
    bStuff1 As Byte
    bStuff2 As Byte
    ExpectedLength As Long
    NodeID As Long
End Type *)


  PspyFilterBytes = ^spyFilterBytes;
  spyFilterBytes = packed record // matching Delphi structure
    StatusValue: Cardinal;               // 4
    StatusMask: Cardinal;                // 4
    Status2Value: Cardinal;              // 4
    Status2Mask: Cardinal;               // 4
    Header: array [0..3] of Byte;        // 4
    HeaderMask: array [0..3] of Byte;    // 4
    MiscData: Cardinal;                  // 4
    MiscDataMask: Cardinal;              // 4
    ByteData: array [0..7] of Byte;      // 4
    ByteDataMask: array [0..7] of Byte;  // 4
    HeaderLength: Cardinal;              // 4
    ByteDataLength: Cardinal;            // 4
    NetworkID: Cardinal;                 // 4
    FrameMaster: Word;                   // 2
    bUseArbIdRangeFilter: Byte;
    bStuff2: Byte;
    ExpectedLength: Cardinal;
    NodeID: Cardinal;
  end;

(*Public Type spyFilterLong
    StatusValue As Long
    StatusMask As Long
    Status2Value As Long
    Status2Mask As Long
    Header As Long
    HeaderMask As Long
    MiscData As Long
    MiscDataMask As Long
    ByteDataMsb As Long
    ByteDataLsb As Long
    ByteDataMaskMsb As Long
    ByteDataMaskLsb As Long
    HeaderLength As Long
    ByteDataLength As Long
    NetworkID As Long
    FrameMaster As Boolean
    bStuff1 As Byte
    bStuff2 As Byte
    ExpectedLength As Long
    NodeID As Long
End Type *)

  PspyFilterLong = ^spyFilterLong;
  spyFilterLong = packed record // matching Delphi structure
    StatusValue: Cardinal;      // 4
    StatusMask: Cardinal;       // 4
    Status2Value: Cardinal;     // 4
    Status2Mask: Cardinal;      // 4
    Header: Cardinal;           // 4
    HeaderMask: Cardinal;       // 4
    MiscData: Cardinal;         // 4
    MiscDataMask: Cardinal;     // 4
    ByteDataMSB: Cardinal;      // 4
    ByteDataLSB: Cardinal;      // 4
    ByteDataMaskMSB: Cardinal;  // 4
    ByteDataMaskLSB: Cardinal;  // 4
    HeaderLength: Cardinal;     // 4
    ByteDataLength: Cardinal;   // 4
    NetworkID: Cardinal;        // 4
    FrameMaster: Word;          // 2
    bUseArbIdRangeFilter: Byte;
    bStuff2: Byte;
    ExpectedLength: Cardinal;
    NodeID: Cardinal;
  end;

implementation

end.

