private bool InitAdam5050() { bool[] bDIO, bMask; bool bRet; int iCh = 0, iDI = 0, iDO = 0; if (m_b5000) { bRet = (adamCom.DigitalInput(m_iAddr).GetUniversalStatus(m_iSlot, out bDIO) & adamCom.DigitalOutput(m_iAddr).GetAlarmMappingMask(m_iSlot, m_iChTotal, out bMask)); } else { bRet = (adamSocket.DigitalInput(m_iAddr).GetUniversalStatus(m_iSlot, out bDIO) & adamSocket.DigitalOutput(m_iAddr).GetAlarmMappingMask(m_iSlot, m_iChTotal, out bMask)); } if (bRet && bDIO.Length == 16) { InitChannelItems(true, bDIO[0], bMask[0], ref iCh, ref iDI, ref iDO, ref panelCh0, ref btnCh0); InitChannelItems(true, bDIO[1], bMask[1], ref iCh, ref iDI, ref iDO, ref panelCh1, ref btnCh1); InitChannelItems(true, bDIO[2], bMask[2], ref iCh, ref iDI, ref iDO, ref panelCh2, ref btnCh2); InitChannelItems(true, bDIO[3], bMask[3], ref iCh, ref iDI, ref iDO, ref panelCh3, ref btnCh3); InitChannelItems(true, bDIO[4], bMask[4], ref iCh, ref iDI, ref iDO, ref panelCh4, ref btnCh4); InitChannelItems(true, bDIO[5], bMask[5], ref iCh, ref iDI, ref iDO, ref panelCh5, ref btnCh5); InitChannelItems(true, bDIO[6], bMask[6], ref iCh, ref iDI, ref iDO, ref panelCh6, ref btnCh6); InitChannelItems(true, bDIO[7], bMask[7], ref iCh, ref iDI, ref iDO, ref panelCh7, ref btnCh7); InitChannelItems(true, bDIO[8], bMask[8], ref iCh, ref iDI, ref iDO, ref panelCh8, ref btnCh8); InitChannelItems(true, bDIO[9], bMask[9], ref iCh, ref iDI, ref iDO, ref panelCh9, ref btnCh9); InitChannelItems(true, bDIO[10], bMask[10], ref iCh, ref iDI, ref iDO, ref panelCh10, ref btnCh10); InitChannelItems(true, bDIO[11], bMask[11], ref iCh, ref iDI, ref iDO, ref panelCh11, ref btnCh11); InitChannelItems(true, bDIO[12], bMask[12], ref iCh, ref iDI, ref iDO, ref panelCh12, ref btnCh12); InitChannelItems(true, bDIO[13], bMask[13], ref iCh, ref iDI, ref iDO, ref panelCh13, ref btnCh13); InitChannelItems(true, bDIO[14], bMask[14], ref iCh, ref iDI, ref iDO, ref panelCh14, ref btnCh14); InitChannelItems(true, bDIO[15], bMask[15], ref iCh, ref iDI, ref iDO, ref panelCh15, ref btnCh15); return(true); } return(false); }
private void RefreshDIValue() { bool[] bValue; if (adamCom.DigitalInput(m_iAddr).GetValues(out bValue)) { txtDI0.Text = bValue[0].ToString(); txtDI1.Text = bValue[1].ToString(); txtDI2.Text = bValue[2].ToString(); txtDI3.Text = bValue[3].ToString(); } else { txtDI0.Text = "GetValues() failed"; txtDI1.Text = "GetValues() failed"; txtDI2.Text = "GetValues() failed"; txtDI3.Text = "GetValues() failed"; } }
private void RefresDIO() { bool[] bDI, bDO; if (adamCom.DigitalInput(m_iAddr).GetValues(m_iDITotal, m_iDOTotal, out bDI, out bDO)) { if (m_iDITotal > 0) { if (m_iDOTotal > 0) // DI > 0, DO > 0 { if (m_iDITotal > 0) { txtCh0.Text = bDI[0].ToString(); } if (m_iDITotal > 1) { txtCh1.Text = bDI[1].ToString(); } if (m_iDITotal > 2) { txtCh2.Text = bDI[2].ToString(); } if (m_iDITotal > 3) { txtCh3.Text = bDI[3].ToString(); } if (m_iDITotal > 4) { txtCh4.Text = bDI[4].ToString(); } if (m_iDITotal > 5) { txtCh5.Text = bDI[5].ToString(); } if (m_iDITotal > 6) { txtCh6.Text = bDI[6].ToString(); } if (m_iDITotal > 7) { txtCh7.Text = bDI[7].ToString(); } // if (m_iDOTotal > 0) { txtCh8.Text = bDO[0].ToString(); } if (m_iDOTotal > 1) { txtCh9.Text = bDO[1].ToString(); } if (m_iDOTotal > 2) { txtCh10.Text = bDO[2].ToString(); } if (m_iDOTotal > 3) { txtCh11.Text = bDO[3].ToString(); } if (m_iDOTotal > 4) { txtCh12.Text = bDO[4].ToString(); } if (m_iDOTotal > 5) { txtCh13.Text = bDO[5].ToString(); } if (m_iDOTotal > 6) { txtCh14.Text = bDO[6].ToString(); } if (m_iDOTotal > 7) { txtCh15.Text = bDO[7].ToString(); } } else // DI > 0, DO = 0 { if (m_iDITotal > 0) { txtCh0.Text = bDI[0].ToString(); } if (m_iDITotal > 1) { txtCh1.Text = bDI[1].ToString(); } if (m_iDITotal > 2) { txtCh2.Text = bDI[2].ToString(); } if (m_iDITotal > 3) { txtCh3.Text = bDI[3].ToString(); } if (m_iDITotal > 4) { txtCh4.Text = bDI[4].ToString(); } if (m_iDITotal > 5) { txtCh5.Text = bDI[5].ToString(); } if (m_iDITotal > 6) { txtCh6.Text = bDI[6].ToString(); } if (m_iDITotal > 7) { txtCh7.Text = bDI[7].ToString(); } if (m_iDITotal > 8) { txtCh8.Text = bDI[8].ToString(); } if (m_iDITotal > 9) { txtCh9.Text = bDI[9].ToString(); } if (m_iDITotal > 10) { txtCh10.Text = bDI[10].ToString(); } if (m_iDITotal > 11) { txtCh11.Text = bDI[11].ToString(); } if (m_iDITotal > 12) { txtCh12.Text = bDI[12].ToString(); } if (m_iDITotal > 13) { txtCh13.Text = bDI[13].ToString(); } if (m_iDITotal > 14) { txtCh14.Text = bDI[14].ToString(); } if (m_iDITotal > 15) { txtCh15.Text = bDI[15].ToString(); } } } else // DI = 0, DO > 0 { if (m_iDOTotal > 0) { txtCh0.Text = bDO[0].ToString(); } if (m_iDOTotal > 1) { txtCh1.Text = bDO[1].ToString(); } if (m_iDOTotal > 2) { txtCh2.Text = bDO[2].ToString(); } if (m_iDOTotal > 3) { txtCh3.Text = bDO[3].ToString(); } if (m_iDOTotal > 4) { txtCh4.Text = bDO[4].ToString(); } if (m_iDOTotal > 5) { txtCh5.Text = bDO[5].ToString(); } if (m_iDOTotal > 6) { txtCh6.Text = bDO[6].ToString(); } if (m_iDOTotal > 7) { txtCh7.Text = bDO[7].ToString(); } if (m_iDOTotal > 8) { txtCh8.Text = bDO[8].ToString(); } if (m_iDOTotal > 9) { txtCh9.Text = bDO[9].ToString(); } if (m_iDOTotal > 10) { txtCh10.Text = bDO[10].ToString(); } if (m_iDOTotal > 11) { txtCh11.Text = bDO[11].ToString(); } if (m_iDOTotal > 12) { txtCh12.Text = bDO[12].ToString(); } if (m_iDOTotal > 13) { txtCh13.Text = bDO[13].ToString(); } if (m_iDOTotal > 14) { txtCh14.Text = bDO[14].ToString(); } if (m_iDOTotal > 15) { txtCh15.Text = bDO[15].ToString(); } } } else { txtCh0.Text = "Fail"; txtCh1.Text = "Fail"; txtCh2.Text = "Fail"; txtCh3.Text = "Fail"; txtCh4.Text = "Fail"; txtCh5.Text = "Fail"; txtCh6.Text = "Fail"; txtCh7.Text = "Fail"; txtCh8.Text = "Fail"; txtCh9.Text = "Fail"; txtCh10.Text = "Fail"; txtCh11.Text = "Fail"; txtCh12.Text = "Fail"; txtCh13.Text = "Fail"; txtCh14.Text = "Fail"; txtCh15.Text = "Fail"; } }
public bool Get(out bool[] di, out bool[] @do) => adamCom.DigitalInput(address).GetValues(DiNumber, DoNumber, out di, out @do);
private void timer1_Tick(object sender, EventArgs e) { long lVal; bool bDI; float[] fVal; bool[] DOStatus; Adam4000_ChannelStatus[] status; Adam_AIAlarmMode mode; m_iCount++; txtReadCount.Text = "Polling " + m_iCount.ToString() + " times..."; if (adamCom.AnalogInput(m_iAddr).GetValues(1, out fVal, out status)) // read AI value { if (status[0] == Adam4000_ChannelStatus.Normal) // the value is normal { txtAI.Text = fVal[0].ToString() + " " + AnalogInput.GetUnitName(m_Adam4000Type, m_adamConfig.TypeCode); } else // the value is invalid { txtAI.Text = status[0].ToString(); } } else { txtAI.Text = "Failed to get!"; } // for ADAM-4011, ADAM-4011D, or ADAM-4012 if (m_Adam4000Type != Adam4000Type.Adam4013) { // event counter if (adamCom.Counter(m_iAddr).GetValue(out lVal)) { txtCounter.Text = lVal.ToString(); } else { txtCounter.Text = "Failed to get!"; } // event status if (adamCom.DigitalInput(m_iAddr).GetValue(out bDI)) { txtEvent.Text = bDI.ToString(); } else { txtEvent.Text = "Failed to get!"; } // alarm if (adamCom.Alarm(m_iAddr).GetModeAlarmDO(2, out mode, out DOStatus)) { m_DOStatus[0] = DOStatus[0]; m_DOStatus[1] = DOStatus[1]; txtLowAlarm.Text = DOStatus[0].ToString(); txtHighAlarm.Text = DOStatus[1].ToString(); } else { txtLowAlarm.Text = "Failed to get!"; txtHighAlarm.Text = "Failed to get!"; } } }