public static void Main(string[] args) { // Initialize Logger to dump traces to log file. Logger.init(); // First check whether there are enought input arguments to start the app. if (Instructions.CheckInputArgs(args.Length) == true) { // Display necessary instructions to use the sensor. Instructions.Display(); // Create an object of the sensor library by providing ip address and port number. string ipAddress = args[0]; string portNumber = args[1]; SensorAPI sensorAPI = new SensorAPI(ipAddress, portNumber); if (sensorAPI != null) { // Listen to the events and callbacks from lib SensorEvents events = new SensorEvents(ref sensorAPI); // Execute different commands based on user input. string commandVal = Command.INVALID; while (commandVal != Command.QUIT) { var command = SensorCommandParse.Parse(Console.ReadLine()); commandVal = command.Execute(ref sensorAPI); } } // Destroy sensor library object. sensorAPI = null; } }
public string Execute(ref SensorAPI sensorAPI) { Console.WriteLine("Quitting the app"); Logger.Log("Quitting the app"); return(Command.QUIT); }
public string Execute(ref SensorAPI sensorAPI) { Logger.Log("Stop scanning frames"); var result = sensorAPI.StopScanning(); return(Command.STOP_SCAN); }
public string Execute(ref SensorAPI sensorAPI) { Console.WriteLine("Invaild command, Please recheck"); Logger.Log("Invaild command, Please recheck"); Instructions.Display(); return(Command.INVALID); }
public string Execute(ref SensorAPI sensorAPI) { Console.WriteLine("Failure in sensor, try to reconnect"); Logger.Log("Failure in sensor, try to reconnect"); var result = sensorAPI.Failure(); return(Command.FAILURE); }
public string Execute(ref SensorAPI sensorAPI) { SensorCallback sensorCallback = new SensorCallback(); Logger.Log("Start scanning frames"); var result = sensorAPI.StartScanning(sensorCallback.callback); sensorCallback = null; return(Command.START_SCAN); }
public string Execute(ref SensorAPI sensorAPI) { SensorSettings settings = sensorAPI.OutputSettings(); if (settings != null) { Console.WriteLine("Get sensor settings"); Console.WriteLine("frames : {0}, scan mode : {1}", settings.numFrames, settings.scanMode); Logger.Log("Sensor output settings", settings.numFrames.ToString(), settings.scanMode); } else { Console.WriteLine("No Connection to the sensor"); Logger.Log("No Connection to the sensor"); } return(Command.OUTPUT_SETTINGS); }
public string Execute(ref SensorAPI sensorAPI) { SensorStatus status = sensorAPI.ReportStatus(); if (status != null) { Console.WriteLine("Sensor status"); Console.WriteLine("status code : {0}, status description : {1}", status.statusCode, status.statusText); Logger.Log("Sensor status :", status.statusCode.ToString(), status.statusText); } else { Console.WriteLine("No Connection to the sensor"); Logger.Log("No Connection to the sensor"); } return(Command.REPORT_STATUS); }
public string Execute(ref SensorAPI sensorAPI) { SensorSettings settings = new SensorSettings(2, "slow"); int result = sensorAPI.InputSettings(settings); if (result == 0) { Console.WriteLine("Set sensor settings:"); Console.WriteLine("frames : {0}, scan mode : {1}", settings.numFrames, settings.scanMode); Logger.Log("Sensor output settings", settings.numFrames.ToString(), settings.scanMode); } else { Console.WriteLine("No Connection to the sensor"); Logger.Log("No Connection to the sensor"); } return(Command.INPUT_SETTINGS); }
public string Execute(ref SensorAPI sensorAPI) { Console.WriteLine("Connecting to the sensor"); Logger.Log("Connecting to the sensor"); int result = sensorAPI.Connect(); if (result == 0) { Console.WriteLine("Connected the sensor"); Logger.Log("Connected to the sensor"); } else { Console.WriteLine("Not able to connect to the sensor"); Logger.Log("Not able to connect to the sensor"); } return(Command.CONNECT); }
public SensorCommandParseUT() { m_sensorAPI = new SensorAPI("", ""); }
public SensorEvents(ref SensorAPI sensorAPI) { sensorAPI.ScanStarted += SensorAPI_ScanStarted; sensorAPI.ScanEnded += SensorAPI_ScanEnded; }