SafeDispatch/AndroidLIB/RadioMSG.cs

245 lines
8.9 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AndroidLIB;
namespace AndroidLIB
{
public class RadioMSG:MSG
{
public int rOpcode;
public int gwID;
public int rgwID;
public int zoneNr;
public int channelNr;
public int sc_id;
public int status;
public int emerg;
public int radioID;
public int groupID;
public string userID;
public RadioMSG(byte[] data, int dataLen)
: base(data, dataLen)
{
Parse();
}
public RadioMSG(MSG m)
: base(m._rawdata, m._len)
{
Parse();
}
private void Parse()
{
if (OK)
{
SMd.Debug("RadioMSG parsing :" + data);
string forParsing = data;
string[] tempArr = forParsing.Split('#');
rOpcode = Int32.Parse(tempArr[0]);
SMd.Debug("RadioOpCode " + rOpcode);
switch (rOpcode)
{
case (int)Radio_MSG_type.gw_list_req:
{
break;
}
case (int)Radio_MSG_type.gw_zone_channel_req:
{
try
{
gwID = Int32.Parse(tempArr[1]);
rgwID = Int32.Parse(tempArr[2]);
zoneNr = Int32.Parse(tempArr[3]);
channelNr = Int32.Parse(tempArr[4]);
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.su_enable_disable_req:
{
SMd.Debug("su_enable_disable_req");
try
{
sc_id = Int32.Parse(tempArr[1]);
status = Int32.Parse(tempArr[2]);
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.poll_req:
{
try
{
sc_id = Int32.Parse(tempArr[1]);
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.dekey_req:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.emerg_req:
{
try
{
//sc_id = Int32.Parse(tempArr[1]);
emerg = Int32.Parse(tempArr[1]);
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.ptt_all_init:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
userID = tempArr[2];
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.ptt_grp_init:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
groupID = Int32.Parse(tmpArr2[2]);
userID = tempArr[2];
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.ptt_prv_init:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
radioID = Int32.Parse(tmpArr2[2]);
userID = tempArr[2];
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.ptt_all_stop:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
radioID = Int32.Parse(tmpArr2[2]);
userID = tempArr[2];
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.ptt_grp_stop:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
radioID = Int32.Parse(tmpArr2[2]);
userID = tempArr[2];
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.ptt_prv_stop:
{
try
{
String tmp = tempArr[1];
string[] tmpArr2 = tmp.Split('.');
gwID = Int32.Parse(tmpArr2[0]);
rgwID = Int32.Parse(tmpArr2[1]);
radioID = Int32.Parse(tmpArr2[2]);
userID = tempArr[2];
}
catch (Exception ex)
{
SMd.Debug(ex.ToString());
}
break;
}
case (int)Radio_MSG_type.gw_status_req:
{
break;
}
default:
SMd.Debug("Unknown rOPcode:" + rOpcode);
break;
}//endswitch
}
}
}
}