123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using ANT_Managed_Library;
- namespace ANTFS_Demo
- {
- class Demo
- {
-
-
- public readonly static byte SearchRF = (byte)ANT_Managed_Library.ANTFS.RadioFrequency.ANTFSNetwork;
- public readonly static ushort ChannelPeriod = 8192;
- public readonly static byte DeviceType = 1;
- public readonly static byte TransmissionType = 5;
- public readonly static byte NetworkNumber = 0;
- public readonly static byte[] NetworkKey = { 0xA8, 0xA4, 0x23, 0xB9, 0xF5, 0x5E, 0x63, 0xC1 };
-
-
- public readonly static ushort ClientManufacturerID = 2;
- public readonly static ushort ClientDeviceType = 416;
- public readonly static ANT_Managed_Library.ANTFS.BeaconPeriod LinkPeriod = ANT_Managed_Library.ANTFS.BeaconPeriod.FourHz;
-
-
- public readonly static string[] CursorStrings = { "|", "/", "_", "\\" };
- public static readonly bool AntfsBroadcast = false;
- static ANT_Device device0;
- static byte selection = Byte.MaxValue;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- static void Main(string[] args)
- {
- if (args.Length > 0)
- {
- selection = byte.Parse(args[0]);
- }
- try
- {
- Init();
- Start(selection);
- }
- catch (Exception ex)
- {
- Console.WriteLine("Demo failed with exception: \n" + ex.Message);
- }
- }
-
-
-
- static void Init()
- {
- try
- {
- Console.WriteLine("Attempting to connect to an ANT USB device...");
- ANT_Common.enableDebugLogs();
- device0 = new ANT_Device();
- Console.WriteLine("Initialization was successful!");
- }
- catch (Exception ex)
- {
- if (device0 == null)
- {
- throw new Exception("Could not connect to any device.\n" +
- "Details: \n " + ex.Message);
- }
- else
- {
- throw new Exception("Error connecting to ANT: " + ex.Message);
- }
- }
- }
-
-
-
-
- static void Start(byte userSelection)
- {
- selection = userSelection;
-
- do
- {
- if (selection == Byte.MaxValue)
- {
- Console.WriteLine("Please select (Host = 0, Client = 1)");
- try
- {
- selection = byte.Parse(Console.ReadLine());
- if (selection != 0 && selection != 1)
- throw new FormatException("Error: Invalid selection");
- }
- catch (Exception)
- {
- selection = Byte.MaxValue;
- }
- }
- } while (selection == Byte.MaxValue);
- if (selection == 0)
- {
- HostDemo theDemo = new HostDemo();
- theDemo.Start(device0);
- }
- else if (selection == 1)
- {
- ClientDemo theDemo = new ClientDemo();
- theDemo.Start(device0);
- }
- }
-
-
-
-
-
- public static ushort ParseInput(string selection)
- {
- try
- {
- return UInt16.Parse(selection);
- }
- catch (Exception ex)
- {
- throw new System.ArgumentException("Invalid input", ex);
- }
- }
- }
- }
|