private void HMIEditor_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Return) { if (string.IsNullOrEmpty(PLCAddressValue) ? true : string.IsNullOrWhiteSpace(PLCAddressValue)) { Utility.Utility.ShowTagNameInvalidMessage(this, Name); } else if (TagCollectionClient.Tags[PLCAddressValue] != null) { dynamic text = Text; WCFChannelFactory.Write(PLCAddressValue, text); } else { Utility.Utility.ShowTagInvalidMessage(this, Name); } } } catch (Exception exception1) { var exception = exception1; MessageBox.Show(this, exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); this.ButtonIsDown = false; if (this.Enabled) { if (this.OutputType != OutputType.Toggle) { this.LightImage = this.LightOffImage; } this.Invalidate(); } if (!string.IsNullOrWhiteSpace(m_PLCAddressClick) & Enabled) { try { switch (OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(m_PLCAddressClick, "0"); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(m_PLCAddressClick, "1"); break; } } catch (Exception ex) { DisplayError("WRITE FAILED!" + ex.Message); } Invalidate(); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (!string.IsNullOrWhiteSpace(m_PLCAddressClick) & Enabled) { try { switch (OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(m_PLCAddressClick, "0"); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(m_PLCAddressClick, "1"); break; } } catch (Exception ex) { DisplayError("WRITE FAILED!" + ex.Message); } Invalidate(); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (Enabled) { LightImage = LightOnImage; Invalidate(); } if (!string.IsNullOrWhiteSpace(m_PLCAddressClick) & Enabled && PLCAddressClick != null) { try { switch (OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(m_PLCAddressClick, "1"); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(m_PLCAddressClick, "0"); break; case OutputType.SetTrue: WCFChannelFactory.Write(m_PLCAddressClick, "1"); break; case OutputType.SetFalse: WCFChannelFactory.Write(m_PLCAddressClick, "0"); break; case OutputType.Toggle: var CurrentValue = Value; if (CurrentValue) { WCFChannelFactory.Write(m_PLCAddressClick, "0"); } else { WCFChannelFactory.Write(m_PLCAddressClick, "1"); } break; default: break; } } catch (Exception ex) { DisplayError("WRITE FAILED!" + ex.Message); } Invalidate(); } }
public void ValueToWrite() { if (string.IsNullOrEmpty(m_PLCAddressValueToWrite) || string.IsNullOrWhiteSpace(m_PLCAddressValueToWrite) || Licenses.LicenseManager.IsInDesignMode) { return; } WCFChannelFactory.Write(m_PLCAddressValueToWrite, this.Text); }
private void KeypadPopUp_ButtonClick(object sender, KeypadEventArgs e) { if (e.Key == "Quit") { KeypadPopUp.Visible = false; } else if (e.Key == "Enter") { if (KeypadPopUp.Value != null && string.Compare(KeypadPopUp.Value, string.Empty) != 0) { try { if (KeypadMaxValue != KeypadMinValue) { if ((Convert.ToDouble(KeypadPopUp.Value) < KeypadMinValue) | (Convert.ToDouble(KeypadPopUp.Value) > KeypadMaxValue)) { MessageBox.Show("Value must be >" + KeypadMinValue + " and <" + KeypadMaxValue); return; } } } catch (Exception ex) { MessageBox.Show("Failed to validate value. " + ex.Message); return; } try { if ((KeypadScaleFactor == 1) | (KeypadScaleFactor == 0)) { WCFChannelFactory.Write(m_PLCAddressKeypad, KeypadPopUp.Value); } else { var v = Convert.ToDouble(KeypadPopUp.Value); var z = v / m_KeypadScaleFactor; WCFChannelFactory.Write(m_PLCAddressKeypad, (Convert.ToDouble(KeypadPopUp.Value) / m_KeypadScaleFactor).ToString()); } } catch (Exception ex) { MessageBox.Show("Failed to write value. " + ex.Message); } } KeypadPopUp.Visible = false; } }
//****************************************************************************************** //* Use the base control's text property and make it visible as a property on the designer //****************************************************************************************** private void ReleaseValue() { try { if (OutputType == OutputType.MomentarySet) { WCFChannelFactory.Write(PLCAddressClick, "0"); } else if (OutputType == OutputType.MomentaryReset) { WCFChannelFactory.Write(PLCAddressClick, "1"); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void MouseDownAction(string PLCAddress) { if (PLCAddress != null && string.Compare(PLCAddress, string.Empty) != 0) { try { switch (m_OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(PLCAddress, "1"); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(PLCAddress, "0"); break; case OutputType.SetTrue: WCFChannelFactory.Write(PLCAddress, "1"); break; case OutputType.SetFalse: WCFChannelFactory.Write(PLCAddress, "0"); break; case OutputType.Toggle: var CurrentValue = false; CurrentValue = Convert.ToBoolean(PLCAddress); if (CurrentValue) { WCFChannelFactory.Write(PLCAddress, "0"); } else { WCFChannelFactory.Write(PLCAddress, "1"); } break; } } catch (Exception ex) { DisplayError(ex.Message); } } }
private void RadioButton_CheckedChanged(object sender, EventArgs e) { if (!string.IsNullOrEmpty(m_PLCAddressCheckChanged)) { try { string WriteValue = "0"; if (this.Checked) { WriteValue = "1"; } WCFChannelFactory.Write(m_PLCAddressCheckChanged, WriteValue); } catch (Exception ex) { DisplayError(ex.Message); } } }
private void ReleaseValue() { try { switch (OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(PLCAddressClick, Convert.ToString(false)); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(PLCAddressClick, Convert.ToString(true)); break; } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected override void OnClick(EventArgs e) { base.OnClick(e); if (!string.IsNullOrEmpty(m_PLCAddressCheckChanged)) { try { var WriteValue = "0"; if (Checked) { WriteValue = "1"; } WCFChannelFactory.Write(m_PLCAddressCheckChanged, WriteValue); } catch (Exception ex) { DisplayError(ex.Message); } } }
protected override void OnEnterKeyPressed(EventArgs e) { base.OnEnterKeyPressed(e); try { if (m_PLCAddressWriteValue != null) { WCFChannelFactory.Write(m_PLCAddressWriteValue, double.Parse(Text)); } else { MessageBox.Show("PLCAddressWriteValue not set to anything"); } } catch (Exception ex) { MessageBox.Show("Failed to write value - " + ex.Message); } }
protected override void OnValueChanged(EventArgs e) { base.OnValueChanged(e); if (this.PLCAddressValue != null) { try { //INSTANT C# NOTE: The following VB 'Select Case' included either a non-ordinal switch expression or non-ordinal, range-type, or non-constant 'Case' expressions and was converted to C# 'if-else' logic: // Select Case _OutputType //ORIGINAL LINE: Case MfgControl.AdvancedHMI.Controls.OutputType.WriteValue if (_OutputType == OutputType.WriteValue) { WCFChannelFactory.Write(this.m_PLCAddressValue, Value); //Write new value to PLCAddress } } catch (Exception ex) { MessageBox.Show("\"" + this.m_PLCAddressValue + "\" PLC Address not found"); } } }
private void KeypadPopUp_ButtonClick(object sender, KeypadEventArgs e) { if (e.Key == "Quit") { KeypadPopUp.Visible = false; } else if (e.Key == "Enter") { if (KeypadPopUp.Value != null && string.Compare(KeypadPopUp.Value, string.Empty) != 0) { try { WCFChannelFactory.Write(m_PLCAddressKeypad, KeypadPopUp.Value); } catch (Exception ex) { MessageBox.Show("Failed to write value. " + ex.Message); } } KeypadPopUp.Visible = false; } }
private void KeypadPopUp_ButtonClick(object sender, KeypadEventArgs e) { if (e.Key == "Quit") { KeypadPopUp.Visible = false; } else if (e.Key == "Enter") { if (KeypadPopUp.Value != null && string.Compare(KeypadPopUp.Value, string.Empty) != 0) { if (ScaleFactor == 1) { WCFChannelFactory.Write(m_PLCAddressKeypad, KeypadPopUp.Value); } else { WCFChannelFactory.Write(m_PLCAddressKeypad, KeypadPopUp.Value); } KeypadPopUp.Visible = false; } } }
private void MouseUpAction(string PLCAddress) { if (PLCAddress != null && (string.Compare(PLCAddress, string.Empty) != 0) & Enabled) { try { switch (OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(PLCAddress, "0"); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(PLCAddress, "1"); break; } } catch (Exception ex) { DisplayError(ex.Message); } } }
protected override void OnMouseDown(MouseEventArgs mevent) { base.OnMouseDown(mevent); if (PLCAddressClick != null && string.Compare(PLCAddressClick, string.Empty) != 0 && Enabled && PLCAddressClick != null) { try { if (OutputType == OutputType.MomentarySet) { WCFChannelFactory.Write(PLCAddressClick, "1"); if (m_MinimumHoldTime > 0) { MinHoldTimer.Enabled = true; } if (m_MaximumHoldTime > 0) { MaxHoldTimer.Enabled = true; } } else if (OutputType == OutputType.MomentaryReset) { WCFChannelFactory.Write(PLCAddressClick, "0"); if (m_MinimumHoldTime > 0) { MinHoldTimer.Enabled = true; } if (m_MaximumHoldTime > 0) { MaxHoldTimer.Enabled = true; } } else if (OutputType == OutputType.SetTrue) { WCFChannelFactory.Write(PLCAddressClick, "1"); } else if (OutputType == OutputType.SetFalse) { WCFChannelFactory.Write(PLCAddressClick, "0"); } else if (OutputType == OutputType.Toggle) { bool CurrentValue = Convert.ToBoolean(Value); if (CurrentValue) { WCFChannelFactory.Write(PLCAddressClick, "0"); } else { WCFChannelFactory.Write(PLCAddressClick, $"{m_Flag}"); } } } catch (Exception) { } } //this.Invalidate(); }
public void Write(string adr, string Value) { WCFChannelFactory.Write(adr, Value); }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (!string.IsNullOrWhiteSpace(m_PLCAddressClick) & Enabled && PLCAddressClick != null) { try { switch (OutputType) { case OutputType.MomentarySet: WCFChannelFactory.Write(m_PLCAddressClick, "1"); break; case OutputType.MomentaryReset: WCFChannelFactory.Write(m_PLCAddressClick, "0"); break; case OutputType.SetTrue: WCFChannelFactory.Write(m_PLCAddressClick, "1"); break; case OutputType.SetFalse: WCFChannelFactory.Write(m_PLCAddressClick, "0"); break; case OutputType.Toggle: var CurrentValue = Value; if (CurrentValue) { WCFChannelFactory.Write(m_PLCAddressClick, "0"); } else { WCFChannelFactory.Write(m_PLCAddressClick, "1"); } break; case OutputType.ValveWeiCtriDialog: var objValveWeiCtriDialog = new ValveWeiCtriDialog(m_PLCAddressClick); var LocationDialogArrays = LocationDialog.Split(';'); objValveWeiCtriDialog.SetDesktopLocation(int.Parse(LocationDialogArrays[0]), int.Parse(LocationDialogArrays[1])); objValveWeiCtriDialog.TopMost = true; objValveWeiCtriDialog.Show(); break; default: break; } } catch (Exception ex) { DisplayError("WRITE FAILED!" + ex.Message); } Invalidate(); } }
private void BtnCLOSE_Click(object sender, EventArgs e) { WCFChannelFactory.Write(PLCAddressClick, "0"); }