public TemperatureControlledFanForm() { InitializeComponent(); BackColor = Color.White; _serialPort = new SerialPort { BaudRate = 9600, DtrEnable = true, RtsEnable = true, DataBits = 8 }; string portId = Helpers.Helpers.AutodetectArduinoPort(); if (portId != null) { _serialPort.PortName = portId; } /*_sender = new Sender() * { * SerialPort = _serialPort * };*/ _sender = new RTOSSender() { SerialPort = _serialPort }; _mainView = new MainView(_sender) { Size = new Size(Width, Height), Location = new Point(0, 0) }; _receiver = new Receiver(_mainView, _serialPort); Controls.Add((Panel)_mainView); if (!_serialPort.IsOpen) { try { _serialPort.Open(); ((MainView)_mainView).ConnectionStatus = Constants.ConnectionStatus.Connected; } catch (Exception e) { ((MainView)_mainView).ConnectionStatus = Constants.ConnectionStatus.Disconnected; } } else { MessageBox.Show("The Serial Port is already open!"); } MainController mainController = new MainController((MainView)_mainView); }
public NebulaClient(AbstractSender <RecordedInput> inputSender, AbstractReciver <IPacket> packetReciver, InputRecorder inputRecorder) { _inputSender = inputSender; _packetReciver = packetReciver; _inputRecorder = inputRecorder; }
public MainView(AbstractSender sender) { Sender = sender; _referenceTemperaturesLabel = new Label() { Location = new Point(520, 10), Font = new Font("Arial", 15.0F), AutoSize = true, Text = "Reference temperatures:" }; Controls.Add(_referenceTemperaturesLabel); // TODO: change locations dynamically _lowTemperatureView = new TemperatureView(22) { Location = new Point(450, 35) }; Controls.Add(_lowTemperatureView); _highTemperatureView = new TemperatureView(22) { Location = new Point(650, 35) }; Controls.Add(_highTemperatureView); StartButton = new Button(); StartButton.BackColor = Color.White; StartButton.Location = new Point(570, 300); StartButton.Text = "Start"; StartButton.Size = new Size(100, 30); StartButton.FlatStyle = FlatStyle.Flat; StartButton.Click += StartButton_Click; StopButton = new Button(); StopButton.BackColor = Color.White; StopButton.Location = new Point(700, 300); StopButton.Text = "Stop"; StopButton.Size = new Size(100, 30); StopButton.FlatStyle = FlatStyle.Flat; StopButton.Enabled = false; StopButton.Click += StopButton_Click; Controls.Add(StartButton); Controls.Add(StopButton); _automaticFanSpeedRegulationLabel = new Label { Location = new Point(530, 155), AutoSize = true, Text = "Automatic fan speed regulation:", Font = new Font("Arial", 10.0F) }; Controls.Add(_automaticFanSpeedRegulationLabel); _automaticMotorSpeedCheckBox = new CheckBox() { Checked = false, Location = new Point(750, 150), FlatStyle = FlatStyle.Flat, Size = new Size(30, 30) }; _automaticMotorSpeedCheckBox.CheckedChanged += AutomaticMotorSpeedCheckBox_CheckedChanged; Controls.Add(_automaticMotorSpeedCheckBox); _fanSpeedLabel = new Label() { Location = new Point(490, 200), Font = new Font("Arial", 15.0F), AutoSize = true, Text = "Fan speed:" }; Controls.Add(_fanSpeedLabel); MotorSpeedTrackBar = new TrackBar { Minimum = 0, Maximum = 100, Value = 20, SmallChange = 0, LargeChange = 20, TickFrequency = 20, Size = new Size(270, 40), TickStyle = TickStyle.Both, Location = new Point(480, 230), }; MotorSpeedTrackBar.ValueChanged += MotorSpeedTrackBar_ValueChanged; MotorSpeedTrackBar.MouseWheel += MotorSpeedTrackBar_MouseWheel; MotorSpeedTrackBar.MouseUp += MotorSpeedTrackBar_MouseUp; Controls.Add(MotorSpeedTrackBar); MotorSpeedLabel = new Label() { AutoSize = true, Location = new Point(750, 230), ForeColor = System.Drawing.Color.Black, Text = MotorSpeedTrackBar.Value.ToString() + "%", Font = new Font("Arial", 20.0F) }; Controls.Add(MotorSpeedLabel); ChartView = new ChartView() { Location = new Point(10, 10), Size = new Size(400, 300) }; Controls.Add(ChartView); _lowTemperatureController = new TemperatureController(_lowTemperatureView); _highTemperatureController = new TemperatureController(_highTemperatureView); _connectionStatusTimer = new Timer { Interval = 500, Enabled = true }; _connectionStatusTimer.Tick += ConnectionStatusTimer_Tick; _connectionStatusPanel = new Panel { Location = new Point(810, 358), Size = new Size(20, 20) }; Controls.Add(_connectionStatusPanel); }
public void Setup() { _sender = Substitute.For <AbstractSender <IPacket> >(Substitute.For <ISendTransmissionProtocol>(), Substitute.For <IPacketSerializer <IPacket> >()); _reciver = Substitute.For <AbstractReciver <RecordedInput> >(Substitute.For <IReciveTransmissionProtocol>(), Substitute.For <IPacketDeserializer <RecordedInput> >()); _server = new NebulaServer(_sender, _reciver); }
public NebulaServer(AbstractSender <IPacket> packetSender, AbstractReciver <RecordedInput> inputReciver) { _packetSender = packetSender; _inputReciver = inputReciver; }