Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
90 | gunterl | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.ComponentModel; |
||
4 | using System.Data; |
||
5 | using System.Drawing; |
||
6 | using System.Text; |
||
7 | using System.Windows.Forms; |
||
8 | using winforms = System.Windows.Forms; |
||
9 | using Microsoft.Ccr.Core; |
||
10 | using Microsoft.Dss.ServiceModel.Dssp; |
||
11 | |||
12 | |||
13 | namespace Robotics.RoboBoard |
||
14 | { |
||
15 | partial class RoboBoardForm : Form |
||
16 | { |
||
17 | RoboBoardEvents _eventsPort; |
||
18 | |||
19 | enum PanelState { Idle, GPS, MKSensor, ExtenderBoard, RawData, Control }; |
||
20 | public Int16[] MK_analog = new Int16[32]; |
||
21 | public string[] Mk_analog_name = new string[32]; |
||
22 | public Int16 Control_alt; |
||
23 | public Int16 Control_roll; |
||
24 | public Int16 Control_nick; |
||
25 | public Int16 Control_gier; |
||
26 | public Int16 Control_gas; |
||
27 | |||
28 | |||
29 | int panelstate = (int)PanelState.Idle; |
||
30 | |||
31 | public RoboBoardForm(RoboBoardEvents EventsPort) |
||
32 | |||
33 | { |
||
34 | _eventsPort = EventsPort; |
||
35 | InitializeComponent(); |
||
36 | // UpdateStatus("<unknown>"); |
||
37 | } |
||
38 | |||
39 | public void UpdateStatus(string Status) { |
||
40 | toolStripStatusLabel1.Text = Status; |
||
41 | } |
||
42 | |||
43 | /// <summary> |
||
44 | /// posts the instace of the form to the main process |
||
45 | /// </summary> |
||
46 | /// <param name="sender"></param> |
||
47 | /// <param name="e"></param> |
||
48 | private void RoboBoardForm_Load(object sender, EventArgs e) |
||
49 | { |
||
50 | _eventsPort.Post(new OnLoad(this)); |
||
51 | } |
||
52 | |||
53 | /// <summary> |
||
54 | /// Invalidate the Panel area and trigger a repaint |
||
55 | /// </summary> |
||
56 | /// <param name="Command"></param> |
||
57 | public void MonitorCommand(string Command) |
||
58 | { |
||
59 | MainPanel.Invalidate(); |
||
60 | } |
||
61 | |||
62 | /// <summary> |
||
63 | /// update data value |
||
64 | /// </summary> |
||
65 | /// <param name="index"></param> |
||
66 | /// <param name="value"></param> |
||
67 | /// <param name="name"></param> |
||
68 | public void MonitorMKSensor(int index, Int16 value, string name) |
||
69 | { |
||
70 | if (index > 31) return; |
||
71 | MK_analog[index] = value; |
||
72 | if (name == "") return; |
||
73 | Mk_analog_name[index] = name; |
||
74 | } |
||
75 | |||
76 | public void MonitorMKSensorUpdate() |
||
77 | { |
||
78 | MainPanel.Invalidate(); |
||
79 | } |
||
80 | |||
81 | /// <summary> |
||
82 | /// |
||
83 | /// </summary> |
||
84 | /// <param name="sender"></param> |
||
85 | /// <param name="e"></param> |
||
86 | private void MainPanel_Paint(object sender, PaintEventArgs e) |
||
87 | { |
||
88 | int i; |
||
89 | Graphics dc = e.Graphics; |
||
90 | |||
91 | Font stdFont = new Font("Arial", 10); |
||
92 | SolidBrush stdBrush = new SolidBrush(Color.Green); |
||
93 | Font sensorFont = new Font("Arial", 8); |
||
94 | SolidBrush sensorBrush = new SolidBrush(Color.Black); |
||
95 | |||
96 | switch (panelstate) |
||
97 | { |
||
98 | case (int)PanelState.Control: |
||
99 | dc.DrawString("Control Data Monitor", stdFont, stdBrush, 2, 2); |
||
100 | dc.DrawString("Nick", sensorFont, sensorBrush, 10, 14); |
||
101 | dc.DrawString(Control_nick.ToString(), sensorFont, sensorBrush, 200, 14); |
||
102 | dc.DrawString("Roll", sensorFont, sensorBrush, 10, 24); |
||
103 | dc.DrawString(Control_roll.ToString(), sensorFont, sensorBrush, 200, 24); |
||
104 | dc.DrawString("Gier", sensorFont, sensorBrush, 10, 34); |
||
105 | dc.DrawString(Control_gier.ToString(), sensorFont, sensorBrush, 200, 34); |
||
106 | dc.DrawString("Gas", sensorFont, sensorBrush, 10, 44); |
||
107 | dc.DrawString(Control_gas.ToString(), sensorFont, sensorBrush, 200, 44); |
||
108 | dc.DrawString("Altitute", sensorFont, sensorBrush, 10, 54); |
||
109 | dc.DrawString(Control_alt.ToString(), sensorFont, sensorBrush, 200, 54); |
||
110 | break; |
||
111 | case (int)PanelState.RawData: |
||
112 | dc.DrawString("Raw Data", stdFont, stdBrush, 2, 2); |
||
113 | break; |
||
114 | case (int)PanelState.ExtenderBoard: |
||
115 | dc.DrawString("Extender Board Data", stdFont, stdBrush, 2, 2); |
||
116 | break; |
||
117 | case (int)PanelState.GPS: |
||
118 | dc.DrawString("GPS Data", stdFont, stdBrush, 10, 10); |
||
119 | break; |
||
120 | case (int)PanelState.MKSensor: |
||
121 | dc.DrawString("Mikrokopter Sensors", stdFont, stdBrush, 2, 2); |
||
122 | for (i = 0; i < 32; i++) |
||
123 | { |
||
124 | if (Mk_analog_name[i] == null) |
||
125 | { |
||
126 | dc.DrawString("<unknown>", sensorFont, sensorBrush, 10, (float)(14 + (i * 10))); |
||
127 | } |
||
128 | else |
||
129 | { |
||
130 | dc.DrawString(Mk_analog_name[i], sensorFont, sensorBrush, 10, (float)(14 + (i * 10))); |
||
131 | } |
||
132 | dc.DrawString(MK_analog[i].ToString(), sensorFont, sensorBrush, 200, (float)(14 + (i * 10))); |
||
133 | } |
||
134 | break; |
||
135 | case (int)PanelState.Idle: |
||
136 | dc.DrawString("Select Mode (no mode selected)", stdFont, stdBrush, 2, 2); |
||
137 | break; |
||
138 | default: |
||
139 | dc.DrawString("Select Mode", stdFont, stdBrush, 2, 2); |
||
140 | break; |
||
141 | } |
||
142 | } |
||
143 | |||
144 | private void toolStripButton1_Click(object sender, EventArgs e) |
||
145 | { |
||
146 | panelstate = (int)PanelState.GPS; |
||
147 | MainPanel.Invalidate(); |
||
148 | } |
||
149 | |||
150 | private void toolStripButton2_Click(object sender, EventArgs e) |
||
151 | { |
||
152 | panelstate = (int)PanelState.MKSensor; |
||
153 | MainPanel.Invalidate(); |
||
154 | } |
||
155 | |||
156 | private void toolStripButton3_Click(object sender, EventArgs e) |
||
157 | { |
||
158 | panelstate = (int)PanelState.Control; |
||
159 | MainPanel.Invalidate(); |
||
160 | } |
||
161 | |||
162 | } |
||
163 | |||
164 | class RoboBoardEvents:PortSet <OnLoad,OnClosed> |
||
165 | { |
||
166 | } |
||
167 | |||
168 | class RoboBoardEvent |
||
169 | { |
||
170 | private RoboBoardForm _rbForm; |
||
171 | |||
172 | public RoboBoardForm RoboBoardForm |
||
173 | { |
||
174 | get { return _rbForm; } |
||
175 | set { _rbForm = value; } |
||
176 | } |
||
177 | |||
178 | public RoboBoardEvent(RoboBoardForm rbForm) |
||
179 | { |
||
180 | _rbForm = rbForm; |
||
181 | } |
||
182 | } |
||
183 | |||
184 | class OnLoad : RoboBoardEvent |
||
185 | { |
||
186 | public OnLoad(RoboBoardForm form) |
||
187 | : base(form) |
||
188 | { |
||
189 | } |
||
190 | } |
||
191 | |||
192 | class OnClosed : RoboBoardEvent |
||
193 | { |
||
194 | public OnClosed(RoboBoardForm form) |
||
195 | : base(form) |
||
196 | { |
||
197 | } |
||
198 | } |
||
199 | |||
200 | } |