private void OpcOnOff(int value) { // PCDCS_Testing_Tool.Form1 log = new PCDCS_Testing_Tool.Form1(); // LogUserControl.UserControl1 log = new LogUserControl.UserControl1(); try { string[] target = new string[] { RegisterTxt.Text }; object[] val = new object[] { value }; int[] nErrorArray; opc.Write(target, val, out nErrorArray); if (nErrorArray[0] != 0) { StatusTxt.Text = "Write Error"; return; } short[] wQualityArray; OpcRcw.Da.FILETIME[] fTimeArray; if (opc.Read(target, out val, out wQualityArray, out fTimeArray, out nErrorArray) == true) { StatusTxt.Text = ReadValCopy(val[0], 0, nErrorArray[0]); } // log.LogHistory(DateTime.Now, TagTxt.Text, RegisterTxt.Text, StatusTxt.Text, "Success"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); // log.LogHistory(DateTime.Now, TagTxt.Text, RegisterTxt.Text, StatusTxt.Text, "Error"); } }
private int[] WriteRepeatValue() { int[] errs; string[] writeReg = new string[] { DEV_NAME + "." + WORD_REG_PREFIX + REP_POS }; object[] writeVal = new object[] { numericUpDown.Value }; if (opc.Write(writeReg, writeVal, out errs)) { Debug.WriteLine("Set Writing Succeed in WriteTimeValues()"); } else { // Log Error DataHelper.ErrorLog("Set Writing Failed in WriteTimeValues()"); } return(errs); }
private void OpcOnOff(int value, string register) { try { string[] target = new string[] { register }; object[] val = new object[] { value }; int[] nErrorArray; opc.Write(target, val, out nErrorArray); if (nErrorArray[0] != 0) { return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void OpcOnOff(string addr, int value, Button btn) { try { int[] nErrorArray; short[] wQualityArray; OpcRcw.Da.FILETIME[] fTimeArray; if (addr.Contains("/")) { string newaddr = addr.Replace("/", ""); string[] target = new string[] { newaddr }; object[] val = new object[] { value }; opc.Write(target, val, out nErrorArray); if (nErrorArray[0] != 0) { return; } if (opc.Read(target, out val, out wQualityArray, out fTimeArray, out nErrorArray) == true) { string regValue; regValue = ReadValCopy(val[0], 0, nErrorArray[0]); if (btn == OpAddrBtn) { if (regValue == "0") { OPStatText.Text = "None"; } else if (regValue == "1") { OPStatText.Text = "Prohibition"; } else if (regValue == "2") { OPStatText.Text = "Maintenance"; } else if (regValue == "3") { OPStatText.Text = "Broke"; } else { return; } } else { if (regValue == "True" || regValue == "-1") { btn.Text = "Off"; } else if (regValue == "False" || regValue == "0") { btn.Text = "On"; } } } } else { string[] target = new string[] { addr }; object[] val = new object[] { value }; opc.Write(target, val, out nErrorArray); if (nErrorArray[0] != 0) { return; } if (opc.Read(target, out val, out wQualityArray, out fTimeArray, out nErrorArray) == true) { string regValue; regValue = ReadValCopy(val[0], 0, nErrorArray[0]); if (btn == OpAddrBtn) { if (regValue == "0") { OPStatText.Text = "None"; } else if (regValue == "1") { OPStatText.Text = "Prohibition"; } else if (regValue == "2") { OPStatText.Text = "Maintenance"; } else if (regValue == "3") { OPStatText.Text = "Broke"; } else { return; } } else { if (regValue == "True" || regValue == "-1") { btn.Text = "On"; } else if (regValue == "False" || regValue == "0") { btn.Text = "Off"; } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }