119 lines
3.9 KiB
Plaintext
119 lines
3.9 KiB
Plaintext
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Collections;
|
||
|
|
||
|
namespace SN_Server.ServerMSGS
|
||
|
{
|
||
|
public class SM_GPS
|
||
|
{
|
||
|
//index DBid ; value POLLmsg
|
||
|
public static InterthreadMessageQueue<SM_POLLmsg> readPOLLQueue = new InterthreadMessageQueue<SM_POLLmsg>();
|
||
|
public static InterthreadMessageQueue<SM_POLLmsg> sentPOLLQueue = new InterthreadMessageQueue<SM_POLLmsg>();
|
||
|
public static InterthreadMessageQueue<SM_POLLmsg> recvPOLLQueue = new InterthreadMessageQueue<SM_POLLmsg>();
|
||
|
public static Hashtable ht_POLL_List = new Hashtable(); // ht with all the poll requests
|
||
|
|
||
|
public static byte[] GenGPSMsg(GPS gps)
|
||
|
{
|
||
|
string msg = ServerMSG.GenMsg(0xB011, ServerConnector.serialNr, gps.i_dbid
|
||
|
+ "/" +gps.s_lat
|
||
|
+ "/" + gps.s_lng
|
||
|
+ "/" + gps.i_spd
|
||
|
+ "/" + gps.i_time);
|
||
|
return System.Text.Encoding.ASCII.GetBytes(msg);
|
||
|
}
|
||
|
|
||
|
public static byte[] GenPollRequestMsg()
|
||
|
{
|
||
|
string msg = ServerMSG.GenMsg(0x0011, ServerConnector.serialNr, "");
|
||
|
return System.Text.Encoding.ASCII.GetBytes(msg);
|
||
|
}
|
||
|
|
||
|
public static byte[] GenPollACKMsg(int func, SM_POLLmsg pmsg)
|
||
|
{
|
||
|
string msg = "";
|
||
|
switch (func)
|
||
|
{
|
||
|
case 1:
|
||
|
{
|
||
|
msg = ServerMSG.GenMsg(0xBA11, ServerConnector.serialNr, func + "/" + pmsg.DBid);
|
||
|
break;
|
||
|
}
|
||
|
case 2:
|
||
|
{
|
||
|
msg = ServerMSG.GenMsg(0xBA11, ServerConnector.serialNr, func + "/" + pmsg.DBid);
|
||
|
break;
|
||
|
}
|
||
|
case 3:
|
||
|
{
|
||
|
msg = ServerMSG.GenMsg(0xBA11, ServerConnector.serialNr, func
|
||
|
+ "/" + pmsg.DBid
|
||
|
+ "/" + pmsg.gps.i_dbid
|
||
|
+ "/" + pmsg.gps.s_lat
|
||
|
+ "/" + pmsg.gps.s_lng
|
||
|
+ "/" + pmsg.gps.i_spd
|
||
|
+ "/" + pmsg.gps.i_time);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
return System.Text.Encoding.ASCII.GetBytes(msg);
|
||
|
}
|
||
|
|
||
|
public static SM_POLLmsg DecodePoll(string paylaod)
|
||
|
{
|
||
|
SM_POLLmsg pmsg = new SM_POLLmsg();
|
||
|
string[] temp = paylaod.Split(':');
|
||
|
|
||
|
pmsg.DBid = Convert.ToInt32(temp[0]);
|
||
|
pmsg.suDBid = Convert.ToInt32(temp[1]);
|
||
|
pmsg.suid = temp[2];
|
||
|
pmsg.read = DateTime.Now.ToUniversalTime();
|
||
|
|
||
|
return pmsg;
|
||
|
}
|
||
|
|
||
|
public static void PrintPoll(SM_POLLmsg msg)
|
||
|
{
|
||
|
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||
|
Console.WriteLine("Got POLL msg from server:");
|
||
|
Console.WriteLine("msg.DBid:" + msg.DBid);
|
||
|
Console.WriteLine("msg.suDBid:" + msg.suDBid);
|
||
|
Console.WriteLine("msg.suid:" + msg.suid);
|
||
|
Console.WriteLine("msg.read:" + msg.read.ToString());
|
||
|
Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public class GPS
|
||
|
{
|
||
|
public string s_suid;
|
||
|
public int i_dbid;
|
||
|
public double d_lat;
|
||
|
public string s_lat;
|
||
|
public double d_lng;
|
||
|
public string s_lng;
|
||
|
public int i_spd;
|
||
|
public DateTime dt_time;
|
||
|
public int i_time;
|
||
|
}
|
||
|
|
||
|
public class SM_POLLmsg
|
||
|
{
|
||
|
public int DBid;
|
||
|
public int suDBid;
|
||
|
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 GPS gps;
|
||
|
}
|
||
|
}
|