SafeDispatch/CPlus_GW/definitions.cs

258 lines
7.1 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Threading;
namespace CPlus_GW
{
// -------------------------------------------------------------------
// General
// -------------------------------------------------------------------
public class htCell_t
{
public string lat, lng, spd, spd_v; // GPS data
public DateTime location_time;
public double radius;
public string di;
public DateTime activity_time; // = min(gpstime, arstime)
public string suid;
public byte requestID;
public bool triggered;
public double d_lat, d_lng;
public int altitude;
public int altitude_accuracy;
public int level_confidence;
public string seq_ID;
public Int64 seqID;
public bool isCSBK;
}
enum Result_Codes_ENUM
{
SUCCESS = 0x0,
UNSUPPORTED_VERSION = 0x8,
SYNTAX_ERROR = 0xA,
PROTOCOL_ELEMENT_NOT_SUPPORTED = 0xB,
PROTOCOL_ELEMENT_VALUE_OUT_OF_RANGE = 0xD,
QUERY_INFO_NOT_ATTAINABLE = 0xF,
QUERY_INFO_NOT_CURRENTLY_ATTAINABLE = 0x10,
NO_SUCH_REQUEST = 0x15,
DUPLICATE_REQUEST_ID = 0x16,
/*
BAD_GPS_GEOMETRY = 0x201,
IRRS_RES_INSUFF_DATA = 0x1005,
IRRS_RES_NO_PROVIDERS = 0x1006
* */
};
enum Document_Identifiers_ENUM
{
Immediate_Location_Request = 0x04,
Immediate_Location_Request_NoCDT = 0x05,
Immediate_Location_Report = 0x06,
Immediate_Location_Report_NoCDT = 0x07,
Triggered_Location_Request = 0x08,
Triggered_Location_Request_NoCDT = 0x09,
Triggered_Location_Answer = 0x0A,
Triggered_Location_Answer_NoCDT = 0x0B,
Triggered_Location_Report = 0x0C,
Triggered_Location_Report_NoCDT = 0x0D,
Triggered_Location_Stop_Request = 0x0E,
Triggered_Location_Stop_Request_NoCDT = 0x0F,
Triggered_Location_Stop_Answer = 0x10,
Triggered_Location_Stop_Answer_NoCDT = 0x11,
Unsolicited_Location_Report = 0x12,
Unsolicited_Location_Report_NoCDT = 0x13,
Location_Protocol_Request_NoCDT = 0x14,
Location_Protocol_Report_NoCDT = 0x15
};
// -------------------------------------------------------------------
// ARS Service
// -------------------------------------------------------------------
enum header_event
{
Unqualified_Event = 0x00,
Initial_Event = 0x01,
Refresh_Event = 0x02,
UNKNOWN = 0x03
}
// -------------------------------------------------------------------
// Location Service
// -------------------------------------------------------------------
enum Common_Element_Tokens_ENUM
{
request_id = 0x22,
request_id1 = 0x23,
request_id2 = 0x24
};
enum Query_Request_Messages_Tokens_ENUM
{
interval = 0x31,
oneshot_trigger = 0x33,
periodic_trigger = 0x34,
request_altitude = 0x54,
request_altitude_acc = 0x55,
request_altitude_acc1 = 0x56,
request_direction_hor = 0x57,
request_hor_acc = 0x5F,
request_hor_acc1 = 0x60,
request_lev_conf = 0x61,
request_protocol_version = 0x3F,
request_speed_hor = 0x62,
request_speed_vrt = 0x64,
require_max_info_age = 0x42,
require_altitude = 0x66,
require_altitude_acc = 0x67,
require_altitude_acc1 = 0x68,
require_direction_hor = 0x69,
require_hor_acc = 0x71,
require_hor_acc1 = 0x72,
require_lev_conf = 0x73,
require_speed_hor = 0x74,
require_speed_vrt = 0x76,
ret_info = 0x50,
ret_info1 = 0x51,
ret_info2 = 0x52,
ret_info3 = 0x53,
trg_condition = 0x4A,
SU_IPv4 = 0x26
};
enum Report_Messages_Tokens_ENUM
{
circle_2d = 0x51,
circle_3d = 0x54,
circle_3d1 = 0x55,
direction_hor = 0x56,
info_time = 0x34,
info_time1 = 0x35,
lev_conf = 0x65,
point_2d = 0x66,
point_3d = 0x69,
point_3d1 = 0x6A,
protocol_version = 0x36,
result = 0x37,
result1 = 0x38,
result2 = 0x39,
speed_hor = 0x6C,
speed_vrt = 0x70,
SU_IPv4 = 0x26
};
enum Attribute_Tokens_ENUM
{
result_code = 0x22,
result_code1 = 0x23,
ret_info_accuracy = 0x50,
ret_info_accuracy1 = 0x51,
ret_info_no_req_id = 0x52,
ret_info_no_req_id1 = 0x53,
ret_info_time = 0x54,
ret_info_time1 = 0x55
};
// -------------------------------------------------------------------
// Voip Service
// -------------------------------------------------------------------
enum OPCODE_ENUM
{
XNL_MASTER_STATUS_BRDCST = 0x0002,
DEVICE_AUTH_KEY_REQUEST = 0x0004,
DEVICE_AUTH_KEY_REPLY = 0x0005,
DEVICE_CONN_REQUEST = 0x0006,
DEVICE_CONN_REPLY = 0x0007,
DATA_MSG = 0x000b,
DATA_MSG_ACK = 0x000c,
SPKRSTAT = 0xb407 // Speaker State broadcast message
};
enum MotoTRBOcmd
{
SET_REPORT_INTERVAL = 0x01,
SEND_SMS = 0x02
};
public class MotoTRBOcmdMsg
{
public string m_suid;
public byte m_cmd;
public string m_payload;
}
public class OC4Jrfid
{
public string suid;
public string rfid;
}
public class SMSmsg
{
public string suid;
public string msg;
public bool conf; //sent confirmation
public string DBmsg_id;//message ID from database (for message confirmation)
public int seq_no;
public bool req_conf;
DateTime added;
public SMSmsg()
{
req_conf = true;
conf = false;
added = DateTime.Now;
}
}
public class InterthreadMessageQueue<T>
{
System.Collections.Generic.Queue<T> _queue = new
System.Collections.Generic.Queue<T>();
/// <summary>
/// Post a message to the queue.
/// </summary>
public void PostItem(T item)
{
lock (_queue)
{
_queue.Enqueue(item);
if (_queue.Count == 1)
Monitor.Pulse(_queue);
}
}
/// <summary>
/// Retrieve a message from the queue.
/// </summary>
/// <param name="maxWait">Number of milliseconds to block ifnothing is available. -1 means "block indefinitely"</param>
/// <returns>The next item in the queue, or default(T) if queue is empty</returns>
public T GetItem(int maxWait)
{
lock (_queue)
{
if (_queue.Count == 0)
{
if (maxWait == 0)
return default(T);
Monitor.Wait(_queue, maxWait);
if (_queue.Count == 0)
return default(T);
}
return _queue.Dequeue();
}
}
}
}