public Form1() { InitializeComponent(); int iIdx; m_bStart = false; // the action stops at the beginning m_szIP = "172.18.3.200"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP m_Adam6000Type = Adam6000Type.Adam6024; // the sample is for ADAM-6050 // modbus current list view item m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type); m_iDiTotal = DigitalInput.GetChannelTotal(m_Adam6000Type); m_iAoTotal = AnalogOutput.GetChannelTotal(m_Adam6000Type); m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type); m_bChEnabled = new bool[m_iAiTotal]; m_byAiRange = new byte[m_iAiTotal]; m_byAoRange = new byte[m_iAoTotal]; for (iIdx = 0; iIdx < m_iAoTotal; iIdx++) { // cbxAOChannel.Items.Add(iIdx.ToString()); // } cbxAOChannel.SelectedIndex = -1; txtModule.Text = m_Adam6000Type.ToString(); }
public Form1() { InitializeComponent(); int iIdx; m_b5000 = true; // set to true for module on ADAM-5000; set to false for module on ADAM-5000/TCP if (m_b5000) { m_iCom = 4; // using COM4 adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum } else { m_szIP = "172.18.3.179"; adamSocket = new AdamSocket(); adamSocket.SetTimeout(1000, 1000, 1000); // set timeout } m_iAddr = 1; // the slave address is 1 m_iSlot = 0; // the slot index of the module m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam5000Type = Adam5000Type.Adam5024; // the sample is for ADAM-5024 m_iChTotal = AnalogOutput.GetChannelTotal(m_Adam5000Type); m_byRange = new byte[m_iChTotal]; for (iIdx = 0; iIdx < m_iChTotal; iIdx++) { cbxChannel.Items.Add(iIdx.ToString()); } txtModule.Text = m_Adam5000Type.ToString(); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // int iIdx; adamCtl = new AdamControl(); m_iSlot = 2; // the slot index of the module m_iCount = 0; // the counting start from 0 m_bStart = false; adamCtl = new AdamControl(); m_Adam5000Type = Adam5000Type.Adam5024; // the sample is for ADAM-5024 m_iChTotal = AnalogOutput.GetChannelTotal(m_Adam5000Type); m_byRange = new byte[m_iChTotal]; for (iIdx = 0; iIdx < m_iChTotal; iIdx++) { cbxChannel.Items.Add(iIdx.ToString()); } txtModule.Text = m_Adam5000Type.ToString(); }
private void RefreshAdam5000Information() { int iIdx; byte byCode; Adam5000Type adamType; adamType = (Adam5000Type)cbxModuleType.SelectedItem; // AI information txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString(); listViewAI.Items.Clear(); for (iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType); iIdx++) { byCode = AnalogInput.GetRangeCode(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode)); // range name } // AO information txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString(); listViewAO.Items.Clear(); for (iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType); iIdx++) { byCode = AnalogOutput.GetRangeCode(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode)); // range name } // DIO txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString(); txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString(); // counter txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString(); listViewCounter.Items.Clear(); if (Counter.GetModeTotal(adamType) > 0) { listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Bi_Direction))); // mode name listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Bi_Direction)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Up_Down))); // mode name listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Up_Down)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam5080_CounterMode.Frequency))); // mode name listViewCounter.Items[2].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam5080_CounterMode.Frequency)); // unit name } // alarm listViewAlarm.Items.Clear(); for (iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++) { byCode = Alarm.GetModeCode(adamType, iIdx); listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name } }
public Adam6000(string name, Adam6000Type model) : base(name, new ChannelsInfo { AnalogInputsCount = AnalogInput.GetChannelTotal(model), AnalogOutputsCount = AnalogOutput.GetChannelTotal(model), DiscreteInputsCount = DigitalInput.GetChannelTotal(model), DiscreteOutputsCount = DigitalOutput.GetChannelTotal(model), CounterInputsCount = DigitalInput.GetChannelTotal(model) }) { Model = model; if (AnalogInputs != null) { AIRanges = new List <byte>(new byte[AnalogInputs.Count]); } }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // m_bStart = false; // the action stops at the beginning m_szIP = "172.18.3.93"; // modbus slave IP address m_iPort = 502; // modbus TCP port is 502 adamModbus = new AdamSocket(); adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP adamModbus.AdamSeriesType = AdamType.Adam6200; adamModbus.Connect(m_szIP, ProtocolType.Tcp, m_iPort); m_Adam6000Type = Adam6000Type.Adam6224; // the sample is for ADAM-6224 m_iAoChTotal = AnalogOutput.GetChannelTotal(m_Adam6000Type); m_iAoRangeTotal = AnalogOutput.GetRangeTotal(m_Adam6000Type, Adam6000_RangeFormat.Ushort); m_iDiTotal = DigitalInput.GetChannelTotal(m_Adam6000Type); m_DiValueStartAddr = 1; m_iAoValueStartAddr = 1; txtModule.Text = m_Adam6000Type.ToString(); m_usRange = new ushort[m_iAoChTotal]; m_usAoValue = new ushort[m_iAoChTotal]; InitialDiDgViewModbusGeneralRow(m_DiValueStartAddr, m_iDiTotal, ref dgViewDiChannelInfo); InitialAoDgViewModbusGeneralRow(m_iAoValueStartAddr, m_iAoChTotal, ref dgViewAoChannelInfo); for (int i = 0; i < m_iAoChTotal; i++) { cbxAoChannel.Items.Add(i.ToString()); } cbxAoChannel.Items.Add("All"); if (m_Adam6000Type == Adam6000Type.Adam6224) { for (int i_iIndex = 0; i_iIndex < m_iAoRangeTotal; i_iIndex++) { ushort usRangeCode = AnalogOutput.GetRangeCode2Byte(m_Adam6000Type, i_iIndex); string strRangeName = AnalogOutput.GetRangeName(m_Adam6000Type, usRangeCode); cbxAoOutputRange.Items.Add(new ComboItem(strRangeName, usRangeCode)); } } }
public Form1() { InitializeComponent(); int iIdx; m_iCom = 4; // using COM2 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4024; // the sample is for ADAM-4024 m_iChTotal = AnalogOutput.GetChannelTotal(m_Adam4000Type); m_byRange = new byte[m_iChTotal]; for (iIdx = 0; iIdx < m_iChTotal; iIdx++) { cbxChannel.Items.Add(iIdx.ToString()); } adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum txtModule.Text = m_Adam4000Type.ToString(); }
private void RefreshAdam6000Information() { byte byCode; ushort usCode; int intAdamType; Adam6000Type adamType; adamType = (Adam6000Type)cbxModuleType.SelectedItem; intAdamType = (int)adamType; // AI information txtAITotal.Text = AnalogInput.GetChannelTotal(adamType).ToString(); listViewAI.Items.Clear(); if ((intAdamType == 6017) || ((intAdamType >= 6217) && (intAdamType <= 6224))) { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Ushort); iIdx++) { usCode = AnalogInput.GetRangeCode2Byte(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + usCode.ToString("X04"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, usCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, usCode)); // unit name } } else { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Byte); iIdx++) { byCode = AnalogInput.GetRangeCode(adamType, iIdx); listViewAI.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, byCode)); // range name listViewAI.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, byCode)); // unit name } } // AO information txtAOTotal.Text = AnalogOutput.GetChannelTotal(adamType).ToString(); listViewAO.Items.Clear(); if ((intAdamType >= 6217) && (intAdamType <= 6224)) { for (int iIdx = 0; iIdx < AnalogOutput.GetRangeTotal(adamType, Adam6000_RangeFormat.Ushort); iIdx++) { usCode = AnalogOutput.GetRangeCode2Byte(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + usCode.ToString("X04"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogInput.GetRangeName(adamType, usCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogInput.GetUnitName(adamType, usCode)); // unit name } } else { for (int iIdx = 0; iIdx < AnalogInput.GetRangeTotal(adamType, Adam6000_RangeFormat.Byte); iIdx++) { byCode = AnalogOutput.GetRangeCode(adamType, iIdx); listViewAO.Items.Add(new ListViewItem("0x" + byCode.ToString("X02"))); // range code listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetRangeName(adamType, byCode)); // range name listViewAO.Items[iIdx].SubItems.Add(AnalogOutput.GetUnitName(adamType, byCode)); // range name } } // DIO txtDITotal.Text = DigitalInput.GetChannelTotal(adamType).ToString(); txtDOTotal.Text = DigitalOutput.GetChannelTotal(adamType).ToString(); // counter txtCounterTotal.Text = Counter.GetChannelTotal(adamType).ToString(); listViewCounter.Items.Clear(); if (Counter.GetModeTotal(adamType) > 0) { listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam6051_CounterMode.Counter))); // mode name listViewCounter.Items[0].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam6051_CounterMode.Counter)); // unit name listViewCounter.Items.Add(new ListViewItem(Counter.GetModeName(adamType, (byte)Adam6051_CounterMode.Frequency))); // mode name listViewCounter.Items[1].SubItems.Add(Counter.GetUnitName(adamType, (byte)Adam6051_CounterMode.Frequency)); // unit name } // alarm listViewAlarm.Items.Clear(); for (int iIdx = 0; iIdx < Alarm.GetModeTotal(adamType); iIdx++) { byCode = Alarm.GetModeCode(adamType, iIdx); listViewAlarm.Items.Add(new ListViewItem(Alarm.GetModeName(adamType, byCode))); // mode name } }