コード例 #1
0
        public BreweryCommands()
        {
            arduino = new ArduinoCommands(device = new LSPProtocol(new SimplePacketProtocolPacketEncoder()));
            hardwareSettings = new HardwareSettings();
            brewery = new Brewery();
            ProcessSettings = new Process.settings();

            Messenger.Default.Register<AnalogReturn>(this, "VolumeUpdate", VolumeUpdate_MessageReceived);
            Messenger.Default.Register<DigitalReturn>(this, DigitalReturn_MessageReceived);
            Messenger.Default.Register<HardwareSettings>(this, "HardwareSettingsUpdate", UpdateHardwareSettings);
            Messenger.Default.Register<Probes>(this, "TemperatureUpdate", TemperatureUpdate_MessageReceived);
            Messenger.Default.Register <bool>(this, "DesignMode", DesignMode_MessageReceived);
        }
コード例 #2
0
        private void WriteDataToArduino(ArduinoCommands command)
        {
            if (_serialPort != null && _serialPort.IsOpen)
            {
                switch (command)
                {
                case ArduinoCommands.Up:
                    _serialPort.WriteLine("100");
                    break;

                case ArduinoCommands.Down:
                    _serialPort.WriteLine("0");
                    break;

                case ArduinoCommands.Angle:
                    _serialPort.WriteLine("angle");
                    break;
                }
            }
        }
コード例 #3
0
ファイル: ArduinoSerial.cs プロジェクト: nitrotron/Brewduino
        public void SendCommand(ArduinoCommands.CommandTypes cmd, string text)
        {
            StringBuilder sendCmd = new StringBuilder();

            sendCmd.Append((int)cmd);
            if (!string.IsNullOrEmpty(text))
                sendCmd.Append("," + text + ";");
            else
                sendCmd.Append(";");

            if (sendCmd != null && !String.IsNullOrEmpty(sendCmd.ToString()))
            {
                //if (!IsOpen) Open();
                // FIXTHIS there was a problem with the serial not being open
                WriteLine(sendCmd.ToString());
            }
        }
コード例 #4
0
ファイル: ArduinoSerial.cs プロジェクト: nitrotron/Brewduino
        public Dictionary<string, string> SendCommandWithResponse(ArduinoCommands.CommandTypes cmd, string text)
        {
            //if (!IsOpen) Open();
            SendCommand(cmd, text);
            StringBuilder response = new StringBuilder();

            while (true)
            {
                try
                {
                    response.Append(ReadLine());
                }
                catch
                {
                    //Close();
                    return new Dictionary<string, string>();
                }
                if (response.ToString().Contains(";"))
                    break;

            }

            //Close();

            return parseVaribles(response.ToString());
        }
コード例 #5
0
ファイル: ArduinoSerial.cs プロジェクト: nitrotron/Brewduino
        public string SendCommandWithDebugResponse(ArduinoCommands.CommandTypes cmd, string text)
        {
            //if (!IsOpen) Open();
            SendCommand(cmd, text);
            StringBuilder response = new StringBuilder();

            while (true)
            {
                try
                {
                    response.Append(ReadLine());
                }
                catch
                {
                    //Close();
                    return string.Empty;
                }
                if (response.ToString().Contains(";"))
                    break;

            }

            return response.ToString();
        }
コード例 #6
0
ファイル: ArduinoSlam.cs プロジェクト: rickyman35/SLAMBot
 private void SendData(ArduinoCommands command, byte value)
 {
     sp.Write(new byte[] { (byte)command, value }, 0, 2);
 }