SafeDispatch/SDRgateway/Defs.cs

352 lines
12 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SDRgateway
{
public enum CM_MSG_TYPE
{
CM_DATA = 0x00,
CM_REGISTER_REQ = 0x02,
CM_REGISTER_REPLY = 0x03,
CM_BROADCAST = 0x04,
CM_REPORT = 0x01
};
public enum REG_ANSW
{
REG_OK = 0x00,
REG_DUPLICATE_ADDRESS,
REG_INVALID_ADDRESS,
REG_NOT_AVAILABLE,
REG_INVALID_PASSWD
};
enum DEL_ANS
{
DELIVERY_OVERLOAD = 0x40,
DELIVERY_SERVICE_DISABLED = 0x41,
DELIVERY_SERV_TEMP_NOT_AVAIL = 0x42,
DELIVERY_DEST_NOT_AUTH_FOR_SDS = 0x44,
DELIVERY_UNKNOWN_DEST = 0x45,
DELIVERY_GROUP_ADDR = 0x47,
DELIVERY_NOT_REACHABLE = 0x4a,
DELIVERY_NOT_REGISTERED = 0x4b,
DELIVERT_DEST_QUEUE_FULL = 0x4c,
DELIVERY_MSG_TOO_LONG = 0x4d,
DELIVERY_DEST_NOT_SUPPORT_PDU = 0x4e,
DELIVERY_DEST_NOT_CONNECTED = 0x4f,
DELIVERY_PROT_NOT_SUPP = 0x50,
DELIVERY_DEST_NOT_ACC_SDS = 0x53,
DELIVERY_DEST_PROHIBITED = 0x56,
DELIVERY_UNKOWN_SUBSCRIBER = 0x58,
DELIVERY_DEST_NOT_REACHABLE = 0x5a,
DELIVERY_TEXT_ERROR = 0x8d,
DELIVERY_CORRUPT_INFO = 0x8e
};
public class msgCell
{
public CTRL_MSG_TYPE type;
public string reqID;
public string appID;
public string IMEI;
public string result;
public string lat, lng, radius, spd, dir; // GPS data
public string event_info;
public int ars, emergency, poll;
public string sms;
public MSG_TYPE msg;
public DateTime time;
public uint time70;
public msgCell()
{
type = CTRL_MSG_TYPE.Unknown;
msg = MSG_TYPE.GPS;
sms = "";
ars = -1;
emergency = -1;
poll = -1;
time70 = 0;
}
}
public enum CTRL_MSG_TYPE
{
Loc_Reg_Answ = 0x00,
Trig_Loc_Answ = 0x01,
Immed_Loc_Answ = 0x02,
Trig_Loc_Rep = 0x10,
Trig_Loc_Rep_error = 0x11,
Immed_Loc_rep = 0x12,
Immed_Loc_rep_error = 0x13,
Unsolicited_Loc_rep = 0x14,
Unsolicited_Loc_rep_error = 0x15,
Unknown = 0xff
};
public enum MSG_TYPE
{
GPS = 0x010,
GPSpoll = 0x11,
ARS = 0x02,
SMS = 0x03,
Emergency = 0x04,
ARS_ON = 0x05,
ARS_OFF = 0x06
};
//public class ConvertDT
//{
// private System.DateTime dateTime;
// /// <summary>
// /// This is the class constructor
// /// </summary>
// //public ConvertDT()
// //{
// //}
// /// <summary>
// /// This method makes the conversion from Unix time to a DateTime object
// /// and returns a DateTime object
// /// </summary>
// /// <param name="param">the Unix time</param>
// /// <returns>The method returns a DateTime object</returns>
// //public System.DateTime GetDTFromSeconds(uint param)
// //{
// // dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// // dateTime = dateTime.AddSeconds((double)param);
// // return dateTime;
// //}
// /// <summary>
// /// This method converts a DateTime object into the corresponding
// /// Unix time (number of seconds from 1970/01/01) - attention, does not make
// /// any conversion to GMT time
// /// </summary>
// /// <param name="param">the DateTime object to be converted</param>
// /// <returns>the corresponding Unix time, as a uint number</returns>
// //public uint GetSecondsFromDT(DateTime param)
// //{
// // System.DateTime datetime = param;
// // long nOfSeconds;
// // System.DateTime dt70 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// // TimeSpan span = datetime - dt70;
// // nOfSeconds = (long)span.TotalSeconds;
// // return ((uint)nOfSeconds);
// //}
// //public static uint GetSecondsLocalFromDT(DateTime param)
// //{
// // System.DateTime datetime = param;
// // long nOfSeconds;
// // System.DateTime dt70 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// // System.DateTime dttmp1 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// // System.DateTime dttmp2;
// // dttmp2 = dttmp1.ToLocalTime();
// // TimeSpan span2 = dttmp2 - dttmp1;
// // TimeSpan span = datetime - dt70;
// // //nOfSeconds = (long)span.TotalSeconds - (long)span2.TotalSeconds -3600; //mai scot o ora - 3600
// // if (System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(param)) nOfSeconds = (long)span.TotalSeconds - (long)span2.TotalSeconds - 3600; //mai scot o ora - 3600
// // else nOfSeconds = (long)span.TotalSeconds - (long)span2.TotalSeconds;
// // return ((uint)nOfSeconds);
// //}
// /// <summary>
// /// This method makes the conversion from GMT Unix time to a DateTime object
// /// and returns local time as a DateTime object
// /// </summary>
// /// <param name="param">the Unix time</param>
// /// <returns>The method returns a DateTime object</returns>
// //public System.DateTime GetDTLocalFromSeconds(uint param)
// //{
// // dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// // dateTime = dateTime.AddSeconds((double)param);
// // dateTime = dateTime.ToLocalTime();
// // return dateTime;
// //}
// /// <summary>
// /// This method makes the conversion from local Unix time to a DateTime object
// /// and returns GMT time as a DateTime object
// /// </summary>
// /// <param name="param">the Unix time</param>
// /// <returns>The method returns a DateTime object</returns>
// //public System.DateTime GetDTGMTFromSeconds(uint param)
// //{
// // dateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
// // dateTime = dateTime.AddSeconds((double)param);
// // dateTime = dateTime.ToUniversalTime();
// // return dateTime;
// //}
// /// <summary>
// /// This method converts from local time to GMT
// /// </summary>
// /// <param name="param">local time, as UNIX time</param>
// /// <returns>GMT time, as UNIX time</returns>
// //public uint ConvertLocalToGMT(uint param)
// //{
// // DateTime time = this.GetDTFromSeconds(param);
// // DateTime GMTTime = time.ToUniversalTime();
// // TimeSpan span = GMTTime - time;
// // long nOfSeconds = (long)span.TotalSeconds;
// // return (uint)(nOfSeconds + param);
// //}
// /// <summary>
// /// This method converts from GMT to local time
// /// </summary>
// /// <param name="param">GMT as UNIX time</param>
// /// <returns>local time, as UNIX time</returns>
// //public uint ConvertGMTToLocal(uint param)
// //{
// // DateTime time = this.GetDTFromSeconds(param);
// // DateTime GMTTime = time.ToUniversalTime();
// // TimeSpan span = time - GMTTime;
// // long nOfSeconds = (long)span.TotalSeconds;
// // return (uint)(nOfSeconds + param);
// //}
// /// <summary>
// /// This method converts an integer, representing the number of seconds
// /// from 00:00 to the current time of the day, to the corresponding String
// /// </summary>
// /// <param name="param">the number of seconds</param>
// /// <returns>the String in hh:mm format</returns>
// //public String GetTimeFromSeconds(uint param)
// //{
// // String hours, minutes;
// // uint hoursInt, minutesInt;
// // hoursInt = param / 3600;
// // minutesInt = (param - (hoursInt * 3600)) / 60;
// // hours = Convert.ToString(hoursInt);
// // minutes = Convert.ToString(minutesInt);
// // if (hours.Length == 1)
// // hours = "0" + hours;
// // if (minutes.Length == 1)
// // minutes = "0" + minutes;
// // return (Convert.ToString(hours) + ":" + Convert.ToString(minutes));
// //}
// /// <summary>
// /// Returns just the time of day from the parameter, removing all other info
// /// </summary>
// /// <param name="param">unix time</param>
// /// <returns>Time of day </returns>
// //public String TimeOfDay(uint param)
// //{
// // String toReturn = "";
// // DateTime tempObj = this.GetDTFromSeconds(param);
// // if (tempObj.Hour >= 10)
// // toReturn = toReturn + tempObj.Hour.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + tempObj.Hour.ToString() + ":";
// // if (tempObj.Minute >= 10)
// // toReturn = toReturn + tempObj.Minute.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + tempObj.Minute.ToString() + ":";
// // if (tempObj.Second >= 10)
// // toReturn = toReturn + tempObj.Second.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + tempObj.Second.ToString();
// // return toReturn;
// //}
// //public String TimeOfDayHHMMLocal(uint param)
// //{
// // uint ParamLoc;
// // ParamLoc = ConvertGMTToLocal(param);
// // String toReturn = "";
// // DateTime tempObj = this.GetDTFromSeconds(ParamLoc);
// // if (tempObj.Hour >= 10)
// // toReturn = toReturn + tempObj.Hour.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + tempObj.Hour.ToString() + ":";
// // if (tempObj.Minute >= 10)
// // toReturn = toReturn + tempObj.Minute.ToString();
// // else
// // toReturn = toReturn + "0" + tempObj.Minute.ToString();
// // return toReturn;
// //}
// //public String DateTimeOfDayHHMMLocal(uint param)
// //{
// // uint ParamLoc;
// // ParamLoc = ConvertGMTToLocal(param);
// // String toReturn = "";
// // DateTime tempObj = this.GetDTFromSeconds(ParamLoc);
// // if (tempObj.Hour >= 10)
// // toReturn = toReturn + tempObj.Hour.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + tempObj.Hour.ToString() + ":";
// // if (tempObj.Minute >= 10)
// // toReturn = toReturn + tempObj.Minute.ToString();
// // else
// // toReturn = toReturn + "0" + tempObj.Minute.ToString();
// // //toReturn = tempObj.Month +"//"+tempObj.Day +"//"+tempObj.Year+" "+toReturn;
// // toReturn = Convert.ToString(tempObj);
// // //toReturn = "fane " + toReturn;
// // return toReturn;
// //}
// //public String TimeOfDayHHMMDateTime(TimeSpan param)
// //{
// // String toReturn = "";
// // if (param.Hours >= 10)
// // toReturn = toReturn + param.Hours.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + param.Hours.ToString() + ":";
// // if (param.Minutes >= 10)
// // toReturn = toReturn + param.Minutes.ToString();
// // else
// // toReturn = toReturn + "0" + param.Minutes.ToString();
// // return toReturn;
// //}
// //public String DatePickerToDateHHMM(DateTime Data)
// //{
// // String toReturn = "";
// // toReturn = toReturn + System.Convert.ToString(Data.Date.ToShortDateString()) + " ";
// // if (Data.TimeOfDay.Hours >= 10)
// // toReturn = toReturn + Data.TimeOfDay.Hours.ToString() + ":";
// // else
// // toReturn = toReturn + "0" + Data.TimeOfDay.Hours.ToString() + ":";
// // if (Data.TimeOfDay.Minutes >= 10)
// // toReturn = toReturn + Data.TimeOfDay.Minutes.ToString();
// // else
// // toReturn = toReturn + "0" + Data.TimeOfDay.Minutes.ToString();
// // return toReturn;
// //}
//}
}