public void readSyn(int[] arryHandleServer, int length, out String[] arryResult) { OPCItemState[] arrystate = new OPCItemState[length]; arryResult = new String[length]; try { if (arryHandleServer != null) { TheGrp.SyncRead(OPCDATASOURCE.OPC_DS_DEVICE, arryHandleServer, out arrystate); } if (arrystate != null) { for (int i = 0; i < arrystate.Length; i++) { if (arrystate[i].Quality == 192) { arryResult[i] = arrystate[i].DataValue.ToString(); } else { arryResult[i] = arrystate[i].Quality.ToString(); } } } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); } }
private void cmdReadSync_Click(object sender, EventArgs e) { int[] aE = new int[2]; _txtReadVal_0.Text = ""; _txtReadVal_1.Text = ""; int[] arrHSrv = new int[2]; OPCItemState[] arrStat = new OPCItemState[2]; arrHSrv[0] = itemResults[0].HandleServer; arrHSrv[1] = itemResults[1].HandleServer; try { theGroup.SyncRead(OPCDATASOURCE.OPC_DS_DEVICE, arrHSrv, out arrStat); if (arrStat[0].Quality == 192) { _txtReadVal_0.Text = arrStat[0].DataValue.ToString(); _txtReadVal_0.BackColor = Color.White; } else { _txtReadVal_0.Text = GetQualityText(arrStat[0].Quality); _txtReadVal_0.BackColor = Color.Red; } if (arrStat[1].Quality == 192) { _txtReadVal_1.Text = arrStat[1].DataValue.ToString(); _txtReadVal_1.BackColor = Color.White; } else { _txtReadVal_1.Text = GetQualityText(arrStat[1].Quality); _txtReadVal_1.BackColor = Color.Red; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }