SafeNet/SafeNetLib/Definitions.cs
2021-02-24 13:50:23 +02:00

410 lines
11 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace SafeNetLib
{
public enum CallType { ALLCALL = 101, PRIVATECALL = 102, GROUPCALL = 103, EMERGENCYCALL = 104 };
public enum CallStatus { INPROGRESS = 1, HANGTIME = 2, ENDED = 3 };
public class Definitions
{
public static string GetCallStatus4UI(int callStatus)
{
switch (callStatus)
{
case (int)CallStatus.INPROGRESS: return "In Progress";
case (int)CallStatus.HANGTIME: return "Hang Time";
case (int)CallStatus.ENDED: return "Ended";
default: return "Unknown";
}
}
public static string GetCallType4UI(int callType)
{
switch (callType)
{
case (int)CallType.ALLCALL: return "All Call";
case (int)CallType.PRIVATECALL: return "Private Call";
case (int)CallType.GROUPCALL: return "Group Call";
case (int)CallType.EMERGENCYCALL: return "Emergency Call";
default: return "Unknown";
}
}
}
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;
public List<Telemetry> telemetryList;
}
public class Telemetry
{
private int id;
public int ID
{
get { return id; }
set { id = value; }
}
private int telemetryValue;
public int TelemetryValue
{
get { return telemetryValue; }
set { telemetryValue = value; }
}
}
public class landmark
{
public string name;
public string address;
public decimal lng;
public decimal lat;
public string icon;
public int userID;
public int radius;
public string innerException;
}
public 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,
/*
INSUFFICIENT_GPS_SATELLITES = 0x200,
BAD_GPS_GEOMETRY = 0x201,
IRRS_RES_INSUFF_DATA = 0x1005,
IRRS_RES_NO_PROVIDERS = 0x1006
* */
};
public 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
// -------------------------------------------------------------------
public enum header_event
{
Unqualified_Event = 0x00,
Initial_Event = 0x01,
Refresh_Event = 0x02,
UNKNOWN = 0x03
}
// -------------------------------------------------------------------
// Location Service
// -------------------------------------------------------------------
public enum Common_Element_Tokens_ENUM
{
request_id = 0x22,
request_id1 = 0x23,
request_id2 = 0x24
};
public 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
};
public 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
};
public 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
// -------------------------------------------------------------------
public 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
};
public enum MotoTRBOcmd
{
SET_REPORT_INTERVAL = 0x01,
SEND_SMS = 0x02,
SEND_POLL = 0x03
};
public enum Alert_TYPE
{
SPEED = 0x01,
LANDMARK = 0x02,
GEOFENCE = 0x03,
DI = 0x04
};
public enum Connection_TYPE
{
TCP,
UDP
}
public class GeoPoint
{
public double lat;
public double lng;
public int speed;
}
public class MotoTRBOcmdMsg
{
public string m_suid;
public int m_cmd;
public string m_payload;
public Int32 m_seqID; //seqID when it was last sent
public DateTime m_time; //time when it was last sent
}
public class GWstatus
{
public string gw_id;
public int status;
public string message;
}
public class OC4Jrfid
{
public string suid;
public string rfid;
}
public class SMSmsg
{
public string suid;
public string msg;
public bool conf; //sent confirmation
public uint DBmsg_id;//message ID from database (for message confirmation)
public int seq_no;
public bool req_conf;
DateTime added;
public DateTime waitConfSMSList_time;
public SMSmsg()
{
req_conf = true;
conf = false;
added = DateTime.Now;
}
}
public class POLLmsg
{
public int DBid;
public string suid;
public DateTime created;
public DateTime read;
public DateTime sent;
public DateTime response;
public string lat;
public string lng;
public string speed;
public Int32 requestID;
}
public struct header_T
{
public bool ext, ext2, ack, cntl;
public byte pdu_type;
public byte seq_no;
public byte encoding;
public byte header;
public string message;
}
public class ArsMSG
{
public string suid;
public string msg;
public string imei;
public string gatewayID;
}
public class gpsMSG
{
public byte[] data = null;
}
public class SUinfo
{
public int DBid;
public string suid;
public bool ARSon;
public int repInterval;
public DateTime arsCheckTime;
public DateTime GPSlasttime = DateTime.UtcNow;
public List<Alert> alertList;
}
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();
}
}
public int Count
{
get
{
lock (_queue)
{
return _queue.Count;
}
}
}
public void Clear()
{
lock (_queue)
{
_queue.Clear();
}
}
}
}