SafeDispatch/AndroidLIB/Definitions.cs

156 lines
4.0 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System.Threading;
namespace AndroidLIB
{
public enum Android_MSG_type
{
RecordPlay_req = 18,
RecordPlay_rpl = 38,
Init_req =19,
Init_rpl =39,
Login_List_req = 20,
Login_List_rpl = 40,
Veh_req = 21,
Veh_rpl = 41,
SMS_req = 22,
SMS_rpl = 42,
SMS_last_req = 23,
SMS_last_rpl = 43,
SMS_send = 24,
SMS_ack = 44,
LastPos_req = 25,
LastPos_rpl = 45,
GPShistory_req = 26,
GPShistory_countrpl = 86,
GPShistory_rpl = 46,
Alarmhistory_req = 27,
Alarmhistory_rpl = 47,
AlarmAck_req = 28,
AlarmAck_rpl = 48,
Recording_req = 29,
Recording_rpl = 49,
Radio_req = 30,
Radio_rpl = 50,
DB_status_brdcst = 55,
DB_status_req = 56
}
public enum DB_STATUS
{
DISCONNECTED = 0,
CONNECTED = 1
}
public enum Radio_MSG_type
{
gw_status_req = 99,
gw_status_rpl = 199,
dekey_req = 160,
gw_list_req = 100,
gw_list_rpl = 200,
gw_zone_channel_req = 104,
gw_zone_channel_rpl = 204,
su_enable_disable_req =150,
su_enable_disable_brd =250,
poll_req = 154,
poll_brd = 231,
emerg_req =130,
emerg_rpl =230,
ptt_all_init=101,
ptt_all_stop=111,
ptt_grp_init=103,
ptt_grp_stop=113,
ptt_prv_init=102,
ptt_prv_stop=112,
dekey = 160
}
public enum RADIO_STATUS
{
OFF = 0x00,
FREE = 0x01,
ALLcall_INIT = 101,
ALLcall_INPROGRES = 121,
PrivateCall_INIT = 102,
PrivateCall_INPROGRES = 122,
GroupCall_INIT = 103,
GroupCall_INPROGRES = 123,
ChannelQuery = 104,
CallEvent = 125,
RemoteMonitor = 161,
RemoteMonitor_INPROGRES = 162,
DKEY = 160,
EnableDisable = 150,
HangTime = 108
}
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 T Peek(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.Peek();
}
}
public void Remove(T item)
{
lock (_queue)
{
if (_queue.Count != 0)
{
T itemPeek = _queue.Peek();
if (itemPeek.Equals(item))
{
_queue.Dequeue();
}
}
}
}
}
}