-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
65 lines (52 loc) · 2.1 KB
/
Main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Piealytics
{
public partial class MainWindow : Form
{
private DataRenderer dataRenderer;
private DataManager dataManager;
private NetworkManager networkManager;
// constructor
public MainWindow()
{
// init window
InitializeComponent();
// create managers
dataRenderer = new DataRenderer(chartFrame);
networkManager = new NetworkManager(15000);
dataManager = new DataManager(dataRenderer);
// start tasks
Run();
}
private async void Run()
{
// search raspberry in local network and remember its IP
var connectionProperties = await networkManager.SearchClientAsync();
statusBar_statusLabel.Text = "Status: Verbunden mit " + connectionProperties.EndPoint.Address;
statusBar_frequency.Text = "Frequenz: " + connectionProperties.Frequency + "Hz";
statusBar_range.Text = "Wertebereich: " + connectionProperties.Range.Item1 + " - " + connectionProperties.Range.Item2;
// set connection properties on data manager and renderer
dataRenderer.SetRange( connectionProperties.Range );
dataManager.SetConnectionProperties(connectionProperties);
dataManager.SetHistoryLength(decimal.ToInt32(input_historyLength.Value));
// start listening for incoming data and assign the datamanager to it
networkManager.StartListenerAsync(dataManager.HandleData);
// render the axes
dataRenderer.DrawGrid();
dataRenderer.InvalidateCanvas();
}
private void Input_historyLength_ValueChanged(object sender, EventArgs e)
{
dataManager.SetHistoryLength(decimal.ToInt32(input_historyLength.Value));
dataRenderer.InvalidateCanvas();
}
}
}