using System;
using System.Threading;
namespace AxsunOCTControl_LW_ExampleConsoleApp_DotNet
{
public class Axsun {
public AOCLW cntrl = new AOCLW(false);
public void PrintConnectedDevices()
{
var count = cntrl.
GetNumberOfOCTDevicesPresent();
Console.WriteLine("Connected device count: " + count.ToString());
for (uint i = 0; i < count; ++i)
{
try
{
var system_type = cntrl.
GetSystemType(i);
Console.Write(system_type.ToString() +
" (" + cntrl.
GetConnectionType(i).ToString() +
")\tFW: v" + cntrl.
GetFirmwareVersion(i) +
"\tSN: " + cntrl.
GetSerialNum(i));
if (system_type == AOCLW.AxDeviceType.EDAQ || system_type == AOCLW.AxDeviceType.AZMYTH_LASER)
Console.Write(
"\t FPGA: v" + cntrl.
GetFPGAVersion(i));
Console.WriteLine();
}
catch (AOCLW.AxException ex)
{
Console.WriteLine("Error in connect callback: " + ex.msg_ + " (" + ex.err_.ToString() + ")");
}
}
Console.WriteLine();
}
}
class AxsunOCTControl_LW_ExampleConsoleApp
{
static void Main(string[] args)
{
try
{
Axsun axsun = new Axsun();
Console.WriteLine("Using AxsunOCTControl_LW.dll v" + axsun.cntrl.GetControlVersion());
Console.WriteLine("Registering connect/disconnect callback function...");
axsun.cntrl.OCTDeviceConnectOrDisconnectEvent += new AOCLW.OCTDeviceConnectOrDisconnectHandler(axsun.PrintConnectedDevices);
Console.WriteLine("Starting USB interface...");
axsun.cntrl.StartUSBControlInterface();
Console.WriteLine("Starting network interface...");
axsun.cntrl.StartNetworkControlInterface();
var running = true;
while (running)
{
Console.Write("Type a character and press enter to execute a command ('?' for command list).\n >> ");
var which_command = Console.ReadLine();
try {
switch (which_command)
{
case "?":
Console.WriteLine("\n***** COMMAND LIST *****");
Console.WriteLine("D\tLASER: StopScan(...); // Disable Laser Emission");
Console.WriteLine("E\tLASER: StartScan(...); // Enable Laser Emission");
Console.WriteLine("0\tLASER: SwitchConfiguration(0); // Set Laser Drive Config 0");
Console.WriteLine("1\tLASER: SwitchConfiguration(1); // Set Laser Drive Config 1");
Console.WriteLine("G\tLASER: GetConfiguration(...); // Get Laser Drive Config");
Console.WriteLine("R\tLASER: GetLaserErrors(...); // Get Laser Error States");
Console.WriteLine("\nI\tGet info on connected devices.");
Console.WriteLine("?\tList command options.");
Console.WriteLine("Q\tQuit this program.\n");
break;
case "I":
case "i":
axsun.PrintConnectedDevices();
break;
case "d":
case "D":
Console.WriteLine("StopScan() ... disable laser emission.");
axsun.cntrl.StopScan(0);
break;
case "E":
case "e":
Console.WriteLine("StartScan() ... enable laser emission.");
axsun.cntrl.StartScan(0);
break;
case "0":
Console.WriteLine("SwitchConfiguration() to config 0.");
axsun.cntrl.SwitchConfiguration(0, 0);
break;
case "1":
Console.WriteLine("SwitchConfiguration() to config 1.");
axsun.cntrl.SwitchConfiguration(1, 0);
break;
case "g":
case "G":
Console.WriteLine("Current configuration is: " + axsun.cntrl.GetConfiguration(0).ToString());
break;
case "r":
case "R":
Console.WriteLine("Current error state is: " + axsun.cntrl.GetLaserErrors(0).ToString());
break;
case "q":
case "Q":
Console.WriteLine("Quitting...");
running = false;
break;
default:
Console.WriteLine("Command not recognized. Enter '?' to list options.");
break;
}
}
catch (AOCLW.AxException ex)
{
Console.WriteLine("Error: " + ex.msg_ + " (" + ex.err_.ToString() + ")");
}
}
}
catch (AOCLW.AxException ex)
{
Console.WriteLine("Error in AxsunOCTControl_LW setup phase: " + ex.msg_ + " (" + ex.err_.ToString() + ")");
Console.WriteLine("Quitting...");
}
Thread.Sleep(1000);
}
}
}