Пример #1
0
        public void Initialize(Adam4000Type type, int port, int address = 1, bool checksum = false)
        {
            this.AdamType         = type;
            this.SerialPortNumber = port;
            this.address          = address;
            this.Checksum         = checksum;

            this.DiNumber = DigitalInput.GetChannelTotal(type);
            this.DoNumber = DigitalOutput.GetChannelTotal(type);
        }
Пример #2
0
        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!");
            }
        }
Пример #3
0
        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();
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
        public Form1()
        {
            InitializeComponent();

            m_szIP   = "172.18.3.69";
            m_Port   = 1025;
            m_iAddr  = 2;       // 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();
            }
            adamSocket = new AdamSocket();

            txtModule.Text = m_Adam4000Type.ToString();
        }
Пример #6
0
 public AdamClient(Adam4000Type type, int port, int address = 1, bool checksum = false) : this()
 {
     Initialize(type, port, address, checksum);
 }