Quellcode durchsuchen

finale Verbesserungen

develop
Flo Smilari vor 2 Jahren
Ursprung
Commit
2004615bc0
4 geänderte Dateien mit 140 neuen und 88 gelöschten Zeilen
  1. BIN
      .vs/FSRemotePowerSwitch/v16/.suo
  2. 76
    75
      Form1.Designer.cs
  3. 60
    13
      Form1.cs
  4. 4
    0
      Message.cs

BIN
.vs/FSRemotePowerSwitch/v16/.suo Datei anzeigen


+ 76
- 75
Form1.Designer.cs Datei anzeigen

@@ -45,7 +45,6 @@ namespace FSRemotePowerSwitch {
this.fwVersionLbl = new System.Windows.Forms.ToolStripStatusLabel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.powerStateLed = new System.Windows.Forms.PictureBox();
this.webCamRotator = new KnobControl.KnobControl();
this.rotatorActValue = new System.Windows.Forms.Label();
this.webCamRotatorLbl = new System.Windows.Forms.Label();
this.webCamRotPowerLbl = new System.Windows.Forms.Label();
@@ -55,12 +54,13 @@ namespace FSRemotePowerSwitch {
this.webCamRotatorPowerOnLbl = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.webCamRotatorPowerSwitch = new FSRemotePowerSwitch.SButton();
this.powerSwitchButton = new FSRemotePowerSwitch.SButton();
this.webCamRotVelocityLbl = new System.Windows.Forms.Label();
this.webCamRotatorVelocitySwitch = new FSRemotePowerSwitch.SButton();
this.webCamRotatorVelocitySlowLbl = new System.Windows.Forms.Label();
this.webCamRotatorVelocityFastLbl = new System.Windows.Forms.Label();
this.webCamRotator = new KnobControl.KnobControl();
this.webCamRotatorVelocitySwitch = new FSRemotePowerSwitch.SButton();
this.webCamRotatorPowerSwitch = new FSRemotePowerSwitch.SButton();
this.powerSwitchButton = new FSRemotePowerSwitch.SButton();
this.statusBar.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.powerStateLed)).BeginInit();
@@ -157,7 +157,7 @@ namespace FSRemotePowerSwitch {
//
// statusTimer
//
this.statusTimer.Interval = 5000;
this.statusTimer.Interval = 10000;
this.statusTimer.Tick += new System.EventHandler(this.onStatusTimerTick);
//
// statusBar
@@ -257,34 +257,6 @@ namespace FSRemotePowerSwitch {
this.powerStateLed.TabIndex = 12;
this.powerStateLed.TabStop = false;
//
// webCamRotator
//
this.webCamRotator.EndAngle = 420F;
this.webCamRotator.ForeColor = System.Drawing.Color.AliceBlue;
this.webCamRotator.ImeMode = System.Windows.Forms.ImeMode.On;
this.webCamRotator.KnobBackColor = System.Drawing.Color.Silver;
this.webCamRotator.KnobPointerStyle = KnobControl.KnobControl.KnobPointerStyles.circle;
this.webCamRotator.LargeChange = 5;
this.webCamRotator.Location = new System.Drawing.Point(234, 133);
this.webCamRotator.Maximum = 180;
this.webCamRotator.Minimum = -180;
this.webCamRotator.Name = "webCamRotator";
this.webCamRotator.PointerColor = System.Drawing.SystemColors.HotTrack;
this.webCamRotator.ScaleColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.webCamRotator.ScaleDivisions = 13;
this.webCamRotator.ScaleFont = new System.Drawing.Font("Bahnschrift SemiLight SemiConde", 9F);
this.webCamRotator.ScaleFontAutoSize = false;
this.webCamRotator.ScaleSubDivisions = 2;
this.webCamRotator.ShowLargeScale = true;
this.webCamRotator.ShowSmallScale = true;
this.webCamRotator.Size = new System.Drawing.Size(165, 165);
this.webCamRotator.SmallChange = 1;
this.webCamRotator.StartAngle = 120F;
this.webCamRotator.TabIndex = 17;
this.webCamRotator.Value = 0;
this.webCamRotator.ValueChanged += new KnobControl.ValueChangedEventHandler(this.onWebCamRotatorValueChanged);
this.webCamRotator.MiddleAreaClicked += new KnobControl.MiddleAreaMouseClickEventHandler(this.onWebCamRotatorMiddleAreaClicked);
//
// rotatorActValue
//
this.rotatorActValue.BackColor = System.Drawing.Color.Black;
@@ -302,7 +274,7 @@ namespace FSRemotePowerSwitch {
this.webCamRotatorLbl.AutoSize = true;
this.webCamRotatorLbl.Font = new System.Drawing.Font("Bahnschrift SemiBold SemiConden", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.webCamRotatorLbl.ForeColor = System.Drawing.SystemColors.HotTrack;
this.webCamRotatorLbl.Location = new System.Drawing.Point(248, 96);
this.webCamRotatorLbl.Location = new System.Drawing.Point(243, 96);
this.webCamRotatorLbl.Name = "webCamRotatorLbl";
this.webCamRotatorLbl.Size = new System.Drawing.Size(137, 19);
this.webCamRotatorLbl.TabIndex = 19;
@@ -384,34 +356,6 @@ namespace FSRemotePowerSwitch {
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.onSetWebCamZero);
//
// webCamRotatorPowerSwitch
//
this.webCamRotatorPowerSwitch.Location = new System.Drawing.Point(434, 278);
this.webCamRotatorPowerSwitch.MinimumSize = new System.Drawing.Size(45, 22);
this.webCamRotatorPowerSwitch.Name = "webCamRotatorPowerSwitch";
this.webCamRotatorPowerSwitch.OffBackColor = System.Drawing.Color.Gray;
this.webCamRotatorPowerSwitch.OffToggleColor = System.Drawing.Color.Gainsboro;
this.webCamRotatorPowerSwitch.OnBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.webCamRotatorPowerSwitch.OnToggleColor = System.Drawing.Color.WhiteSmoke;
this.webCamRotatorPowerSwitch.Size = new System.Drawing.Size(45, 22);
this.webCamRotatorPowerSwitch.TabIndex = 25;
this.webCamRotatorPowerSwitch.UseVisualStyleBackColor = true;
this.webCamRotatorPowerSwitch.CheckStateChanged += new System.EventHandler(this.onWebCamPowerSwitchCheckStateChanged);
//
// powerSwitchButton
//
this.powerSwitchButton.Location = new System.Drawing.Point(72, 135);
this.powerSwitchButton.MinimumSize = new System.Drawing.Size(45, 22);
this.powerSwitchButton.Name = "powerSwitchButton";
this.powerSwitchButton.OffBackColor = System.Drawing.Color.Gray;
this.powerSwitchButton.OffToggleColor = System.Drawing.Color.Gainsboro;
this.powerSwitchButton.OnBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.powerSwitchButton.OnToggleColor = System.Drawing.Color.WhiteSmoke;
this.powerSwitchButton.Size = new System.Drawing.Size(80, 40);
this.powerSwitchButton.TabIndex = 16;
this.powerSwitchButton.UseVisualStyleBackColor = true;
this.powerSwitchButton.CheckStateChanged += new System.EventHandler(this.onSwitchCheckStateChanged);
//
// webCamRotVelocityLbl
//
this.webCamRotVelocityLbl.AutoSize = true;
@@ -423,19 +367,6 @@ namespace FSRemotePowerSwitch {
this.webCamRotVelocityLbl.TabIndex = 28;
this.webCamRotVelocityLbl.Text = "WebCam Geschwindigkeit";
//
// webCamRotatorVelocitySwitch
//
this.webCamRotatorVelocitySwitch.Location = new System.Drawing.Point(447, 194);
this.webCamRotatorVelocitySwitch.MinimumSize = new System.Drawing.Size(45, 22);
this.webCamRotatorVelocitySwitch.Name = "webCamRotatorVelocitySwitch";
this.webCamRotatorVelocitySwitch.OffBackColor = System.Drawing.Color.Gray;
this.webCamRotatorVelocitySwitch.OffToggleColor = System.Drawing.Color.Gainsboro;
this.webCamRotatorVelocitySwitch.OnBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.webCamRotatorVelocitySwitch.OnToggleColor = System.Drawing.Color.WhiteSmoke;
this.webCamRotatorVelocitySwitch.Size = new System.Drawing.Size(45, 22);
this.webCamRotatorVelocitySwitch.TabIndex = 31;
this.webCamRotatorVelocitySwitch.UseVisualStyleBackColor = true;
//
// webCamRotatorVelocitySlowLbl
//
this.webCamRotatorVelocitySlowLbl.AutoSize = true;
@@ -458,6 +389,76 @@ namespace FSRemotePowerSwitch {
this.webCamRotatorVelocityFastLbl.TabIndex = 30;
this.webCamRotatorVelocityFastLbl.Text = "FAST";
//
// webCamRotator
//
this.webCamRotator.EndAngle = 420F;
this.webCamRotator.ForeColor = System.Drawing.Color.AliceBlue;
this.webCamRotator.ImeMode = System.Windows.Forms.ImeMode.On;
this.webCamRotator.KnobBackColor = System.Drawing.Color.Silver;
this.webCamRotator.KnobPointerStyle = KnobControl.KnobControl.KnobPointerStyles.circle;
this.webCamRotator.LargeChange = 5;
this.webCamRotator.Location = new System.Drawing.Point(234, 133);
this.webCamRotator.Maximum = 180;
this.webCamRotator.Minimum = -180;
this.webCamRotator.Name = "webCamRotator";
this.webCamRotator.PointerColor = System.Drawing.SystemColors.HotTrack;
this.webCamRotator.ScaleColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.webCamRotator.ScaleDivisions = 13;
this.webCamRotator.ScaleFont = new System.Drawing.Font("Bahnschrift SemiLight SemiConde", 9F);
this.webCamRotator.ScaleFontAutoSize = false;
this.webCamRotator.ScaleSubDivisions = 2;
this.webCamRotator.ShowLargeScale = true;
this.webCamRotator.ShowSmallScale = true;
this.webCamRotator.Size = new System.Drawing.Size(165, 165);
this.webCamRotator.SmallChange = 1;
this.webCamRotator.StartAngle = 120F;
this.webCamRotator.TabIndex = 17;
this.webCamRotator.Value = 0;
this.webCamRotator.ValueChanged += new KnobControl.ValueChangedEventHandler(this.onWebCamRotatorValueChanged);
this.webCamRotator.MiddleAreaClicked += new KnobControl.MiddleAreaMouseClickEventHandler(this.onWebCamRotatorMiddleAreaClicked);
//
// webCamRotatorVelocitySwitch
//
this.webCamRotatorVelocitySwitch.Location = new System.Drawing.Point(447, 194);
this.webCamRotatorVelocitySwitch.MinimumSize = new System.Drawing.Size(45, 22);
this.webCamRotatorVelocitySwitch.Name = "webCamRotatorVelocitySwitch";
this.webCamRotatorVelocitySwitch.OffBackColor = System.Drawing.Color.Gray;
this.webCamRotatorVelocitySwitch.OffToggleColor = System.Drawing.Color.Gainsboro;
this.webCamRotatorVelocitySwitch.OnBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.webCamRotatorVelocitySwitch.OnToggleColor = System.Drawing.Color.WhiteSmoke;
this.webCamRotatorVelocitySwitch.Size = new System.Drawing.Size(45, 22);
this.webCamRotatorVelocitySwitch.TabIndex = 31;
this.webCamRotatorVelocitySwitch.UseVisualStyleBackColor = true;
this.webCamRotatorVelocitySwitch.CheckStateChanged += new System.EventHandler(this.onWebCamVelocitySwitchCheckedStateChanged);
//
// webCamRotatorPowerSwitch
//
this.webCamRotatorPowerSwitch.Location = new System.Drawing.Point(434, 278);
this.webCamRotatorPowerSwitch.MinimumSize = new System.Drawing.Size(45, 22);
this.webCamRotatorPowerSwitch.Name = "webCamRotatorPowerSwitch";
this.webCamRotatorPowerSwitch.OffBackColor = System.Drawing.Color.Gray;
this.webCamRotatorPowerSwitch.OffToggleColor = System.Drawing.Color.Gainsboro;
this.webCamRotatorPowerSwitch.OnBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.webCamRotatorPowerSwitch.OnToggleColor = System.Drawing.Color.WhiteSmoke;
this.webCamRotatorPowerSwitch.Size = new System.Drawing.Size(45, 22);
this.webCamRotatorPowerSwitch.TabIndex = 25;
this.webCamRotatorPowerSwitch.UseVisualStyleBackColor = true;
this.webCamRotatorPowerSwitch.CheckStateChanged += new System.EventHandler(this.onWebCamPowerSwitchCheckStateChanged);
//
// powerSwitchButton
//
this.powerSwitchButton.Location = new System.Drawing.Point(72, 135);
this.powerSwitchButton.MinimumSize = new System.Drawing.Size(45, 22);
this.powerSwitchButton.Name = "powerSwitchButton";
this.powerSwitchButton.OffBackColor = System.Drawing.Color.Gray;
this.powerSwitchButton.OffToggleColor = System.Drawing.Color.Gainsboro;
this.powerSwitchButton.OnBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(151)))), ((int)(((byte)(156)))));
this.powerSwitchButton.OnToggleColor = System.Drawing.Color.WhiteSmoke;
this.powerSwitchButton.Size = new System.Drawing.Size(80, 40);
this.powerSwitchButton.TabIndex = 16;
this.powerSwitchButton.UseVisualStyleBackColor = true;
this.powerSwitchButton.CheckStateChanged += new System.EventHandler(this.onSwitchCheckStateChanged);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 18F);

+ 60
- 13
Form1.cs Datei anzeigen

@@ -80,6 +80,8 @@ namespace FSRemotePowerSwitch {
sendWebCamStatusCmd();
waitForPendingRequest();
sendWebCamActualAzimutCmd();
waitForPendingRequest();
sendWebCamVelocityStatusCmd();
BeginInvoke(new EventHandler(delegate {
reconnectBtn.Visible = false;
}));
@@ -100,8 +102,10 @@ namespace FSRemotePowerSwitch {
}
private void waitForPendingRequest() {
while(RequestPending) {
Thread.Sleep(2);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (RequestPending && stopwatch.ElapsedMilliseconds < 3000) {
Thread.Sleep(5);
}
}
@@ -136,18 +140,23 @@ namespace FSRemotePowerSwitch {
Message msg = JsonConvert.DeserializeObject<Message>(s);
try {
if (msg.Sender.Equals(Message.CMD_SENDER_AN) && msg.Cmd.Equals(Message.CMD_VER) && msg.Val.Equals(firmwareVersion)) {
if (msg.Sender.Equals(Message.CMD_SENDER_AN) && msg.Cmd.Equals(Message.CMD_VER)) {
BeginInvoke(new EventHandler(delegate {
Connected = true;
initStatusLbl.Text = "Verbunden";
connectedSerialPortLbl.Text = "Port: " + ((SerialPort)sender).PortName;
fwVersionLbl.Text = "Ver: " + firmwareVersion;
initProgressBar.Style = ProgressBarStyle.Continuous;
initProgressBar.Value = 100;
openBtn.Enabled = false;
closeBtn.Enabled = true;
powerSwitchButton.Enabled = true;
statusTimer.Enabled = true;
if (msg.Val.Equals(firmwareVersion)) {
Connected = true;
initStatusLbl.Text = "Verbunden";
connectedSerialPortLbl.Text = "Port: " + ((SerialPort)sender).PortName;
fwVersionLbl.Text = "Ver: " + firmwareVersion;
initProgressBar.Style = ProgressBarStyle.Continuous;
initProgressBar.Value = 100;
openBtn.Enabled = false;
closeBtn.Enabled = true;
powerSwitchButton.Enabled = true;
statusTimer.Enabled = true;
} else {
fwVersionLbl.Size = new System.Drawing.Size(90, 29);
fwVersionLbl.Text = "Ver: KONFLIKT!";
}
}));
} else if (msg.Sender.Equals(Message.CMD_SENDER_AN) && msg.Cmd.Equals(Message.CMD_STATUS_RELAY)) {
RequestPending = false;
@@ -188,6 +197,13 @@ namespace FSRemotePowerSwitch {
BeginInvoke(new EventHandler(delegate {
webCamRotator.Value = int.Parse(msg.Val);
}));
} else if (msg.Sender.Equals(Message.CMD_SENDER_AN) && msg.Cmd.Equals(Message.CMD_VELOCITY_CAM)) {
RequestPending = false;
BeginInvoke(new EventHandler(delegate {
webCamRotatorVelocitySwitch.CheckStateChanged -= onWebCamVelocitySwitchCheckedStateChanged;
webCamRotatorVelocitySwitch.Checked = msg.Val.Equals(Message.CMD_VELOCITY_FAST);
webCamRotatorVelocitySwitch.CheckStateChanged += onWebCamVelocitySwitchCheckedStateChanged;
}));
}
} catch (Exception ex) when (ex is Newtonsoft.Json.JsonReaderException ||
ex is Newtonsoft.Json.JsonSerializationException) {
@@ -341,6 +357,30 @@ namespace FSRemotePowerSwitch {
}
}
private void sendWebCamVelocityCmd(String value) {
Message msg = new Message();
msg.Sender = Message.CMD_SENDER_PC;
msg.Cmd = Message.CMD_VELOCITY_CAM;
msg.Val = value;
string msJson = JsonConvert.SerializeObject(msg);
if (serialPort.IsOpen) {
serialPort.Write(msJson);
RequestPending = true;
}
}
private void sendWebCamVelocityStatusCmd() {
Message msg = new Message();
msg.Sender = Message.CMD_SENDER_PC;
msg.Cmd = Message.CMD_VELOCITY_CAM;
msg.Val = "";
string msJson = JsonConvert.SerializeObject(msg);
if (serialPort.IsOpen) {
serialPort.Write(msJson);
RequestPending = true;
}
}
private void onStatusTimerTick(object sender, EventArgs e) {
if (timerCount % 2 == 0) {
sendWebCamStatusCmd();
@@ -371,5 +411,12 @@ namespace FSRemotePowerSwitch {
sendWebCamAzimutCmd();
}
private void onWebCamVelocitySwitchCheckedStateChanged(object sender, EventArgs e) {
if (webCamRotatorVelocitySwitch.Checked) {
sendWebCamVelocityCmd(Message.CMD_VELOCITY_FAST);
} else {
sendWebCamVelocityCmd(Message.CMD_VELOCITY_SLOW);
}
}
}
}

+ 4
- 0
Message.cs Datei anzeigen

@@ -25,9 +25,13 @@ namespace FSRemotePowerSwitch {
public static string CMD_POWER_CAM = "Power_Cam";
public static string CMD_AZIMUT_CAM = "Azimut_Cam";
public static string CMD_ACT_AZIMUT_CAM = "Actual_Azimut_Cam";
public static string CMD_VELOCITY_CAM = "Velocity_Cam";
public static string CMD_ZERO_CAM = "Zero_Cam";
public static string CMD_VAL_ON = "On";
public static string CMD_VAL_OFF = "Off";
public static string CMD_VELOCITY_SLOW = "Slow";
public static string CMD_VELOCITY_FAST = "Fast";
public string Sender { get; set; }
public string Cmd { get; set; }

Laden…
Abbrechen
Speichern