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 = 2; // using COM2 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.Adam5080; // the sample is for ADAM-5080 m_iChTotal = Counter.GetChannelTotal(m_Adam5000Type); for (iIdx = 0; iIdx < m_iChTotal; iIdx++) { cbxChannel.Items.Add(iIdx.ToString()); } txtModule.Text = m_Adam5000Type.ToString(); }
public Form1() { InitializeComponent(); int iIdx; m_iCom = 4; // using COM4 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4080D; // the sample is for ADAM-4080D m_iChTotal = Counter.GetChannelTotal(m_Adam4000Type); 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(); // LED source cbxLedSource.Items.Add("Channel 0"); cbxLedSource.Items.Add("Channel 1"); cbxLedSource.Items.Add("External input"); }
public Form1() { InitializeComponent(); 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 = 3; // 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.Adam5017H; // the sample is for ADAM-5017H //m_Adam5000Type = Adam5000Type.Adam5017UH; // the sample is for ADAM-5017UH //m_Adam5000Type = Adam5000Type.Adam5018P; // the sample is for ADAM-5018P m_iChTotal = AnalogInput.GetChannelTotal(m_Adam5000Type); m_byRange = new byte[m_iChTotal]; txtModule.Text = m_Adam5000Type.ToString(); // if (m_Adam5000Type == Adam5000Type.Adam5018P) { chkboxCh7.Visible = false; txtAIValue7.Visible = false; } }
public Form1() { InitializeComponent(); 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 = 2; // using COM2 adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum } else { m_szIP = "172.19.1.234"; adamSocket = new AdamSocket(); adamSocket.SetTimeout(1000, 1000, 1000); // set timeout } m_iAddr = 1; // the slave address is 1 m_iSlot = 1; // the slot index of the module m_iCount = 0; // the counting start from 0 m_bStart = false; //m_Adam5000Type = Adam5000Type.Adam5050; // the sample is for ADAM-5050 m_Adam5000Type = Adam5000Type.Adam5051; // the sample is for ADAM-5051 //m_Adam5000Type = Adam5000Type.Adam5052; // the sample is for ADAM-5052 //m_Adam5000Type = Adam5000Type.Adam5055; // the sample is for ADAM-5055 //m_Adam5000Type = Adam5000Type.Adam5056; // the sample is for ADAM-5056 //m_Adam5000Type = Adam5000Type.Adam5060; // the sample is for ADAM-5060 //m_Adam5000Type = Adam5000Type.Adam5068; // the sample is for ADAM-5068 //m_Adam5000Type = Adam5000Type.Adam5069; // the sample is for ADAM-5069 m_iChTotal = DigitalInput.GetChannelTotal(m_Adam5000Type) + DigitalOutput.GetChannelTotal(m_Adam5000Type); txtModule.Text = m_Adam5000Type.ToString(); }
public FormMemoryRecord(ref AdamCom adamCom, ref ListView listView, int i_iAddr, string i_szTitle, int i_ParentWidth, int i_ParentHeight) { InitializeComponent(); this.Location = new Point((i_ParentWidth - this.Width) / 2, (i_ParentHeight - this.Height) / 2); this.adamCom = adamCom; m_iAddr = i_iAddr; this.Text = i_szTitle; m_listView = listView; }
public Form1() { InitializeComponent(); m_iCom = 4; // using COM4 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4021; // the sample is for ADAM-4021 adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum txtModule.Text = m_Adam4000Type.ToString(); }
public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // int iIdx, iPos, iStart; m_bStart = false; // the action stops at the beginning m_bRegister = true; // set to true to read the register, otherwise, read the coil m_iCom = 3; // host COM port number m_iAddr = 3; // modbus slave address m_iStart = 1; // modbus starting address m_iLength = 8; // modbus reading length adamCom = new AdamCom(m_iCom); // fill the ListView if (m_bRegister) // The initial register list { iStart = 40000 + m_iStart; // The register starting position (4X references) for (iIdx = 0; iIdx < m_iLength; iIdx++) { iPos = iStart + iIdx; listViewModbusCur.Items.Add(new ListViewItem(iPos.ToString())); listViewModbusCur.Items[iIdx].SubItems.Add("Word"); listViewModbusCur.Items[iIdx].SubItems.Add("*****"); listViewModbusCur.Items[iIdx].SubItems.Add("****"); } } else // The initial coil list { iStart = m_iStart; // The coil starting position (0X references) for (iIdx = 0; iIdx < m_iLength; iIdx++) { iPos = iStart + iIdx; listViewModbusCur.Items.Add(new ListViewItem(iPos.ToString("00000"))); listViewModbusCur.Items[iIdx].SubItems.Add("Bit"); listViewModbusCur.Items[iIdx].SubItems.Add("*****"); listViewModbusCur.Items[iIdx].SubItems.Add("****"); } } }
public Form1() { InitializeComponent(); m_iCom = 4; // using COM1 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4018M; // the sample is for ADAM-4018M m_iChTotal = AnalogInput.GetChannelTotal(m_Adam4000Type); m_bCh = new bool[m_iChTotal]; adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum txtModule.Text = m_Adam4000Type.ToString(); }
public Form1() { InitializeComponent(); m_iCom = 4; // using COM4 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_AsciiProtocol = true; // the protocol is Advantech ASCII m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4022T; // the sample is for ADAM-4022T adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum txtModule.Text = m_Adam4000Type.ToString(); m_pv1LblHigh = new float[2]; m_pv1LblLow = new float[2]; m_pv2LblHigh = new float[2]; m_pv2LblLow = new float[2]; m_dVals = new float[3]; // for SV, PV, MV }
public VoltageController(VM_MSConfig msConfig) { Config = msConfig; m_iCom = 3; // using COM4 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4019P; // the sample is for ADAM-4019P m_iChTotal = AnalogInput.GetChannelTotal(m_Adam4000Type); m_byRange = new byte[m_iChTotal]; adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum Module = m_Adam4000Type.ToString(); if (adamCom.OpenComPort()) { // set COM port state, 9600,N,8,1 adamCom.SetComPortState(Baudrate.Baud_9600, Databits.Eight, Parity.None, Stopbits.One); // set COM port timeout adamCom.SetComPortTimeout(500, 500, 0, 500, 0); m_iCount = 0; // reset the reading counter // get module config if (!adamCom.Configuration(m_iAddr).GetModuleConfig(out m_adamConfig)) { adamCom.CloseComPort(); LogHelper.WriteErrorLog("Failed to get module config!"); return; } // RefreshChannelEnable(); RefreshChannelRange(); // m_bStart = true; // starting flag } else { LogHelper.WriteErrorLog("Failed to open COM port!"); } }
private void buttonStart_Click(object sender, EventArgs e) { Socket svrSocket; if (buttonStart.Text == "Start") { m_com = new AdamCom(2); m_com.Checksum = false; // set the checksum disbale, if the checksum must be applied, set it to true m_com.SetComPortState(Baudrate.Baud_9600, Databits.Eight, Parity.None, Stopbits.One); // 9600, N, 8, 1 m_com.SetComPortTimeout(m_SerialTimeout, m_SerialTimeout, 0, m_SerialTimeout, 0); if (!m_com.OpenComPort()) { MessageBox.Show("Failed to open COM!", "Error"); return; } m_SvrSocket = new UDPSocketServer(); m_SvrSocket.Create(m_ListenPort); svrSocket = m_SvrSocket.ServerSocket(); m_SvrStream = new SocketStream(ref svrSocket, m_UDPSendTimeout, m_UDPRecvTimeout); buttonStart.Text = "Stop"; m_UDPRecv = 0; m_UDPSent = 0; m_SerialSent = 0; m_SerialRecv = 0; textBoxUDPRecv.Text = m_UDPRecv.ToString(); textBoxUDPSent.Text = m_UDPSent.ToString(); textBoxSerialSent.Text = m_SerialSent.ToString(); textBoxSerialRecv.Text = m_SerialRecv.ToString(); timer1.Enabled = true; } else { timer1.Enabled = false; m_SvrSocket.Terminate(); m_com.CloseComPort(); buttonStart.Text = "Start"; } }
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(); }
public Form1() { InitializeComponent(); m_iCom = 4; // using COM4 m_iAddr = 19; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_DOStatus = new bool[2]; m_bStart = false; m_Adam4000Type = Adam4000Type.Adam4011; // the sample is for ADAM-4011 //m_Adam4000Type = Adam4000Type.Adam4011D; // the sample is for ADAM-4011D //m_Adam4000Type = Adam4000Type.Adam4012; // the sample is for ADAM-4012 //m_Adam4000Type = Adam4000Type.Adam4013; // the sample is for ADAM-4013 adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disable checksum txtModule.Text = m_Adam4000Type.ToString(); if (m_Adam4000Type == Adam4000Type.Adam4013) { panelEvent.Visible = false; panelAlarm.Visible = false; } }
public void Open() { adamCom = new AdamCom(SerialPortNumber); adamCom.Checksum = Checksum; bool opened = false; try { if (!adamCom.IsOpen) { opened = adamCom.OpenComPort(); } if (!opened) { return; } // set COM port state, 9600,N,8,1 adamCom.SetComPortState(Baudrate.Baud_9600, Databits.Eight, Parity.None, Stopbits.One, FlowControl.None); // set COM port timeout adamCom.SetComPortTimeout(500, 1000, 0, 1000, 0); if (!adamCom.Configuration(address).GetModuleConfig(out config)) { opened = false; adamCom.CloseComPort(); return; } } finally { Opened = opened; } }
public Form1() { InitializeComponent(); m_iCom = 4; // using COM4 m_iAddr = 1; // the slave address is 1 m_iCount = 0; // the counting start from 0 m_bStart = false; //m_Adam4000Type = Adam4000Type.Adam4050; // the sample is for ADAM-4050 //m_Adam4000Type = Adam4000Type.Adam4051; // the sample is for ADAM-4051 //m_Adam4000Type = Adam4000Type.Adam4052; // the sample is for ADAM-4052 //m_Adam4000Type = Adam4000Type.Adam4053; // the sample is for ADAM-4053 m_Adam4000Type = Adam4000Type.Adam4055; // the sample is for ADAM-4055 //m_Adam4000Type = Adam4000Type.Adam4056S; // the sample is for ADAM-4056S //m_Adam4000Type = Adam4000Type.Adam4056SO; // the sample is for ADAM-4056SO //m_Adam4000Type = Adam4000Type.Adam4060; // the sample is for ADAM-4060 //m_Adam4000Type = Adam4000Type.Adam4068; // the sample is for ADAM-4068 //m_Adam4000Type = Adam4000Type.Adam4069; // the sample is for ADAM-4069 m_iDITotal = DigitalInput.GetChannelTotal(m_Adam4000Type); m_iDOTotal = DigitalOutput.GetChannelTotal(m_Adam4000Type); if (m_Adam4000Type == Adam4000Type.Adam4050) { InitAdam4050(); } else if (m_Adam4000Type == Adam4000Type.Adam4051) { InitAdam4051(); } else if (m_Adam4000Type == Adam4000Type.Adam4052) { InitAdam4052(); } else if (m_Adam4000Type == Adam4000Type.Adam4053) { InitAdam4053(); } else if (m_Adam4000Type == Adam4000Type.Adam4055) { InitAdam4055(); } else if (m_Adam4000Type == Adam4000Type.Adam4056S) { InitAdam4056S(); } else if (m_Adam4000Type == Adam4000Type.Adam4056SO) { InitAdam4056SO(); } else if (m_Adam4000Type == Adam4000Type.Adam4060) { InitAdam4060(); } else if (m_Adam4000Type == Adam4000Type.Adam4068) { InitAdam4068(); } else if (m_Adam4000Type == Adam4000Type.Adam4069) { InitAdam4069(); } adamCom = new AdamCom(m_iCom); adamCom.Checksum = false; // disbale checksum txtModule.Text = m_Adam4000Type.ToString(); }