SafeDispatch/SDRgateway/MainForm.cs

882 lines
32 KiB
C#
Raw Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using SafeMobileLib;
using SharedUI;
using System.Diagnostics;
using static SDRgateway.LIP;
using SafeMobileLib.Registration;
using SafeMobileLib.Helpers;
using System.Threading;
using System.Timers;
namespace SDRgateway
{
public partial class MainForm : Form
{
//public static Config cfg;
private SDR SDRConnector;
private MessageBuss msgBuss;
private SMSmanager sms;
private PingThread pingThread;
private static System.Timers.Timer aTimer;
private static Int32 _GWID = 0;
private static int _radioID = 0;
private Gateway currentGateway = null;
UInt32 callOutNumber = 1;
byte cm_msg_id = 1;
public MainForm()
{
InitializeComponent();
Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Utils.WriteLine(lbVersion.Text = "Version: " + v.ToString());
this.Text += " - v." + v.ToString();
Utils.WriteLine("SDR gateway. SafeMobile 2012-2017", ConsoleColor.Magenta);
Utils.WriteLine("");
// load the config file
Program.cfg.LoadConfig();
// set the value for checkbox
cbAutoConnect.Checked = Program.cfg.SDR_Autoconnect;
//LIPSDR.printBytesArray(LIPSDR.Stds_CallOutAlertPDU_sdsEncoder(10006, 11, 5, "this is a test", LIPSDR.TGctrl.TGChangeOnAlert));
//LIPSDR.printBytesArray(LIPSDR.Stds_CallOutAlertPDU_sdsEncoder(623, 3, 00, "this is a test", LIPSDR.TGctrl.TGChangeOnAlert));
/// TODO EMERGENCY ACK
/// bigu limitation for South africa
label1.Visible = false;
label2.Visible = false;
label4.Visible = false;
cbStoreForward.Visible = false;
cbCallOut.Visible = true;
tbSFServerID.Visible = false;
/// end limitation
ddlTgCtrl.SelectedIndex = 1;
}
void pingThread_OnNewPingComplete(bool status, string ip)
{
if (status)
{
Utils.WriteLine("Ping to " + ip + " succeded");
}
else
{
Utils.WriteLine("Ping to " + ip + " failed");
}
}
/// <summary>
/// Verify if an IP address is a valid IP address
/// </summary>
/// <param name="ip">IP which needs to be checked</param>
/// <returns>True if the email is a valid one, or false otherwise</returns>
bool IsValidIP(string ip)
{
Match match = Regex.Match(ip, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");
return match.Success;
}
private void btnSave_Click(object sender, EventArgs e)
{
if (!IsValidIP(tbMUPSpass.Text))
{
MessageBox.Show("The password is invalid. It must be a valid IP address!", "Invalid password");
return;
}
//TestClass t = new TestClass();
try
{
Program.cfg.SDR_ISSI = Int32.Parse(tbMUPSappID.Text);
Program.cfg.SDR_pass = tbMUPSpass.Text;
Program.cfg.SDR_IP = tbMUPSip.Text;
Program.cfg.SDR_port = int.Parse(tbMUPSport.Text);
Program.cfg.messageBusIP = tbMBip.Text;
Program.cfg.messageBusPort = int.Parse(tbMBport.Text);
Program.cfg.SDR_StoreTM = cbStoreForward.Text.Equals("Yes") ? 1 : 0;
Program.cfg.SDR_SFServer = (Int32)tbSFServerID.Value;
Program.cfg.SDR_CallOut = cbCallOut.Text.Equals("Yes") ? 1 : 0;
Program.cfg.PositionErrorTolerance = PositionError.GetPositionError(cbPositionErrorTolerance.Text);
//bigu limitation for SouthAfrica
Program.cfg.SDR_StoreTM = 0;
Program.cfg.SDR_SFServer = 0;
// MainForm.cfg.SDR_CallOut = 0;
//end limitation
//MainForm.cfg.DB_IP = tbDBip.Text;
//MainForm.cfg.DB_port = tbDBport.Text;
Program.cfg.SaveCFGFile();
MessageBox.Show("Configs saved to file. Please restart the gateway for this settings to be used.");
}
catch (Exception ex)
{
Utils.WriteLine("btnSave_Click " + ex.ToString(), ConsoleColor.Red);
}
}
private void LoadSettings_GUI()
{
//MUPS
tbMUPSappID.Text = Program.cfg.SDR_ISSI.ToString();
tbMUPSpass.Text = Program.cfg.SDR_pass.ToString();
tbMUPSip.Text = Program.cfg.SDR_IP;
tbMUPSport.Text = Program.cfg.SDR_port.ToString();
tbSFServerID.Text = Program.cfg.SDR_SFServer.ToString();
cbStoreForward.Text = Program.cfg.SDR_StoreTM == 1 ? "Yes" : "No";
cbCallOut.Text = Program.cfg.SDR_CallOut == 1 ? "Yes" : "No";
cbPositionErrorTolerance.Text = Program.cfg.PositionErrorTolerance.ToHumanString();
//message buss
tbMBip.Text = Program.cfg.messageBusIP;
tbMBport.Text = Program.cfg.messageBusPort.ToString();
//DataBAse
//tbDBip.Text = MainForm.cfg.DB_IP;
//tbDBport.Text = MainForm.cfg.DB_port;
}
private void btnConnect_Click(object sender, EventArgs e)
{
if (btnConnect.Text.Equals("Connect"))
{
btnConnect.Text = "Disconnect";
SDRConnector.Start();
}
else if (btnConnect.Text.Equals("Disconnect"))
{
btnConnect.Text = "Disconnecting...";
btnConnect.Enabled = false;
SDRConnector.Stop(SDR.SDR_STATUS.Disconnecting);
}
}
delegate void PropertyChangedCallback(SDR.SDR_STATUS register);
void SDRConnector_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
SM.Debug("New value for radio status:" + ((SDR)sender).registered);
PropertyChangedCallback d = new PropertyChangedCallback(RegStatusChanged);
this.Invoke(d, new object[] { ((SDR)sender).registered });
}
private void RegStatusChanged(SDR.SDR_STATUS rStatus)
{
switch (rStatus)
{
case SDR.SDR_STATUS.Connected:
{
lbStatus.Text = "Connected";
btnConnect.Text = "Disconnect";
break;
}
case SDR.SDR_STATUS.Connecting:
{
lbStatus.Text = "Trying to connect!";
btnConnect.Text = "Disconnect";
break;
}
case SDR.SDR_STATUS.Disconnected:
{
//lbStatus.Text = "Reconnecting";
btnConnect.Text = "Connect";
btnConnect.Enabled = true;
break;
}
case SDR.SDR_STATUS.NoConnection:
{
if (btnConnect.Text.Equals("Disconnect"))
;
else
{
lbStatus.Text = "Not connected";
btnConnect.Text = "Connect";
}
btnConnect.Enabled = true;
break;
}
case SDR.SDR_STATUS.Disconnecting:
{
if (!lbStatus.Text.EndsWith("Disconnecting..."))
lbStatus.Text = "Disconnecting...";
btnConnect.Text = "Disconnecting...";
break;
}
}
// update envet into the UI lable which is designated for the event
UpdateLabelEvent(lbStatus.Text);
}
#region UI changes
private void ResetMenuBackgroundAndFont()
{
menuStatus.IsSelected = false;
menuSDRSettings.IsSelected = false;
menuMessageBus.IsSelected = false;
menuSave.IsSelected = false;
}
private void menuClick(object sender, EventArgs e)
{
if ((MenuButton)sender == menuSave)
{
btnSave_Click(sender, e);
menuSave.IsSelected = false;
return;
}
ResetMenuBackgroundAndFont();
HideAllPanels();
if ((MenuButton)sender == menuStatus)
{
panelStatus.BringToFront();
panelStatus.Visible = true;
menuStatus.IsSelected = true;
}
else if ((MenuButton)sender == menuSDRSettings)
{
panelSDRSettings.BringToFront();
panelSDRSettings.Visible = true;
menuSDRSettings.IsSelected = true;
}
else if ((MenuButton)sender == menuMessageBus)
{
panelMessageBus.BringToFront();
panelMessageBus.Visible = true;
menuMessageBus.IsSelected = true;
}
}
private void HideAllPanels()
{
panelStatus.Visible = false;
panelStatus.SendToBack();
panelSDRSettings.Visible = false;
panelSDRSettings.SendToBack();
panelMessageBus.Visible = false;
panelMessageBus.SendToBack();
}
#endregion
private void LogoClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("http://www.safemobile.com");
}
private void cbStoreForward_SelectedValueChanged(object sender, EventArgs e)
{
if (cbStoreForward.Text.Equals("Yes"))
tbSFServerID.Enabled = true;
else
tbSFServerID.Enabled = false;
}
/// <summary>
/// Update the label from the UI in which all events are stored
/// </summary>
/// <param name="message">The message which needs to be written into the label</param>
private void UpdateLabelEvent(String message)
{
this.Invoke((MethodInvoker)delegate
{
//tbEvent.BackColor = Color.White;
// remove a line
/*
if (Regex.Matches(labelEvent.Text, Environment.NewLine).Count >= labelEventMaxLines)
labelEvent.Text = labelEvent.Text.Substring(labelEvent.Text.IndexOf(Environment.NewLine) + 1);
*/
// add message at which the date is added
tbEvent.AppendText(String.Format("{0:H:mm:ss} - {1}", DateTime.Now, message) + Environment.NewLine);
});
}
private void menuMessageBus_Load(object sender, EventArgs e)
{
}
int count = 0;
private void button1_Click(object sender, EventArgs e)
{
//SDRConnector.SEND_CALL_OUT_MESSAGE_TEST_623(count++);
}
private void cbAutoConnect_CheckedChanged(object sender, EventArgs e)
{
Program.cfg.SaveConfigOption("SDR", "SDR_Autoconnect", cbAutoConnect.Checked ? "true" : "false");
}
private void MainForm_Load(object sender, EventArgs e)
{
// register for registration changed event
this.OnRegistrationCompleted += OnRegistrationResponseHandler;
Register();
}
private async void Register()
{
RegistrationResponse regResponse = await RegistrationHelper.RegisterGateway(Program.cfg.APPLICATION_SERVER_IP, Program.cfg.regPort);
// raise event for registration completed
OnRegistrationCompleted?.Invoke(regResponse);
//while (unregistered)
//{
// RegistrationResponse regResponse = await RegistrationHelper.RegisterGateway(Program.cfg.APPLICATION_SERVER_IP, Program.cfg.regPort);
// if (regResponse.ToString() == "")
// unregistered = false;
// // raise event for registration completed
// OnRegistrationCompleted?.Invoke(regResponse);
// Thread.Sleep(1000);
//}
}
#region REGISTRATION HANDLER
private void OnRegistrationResponseHandler(RegistrationResponse regResponse)
{
this.Invoke((MethodInvoker)delegate ()
{
switch (regResponse.RegistrationStatus)
{
case RegistrationCode.ServerUnreachable:
onRegistrationServerUnreachable();
break;
case RegistrationCode.Unauthorized:
onRegistraionUnauthorized();
break;
case RegistrationCode.Registered:
onRegistrationCompleted(regResponse);
break;
}
});
}
private void onRegistrationServerUnreachable()
{
DisplayMessageBox("Application Server is unreachable. Please check internet connection and the application server IP in the configuration file.",
"App Server Unreachable", MessageBoxIcon.Error);
Application.Exit();
}
private void onRegistraionUnauthorized()
{
DisplayMessageBox("Please register this gateway in the admin module.", "Unauthorized gateway", MessageBoxIcon.Exclamation);
}
private void DisplayMessageBox(String message, String title, MessageBoxIcon boxType)
{
MessageBox.Show(this, "Application Server is unreachable. Please check internet connection and the application server IP in the configuration file.",
"App Server Unreachable", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
private void onRegistrationCompleted(RegistrationResponse response)
{
String currentIP = "127.0.0.1";
// this gateway is on other computer than the application server is
if (!Program.cfg.APPLICATION_SERVER_IP.Equals("127.0.0.1"))
currentIP = RegistrationHelper.GatewayIP;
// update values for Message bus, database received from AppServer
Program.cfg.DB_IP = response.DataBaseServerIP;
Program.cfg.DB_passwd = response.DataBasePassword;
Program.cfg.DB_port = response.DataBasePort + "";
Program.cfg.DB_schema = response.DataBaseName;
Program.cfg.DB_user = response.DataBaseUser;
Program.cfg.messageBusIP = response.MessageBusIP;
Program.cfg.messageBusPort = response.MessageBusPort;
DBgatewaysManager gatewayManager = new DBgatewaysManager(Program.cfg.DB_IP, Program.cfg.DB_schema,
Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
// get current gateway
currentGateway = getGateway(currentIP, gatewayManager);
List<RadioGateway> radioGws = getRadioGWsFromDB(currentGateway.Id, gatewayManager);
// check if any sdr gateway is defined
if (radioGws.Count == 0)
{
onNoRadioGatewayDefined();
return;
}
else
{
RadioGateway currentRadioGw = radioGws[0];
// search for radioGws with same identifier as this gateway
foreach (RadioGateway rg in radioGws)
{
if (rg.Name.ToLower().Equals(Program.cfg.GatewayName.ToLower()))
{
currentRadioGw = rg;
break;
}
}
// update values for current gateway
Program.cfg.SDR_ISSI = currentRadioGw.Imei;
Program.cfg.SDR_IP = currentRadioGw.Ip;
// remove all others gateways from the list
radioGws.Clear();
radioGws.Add(currentRadioGw);
}
if (Program.cfg.SDR_ping > 0)
{
pingThread = new PingThread(Program.cfg.SDR_IP, Program.cfg.SDR_ping);
pingThread.OnNewPingComplete += new PingThread.NewPingCompleteDEl(pingThread_OnNewPingComplete);
}
Utils.WriteLine("Starting application.");
SDRConnector = new SDR();
SDRConnector.OnEventToDisplayOnUI += delegate (string message)
{
UpdateLabelEvent(message);
};
SDRConnector.OnSDRStopped += delegate ()
{
UpdateLabelEvent("Disconnected");
this.Invoke((MethodInvoker)delegate
{
btnConnect.Enabled = true;
btnConnect.Text = "Connect";
});
};
// set if the message needs to be stored on the server and resent once at X seconds
SDRConnector.setStoreAndForwardOption(Program.cfg.SDR_StoreTM == 1 ? true : false);
SDRConnector.PropertyChanged += new PropertyChangedEventHandler(SDRConnector_PropertyChanged);
//SDRConnector.Start();
msgBuss = new MessageBuss(Program.cfg.messageBusIP, Program.cfg.messageBusPort.ToString(), SDRConnector);
Set500Timer();
msgBuss.OnPollRequest += delegate (Int64 radioID, bool isLong, string seqNumber)
{
SDRConnector.Send_Imed_Loc_req((UInt32)radioID, isLong, seqNumber);
};
msgBuss.OnSDSRequest += delegate (Int64 radioID, Int64 gatewayID, Int64 gatewayRadioID, string message, int type, string seqID)
{
SDRConnector.SEND_SMS((uint)radioID, message);
Utils.WriteLine("SMSConfirm.getFromConfirmationQueue(hret.seq_no)=" + seqID);
string test = "#242#1#";
//send SMS ack to message bus
MessageBuss.SendOnMsgBuss(seqID, test);
};
msgBuss.OnUnitsUpdated += delegate ()
{
DBvehiclesManager dbVehManager = new DBvehiclesManager(Program.cfg.DB_IP, Program.cfg.DB_schema, Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
try
{
lock (SDR.dictionaryLock)
{
SDR.RadioIdToLastPosDictionary = dbVehManager.getImeiLastPosDictionary(true);
Utils.WriteLine("Received " + SDR.RadioIdToLastPosDictionary.Count + " units", ConsoleColor.Green);
foreach (var item in SDR.RadioIdToLastPosDictionary)
{
Utils.Write(String.Format("{0:#############} |||| ", item.Key), ConsoleType.ALL);
}
}
}
catch (Exception ex)
{
Utils.WriteLine("Unable to get assigned units " + ex.ToString(), ConsoleColor.Red);
}
};
msgBuss.OnCallOutRequest += delegate (ulong destISSI, ushort callOutSeverity, string GeoName)
{
SDRConnector.SendCallOut((uint)destISSI, callOutSeverity, GeoName);
};
msgBuss.OnCallOutStopRequest += delegate (ulong destISSI, ushort callOutSeverity)
{
SDRConnector.SendCallOutStop((uint)destISSI, callOutSeverity);
};
lbStatus.Text = "Not connected";
lbGateway.Text = "gateway " + Program.cfg.SDR_ISSI.ToString() + " status";
LoadSettings_GUI();
sms = new SMSmanager(SDRConnector, Program.cfg);
// press the auto connect if needed
if (cbAutoConnect.Checked)
btnConnect.PerformClick();
ContextMenu contextMenu = new ContextMenu();
contextMenu.MenuItems.Add("Check for updates...", (s, e2) => {
UpdateForm uf = new UpdateForm(App.GW_TETRA_SDR, true) { IsDevelop = Program.cfg.isDevelop };
uf.Show();
});
contextMenu.MenuItems.Add("Exit", (s, e2) => CloseApp());
notifyIcon1.ContextMenu = contextMenu;
// check for a new version if available
if (Program.cfg.autoupdate)
CheckForUpdate();
}
#endregion
#region GATEWAY - RADIO GATEWAY
private Gateway getGateway(String gatewayIP, DBgatewaysManager gatewayManager)
{
List<Gateway> allGateways = gatewayManager.getAllGateways();
foreach (Gateway g in allGateways)
{
if (g.Ip == gatewayIP)
{
Utils.WriteLine("Gateway IP found in registration tabel. ID:" + g.Id, ConsoleColor.Yellow);
currentGateway = g;
Program.cfg.GW_ID = g.Id;
Program.cfg.GW_IP = g.Ip;
// TODO update thegateway infos in the config file
return g;
}
}
return null;
}
private List<RadioGateway> getRadioGWsFromDB(Int64 gatewayID, DBgatewaysManager gatewayManager)
{
List<RadioGateway> list = gatewayManager.gelAllRadioGateways(gatewayID);
List<RadioGateway> listtoreturn = new List<RadioGateway>();
foreach (RadioGateway g in list)
listtoreturn.Add(g);
return listtoreturn;
}
private void onNoRadioGatewayDefined()
{
DisplayMessageBox("No SDR controller defined in the admin module for this computer. Please contact your administrator.", "No SDR controller defined", MessageBoxIcon.Exclamation);
}
private static void SendGatewayAlive(Int32 GWID, int radioID)
{
string test = "#500#" + GWID + "#" + radioID + "#ON#";
MessageBuss.SendOnMsgBuss("0.0", test);
}
private void Set500Timer()
{
// Create a timer with a two second interval.
aTimer = new System.Timers.Timer(5000);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += GWAliveTimer;
aTimer.AutoReset = true;
aTimer.Enabled = true;
}
private void GWAliveTimer(Object source, ElapsedEventArgs e)
{
String currentIP = "127.0.0.1";
// this gateway is on other computer than the application server is
if (!Program.cfg.APPLICATION_SERVER_IP.Equals("127.0.0.1"))
currentIP = RegistrationHelper.GatewayIP;
DBgatewaysManager gatewayManager = new DBgatewaysManager(Program.cfg.DB_IP, Program.cfg.DB_schema,
Program.cfg.DB_user, Program.cfg.DB_passwd, Program.cfg.DB_port);
// get current gateway
currentGateway = getGateway(currentIP, gatewayManager);
List<RadioGateway> radioGws = getRadioGWsFromDB(currentGateway.Id, gatewayManager);
_GWID = (Int32)radioGws[0].Gw_id;
_radioID = radioGws[0].Id;
SendGatewayAlive(_GWID, _radioID);
Console.WriteLine("The Elapsed event was raised at {0:HH:mm:ss.fff}",
e.SignalTime);
}
#endregion
#region UPDATE
/// <summary>
/// Check for new version release on SafeMobile Portal
/// The check is done by comparing Current Assembly Version with the one
/// written in a xml file on the portal.
/// </summary>
private void CheckForUpdate()
{
App appType = App.GW_TETRA_SDR;
AutoUpdate au = new AutoUpdate(appType) { IsDevelop = Program.cfg.isDevelop };
au.OnNewVersionAvailable += delegate (string version)
{
notifyIcon1.Text = "New version available";
notifyIcon1.ShowBalloonTip(2500, $"{App.GetAppName(appType)} version {version} available",
$"Press to download and install the latest version of {App.GetAppName(appType)}.", ToolTipIcon.Info);
notifyIcon1.BalloonTipClicked += delegate (object sender, EventArgs e)
{
if (notifyIcon1.Text.Equals("New version available"))
{
UpdateForm uf = new UpdateForm(appType, true) { IsDevelop = Program.cfg.isDevelop };
uf.Show();
}
};
};
// call method to check for new updated
au.CheckUpdate();
}
#endregion
private void CloseApp()
{
Process oldProcess = Process.GetCurrentProcess();
oldProcess.Kill();
Application.Exit();
}
#region EVENTS
public delegate void RegistrationCompleted(RegistrationResponse response);
public event RegistrationCompleted OnRegistrationCompleted;
#endregion
#region TEST CallOut
/*
private void btnAlert_Click(object sender, EventArgs e)
{
if (txtTGNumber.Text.Length == 0)
{
MessageBox.Show("Please add a TGNumber !");
return;
}
try
{
UInt32 sourceISSI = (UInt32)spinSourceISSI.Value;
UInt32 destISSI = (UInt32)spinDestISSI.Value;
UInt16 callOutSeverity = (UInt16)spinSeverity.Value;
UInt32 tgNumber = UInt32.Parse(txtTGNumber.Text);
string data = txtMessage.Text;
uint tgCtrl = (uint)LIPSDR.TGctrl.TGChangeUserInter;
if (ddlTgCtrl.SelectedText == LIPSDR.TGctrl.TGChangeOnAlert.ToString())
tgCtrl = (uint)LIPSDR.TGctrl.TGChangeOnAlert;
byte[] result = SDRConnector.SendCallOut(chkPrefixWithSize.Checked, (uint)LIPSDR.CallOutFunction.Alert, ++callOutNumber, callOutSeverity, tgCtrl, tgNumber, ref cm_msg_id, sourceISSI, destISSI, data);
if (result != null && result.Length > 0)
{
txtOutput.Text = BitConverter.ToString(result);
Utils.WriteLine("RX :" + txtOutput.Text,ConsoleColor.Green);
if (this.InvokeRequired)
listCallOutNumber.Invoke(new Action(() => listCallOutNumber.Items.Add(callOutNumber)));
else
listCallOutNumber.Items.Add(callOutNumber);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnTest_Click(object sender, EventArgs e)
{
try
{
UInt32 sourceISSI = (UInt32)spinSourceISSI.Value;
UInt32 destISSI = (UInt32)spinDestISSI.Value;
string data = txtMessage.Text;
byte[] result = SDRConnector.SendCallOut(chkPrefixWithSize.Checked, (uint)LIPSDR.CallOutFunction.Test, ++callOutNumber, 0, (uint)LIPSDR.TGctrl.TGControlNotUsed, 0, ref cm_msg_id, sourceISSI, destISSI, data);
if (result != null && result.Length > 0)
{
txtOutput.Text = BitConverter.ToString(result);
Utils.WriteLine("RX :" + txtOutput.Text, ConsoleColor.Green);
if (this.InvokeRequired)
listCallOutNumber.Invoke(new Action(() => listCallOutNumber.Items.Add(callOutNumber)));
else
listCallOutNumber.Items.Add(callOutNumber);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnInfo_Click(object sender, EventArgs e)
{
try
{
UInt32 sourceISSI = (UInt32)spinSourceISSI.Value;
UInt32 destISSI = (UInt32)spinDestISSI.Value;
string data = txtMessage.Text;
byte[] result = SDRConnector.SendCallOut(chkPrefixWithSize.Checked, (uint)LIPSDR.CallOutFunction.Info, ++callOutNumber, 0, (uint)LIPSDR.TGctrl.TGControlNotUsed, 0, ref cm_msg_id, sourceISSI, destISSI, data);
if (result != null && result.Length > 0)
{
txtOutput.Text = BitConverter.ToString(result);
Utils.WriteLine("RX :" + txtOutput.Text, ConsoleColor.Green);
if (this.InvokeRequired)
listCallOutNumber.Invoke(new Action(() => listCallOutNumber.Items.Add(callOutNumber)));
else
listCallOutNumber.Items.Add(callOutNumber);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnClear_Click(object sender, EventArgs e)
{
try
{
if (listCallOutNumber.SelectedItem == null)
{
MessageBox.Show("Please select a callOutNumber !");
return;
}
UInt32 sourceISSI = (UInt32)spinSourceISSI.Value;
UInt32 destISSI = (UInt32)spinDestISSI.Value;
string data = txtMessage.Text;
UInt32 callOutNumber = UInt32.Parse(listCallOutNumber.SelectedItem.ToString());
byte[] result = SDRConnector.SendCallOut(chkPrefixWithSize.Checked, (uint)LIPSDR.CallOutFunction.Clear, callOutNumber, 0, (uint)LIPSDR.TGctrl.TGControlNotUsed, 0, ref cm_msg_id, sourceISSI, destISSI, data);
if (result != null && result.Length > 0)
{
listCallOutNumber.Items.Remove(callOutNumber);
txtOutput.Text = BitConverter.ToString(result);
Utils.WriteLine("RX :" + txtOutput.Text, ConsoleColor.Green);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnAvalability_Click(object sender, EventArgs e)
{
UInt32 sourceISSI = (UInt32)spinSourceISSI.Value;
UInt32 destISSI = (UInt32)spinDestISSI.Value;
byte[] result = SDRConnector.SendCallOut((uint)LIPSDR.CallOutFunction.Availability, 0xF0, 0, (uint)LIPSDR.TGctrl.TGControlNotUsed, 0, ref cm_msg_id, sourceISSI, destISSI, "");
if (result != null && result.Length > 0)
{
txtOutput.Text = BitConverter.ToString(result).Replace("-", " ");
}
}
private void btnAvalabilityRequest_Click(object sender, EventArgs e)
{
UInt32 sourceISSI = (UInt32)spinSourceISSI.Value;
UInt32 destISSI = (UInt32)spinDestISSI.Value;
byte[] result = SDRConnector.SendCallOut(chkPrefixWithSize.Checked, (uint)LIPSDR.CallOutFunction.AvailabilityRequest, 0, 0, (uint)LIPSDR.TGctrl.TGControlNotUsed, 0, ref cm_msg_id, sourceISSI, destISSI, "");
if (result != null && result.Length > 0)
{
txtOutput.Text = BitConverter.ToString(result).Replace("-", " ");
}
}
private void btnClearList_Click(object sender, EventArgs e)
{
listCallOutNumber.Items.Clear();
}
private void btnClearOutput_Click(object sender, EventArgs e)
{
txtOutput.Text = "";
}
*/
#endregion
}
}