Exemple #1
0
 public TCPListener(ITankBotLogger logger, IServer server, int port)
 {
     _server = server;
     _logger = logger;
     _port   = port;
     _logger.NotifyUserInfo("TCPIP Listener", $"Created Listener");
 }
Exemple #2
0
        public ChannelWatcherBase(ITankBotLogger logger)
        {
            _logger = logger;

            StartWatcherCommand        = RelayCommand.Create(StartWatcher);
            StopWatcherCommand         = RelayCommand.Create(StopWatcher);
            StopWatcherCommand.Enabled = false;
        }
 public MainViewModel(ITankBotLogger logger)
 {
     _logger            = logger;
     _availableChannels = new ObservableCollection <IChannel>();
     _channelWatchers   = new ObservableCollection <IChannelWatcher>();
     //       _connectedDevices = new ObservableCollection<ISoccerBotCommands>();
     StartWatchersCommand = new RelayCommand(StartWatchers);
     StopWatchersCommand  = new RelayCommand(StopWatchers);
 }
        public BluetoothChannel(DeviceInformation deviceInfo, ITankBotLogger logger)
        {
            _logger     = logger;
            _deviceInfo = deviceInfo;
            Id          = _deviceInfo.Id;
            DeviceName  = _deviceInfo.Name;

            State = States.Disconnected;
            _logger.NotifyUserInfo("BT Channel", "Created");
        }
Exemple #5
0
        public TCPIPChannel(uPnPDevice device, ITankBotLogger logger)
        {
            _remoteDevice = device;
            DeviceName    = device.FriendlyName;
            Id            = device.UDN + " " + device.IPAddress;
            _logger       = logger;
            _logger.NotifyUserInfo("TCPIP Channel", $"Created Device for: {DeviceName}");

            _parser = new MessageParser();
            _parser.MessageReady += _parser_MessageReady;
        }
Exemple #6
0
        private async void InitSockerBot()
        {
            var hostNames    = NetworkInformation.GetHostNames();
            var computerName = hostNames.FirstOrDefault(name => name.Type == HostNameType.DomainName)?.DisplayName ?? "???";



            var pin = await LagoVista.Core.PlatformSupport.Services.Storage.GetKVPAsync <string>("PIN");

            if (String.IsNullOrEmpty(pin))
            {
                var rnd = new Random();
                pin = rnd.Next(1000, 9999).ToString();
                await LagoVista.Core.PlatformSupport.Services.Storage.StoreKVP("PIN", pin);
            }

            Debug.WriteLine("========================================");
            Debug.WriteLine("NOTE: NOTE: NOTE: Your PIN is: " + pin);
            Debug.WriteLine("========================================");

            _logger = new Loggers.DebugLogger();

            switch (AnalyticsInfo.VersionInfo.DeviceFamily)
            {
            case "Windows.IoT":
                var ports = (await LagoVista.Core.PlatformSupport.Services.DeviceManager.GetSerialPortsAsync());
                if (ports.Count == 0)
                {
                    throw new Exception("Could not find any serial ports, a serial port is required.");
                }
                else if (ports.Count > 1)
                {
                    throw new Exception("Found more than one serial port, please add additional logic to select the serial port the mBot is connected to.");
                }

                var serialPortChannel = new SerialPortChannel(ports.First().Id, _logger);
                await serialPortChannel.ConnectAsync();

                _tankBot       = new mBlockTankBot(serialPortChannel, _logger, pin);
                _sensorManager = new SensorManager();
                await _sensorManager.InitAsync();

                _sensorManager.Start();

                break;

            case "Windows.Desktop":
                _tankBot = new SimulatedSoccerBot();

                break;
            }

            ConnectionManager.Start(computerName, _tankBot, _logger, _sensorManager, Constants.WebListenerPort, Constants.TCPListenPort, Constants.UPNPListenPort);
        }
Exemple #7
0
        public Server(ITankBotLogger logger, int port, ITankBot soccerBot, ISensorManager sensorManager)
        {
            _port    = port;
            _logger  = logger;
            _tankBot = soccerBot;

            _sensorManager = sensorManager;

            _clients = new ConcurrentDictionary <string, IClient>();

            _watchDog          = new System.Threading.Timer(_watchDog_Tick, null, 0, 2500);
            _sensorUpdateTimer = new System.Threading.Timer(_sensorUpdateTimer_Tick, null, 0, 100);
        }
Exemple #8
0
        public mBlockSoccerBot(IChannel channel, ITankBotLogger logger, string pin = "9999") : this()
        {
            _pin     = pin;
            _logger  = logger;
            _channel = channel;
            _channel.MessageReceived += _channel_MessageReceived;
            Name = "mSoccerBot";

            _timer = new Timer((state) => { RequestVersion(); }, null, 0, 5000);

            ModeACommand          = RelayCommand.Create(SendModeA);
            ModeBCommand          = RelayCommand.Create(SendModeB);
            ModeCCommand          = RelayCommand.Create(SendModeC);
            SendLEDMessageCommand = RelayCommand.Create(SendLEDMessage);

            _start = DateTime.Now;
        }
Exemple #9
0
        private Client(StreamSocket socket, ITankBotLogger logger)
        {
            _id = Guid.NewGuid().ToString();

            _socket = socket;
            _logger = logger;
            _parser = new MessageParser();
            _parser.MessageReady += _parser_MessageReady;

            _inputStream = socket.InputStream.AsStreamForRead();
            _reader      = new StreamReader(_inputStream);

            _outputStream = socket.OutputStream.AsStreamForWrite();
            _writer       = new StreamWriter(_outputStream);

            _lastMessageDateStamp = DateTime.Now;

            _readBuffer = new char[MAX_BUFFER_SIZE];
        }
Exemple #10
0
        public void Start(String tankBotName, ITankBot tankBot, ITankBotLogger logger, ISensorManager sensorManager, int webServerPort, int tcpListenerPort, int uPnPListenerPort)
        {
            _logger           = logger;
            _tankBotName      = tankBotName;
            _tankBot          = tankBot;
            _sensorManager    = sensorManager;
            _webServerPort    = webServerPort;
            _tcpListenerPort  = tcpListenerPort;
            _uPnPListenerPort = uPnPListenerPort;

            var networkInfo = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

            App.TheApp.HasInternetConnection = networkInfo.GetNetworkConnectivityLevel() == Windows.Networking.Connectivity.NetworkConnectivityLevel.InternetAccess;

            if (App.TheApp.HasInternetConnection)
            {
                MakeDiscoverable(tankBotName);
                StartWebServer(_webServerPort, _tankBotName);
                StartTCPServer(_tcpListenerPort, _tankBot, _sensorManager);
            }
        }
 public MotionController(IConnectionManager connectionManager, ITankBotLogger logger)
 {
     _connectionManager = connectionManager;
     _logger            = logger;
 }
Exemple #12
0
 public static IClient Create(StreamSocket socket, ITankBotLogger logger)
 {
     return(new Client(socket, logger));
 }
 public BluetoothChannelWatcher(ITankBotLogger logger) : base(logger)
 {
     _logger = logger;
 }
 public LocalClientTankBotViewModel(IChannel channel, ITankBotLogger logger, IJoyStick joyStick) : base(joyStick)
 {
     _channel       = channel;
     _mblockTankBot = new mBlockTankBot(channel, logger);
     _logger        = logger;
 }
Exemple #15
0
 public FakeWatcher(ITankBotLogger logger) : base(logger)
 {
     _timer = new Timer(Tick, null, 0, 2500);
 }
 public UPNPChannelWatcher(ITankBotLogger logger) : base(logger)
 {
     _logger = logger;
 }
Exemple #17
0
 public MotionRestAPI(ITankBot tankBot, ITankBotLogger logger)
 {
     _tankBot = tankBot;
     _logger  = logger;
 }
Exemple #18
0
 public SerialPortChannel(ISerialPort port, ITankBotLogger logger)
 {
     _port   = port;
     _logger = logger;
 }
 public SerialPortChannel(string serialPortId, ITankBotLogger logger)
 {
     _serialPortId = serialPortId;
     _logger       = logger;
 }
 public ChannelWatcherBase(ITankBotLogger logger)
 {
     _logger = logger;
 }