Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        private ushort[] m_usRange; //for newer version
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Database.SetInitializer(new CpDashboardDatabaseInitializer());

            RouteTable.Routes.MapHttpRoute(
                name: "Alert",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = System.Web.Http.RouteParameter.Optional }
                );

            CpDashboardContext cont = new CpDashboardContext();

            cont.Database.Initialize(true);
            cont.Database.CreateIfNotExists();

            //set a timer
            //adam initializer
            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "192.168.10.10";            // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamUDP = new AdamSocket();
            adamUDP.SetTimeout(1000, 1000, 1000);    // set timeout for UDP

            m_Adam6000Type = Adam6000Type.Adam6015;  // the sample is for ADAM-6015

            adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp);
            if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion))
            {
                m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1));
            }
            adamUDP.Disconnect();

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            //txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled = new bool[m_iAiTotal];

            //firmware version
            //fwversion.Text = m_DeviceFwVer.ToString();

            if (m_DeviceFwVer > m_Adam6000NewerFwVer)
            {
                m_usRange = new ushort[m_iAiTotal];
            }

            if (cont.Database.Exists())
            {
                // start the retrieving datas and save to db;
                startSending();
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        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
            }
        }
Ejemplo n.º 6
0
 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]);
     }
 }
Ejemplo n.º 7
0
        public AdamRetriever(int sensorNum)
        {
            sensorStatus = "false";
            sensorNumber = sensorNum;
            m_bStart     = false;                    // the action stops at the beginning
            m_szIP       = "192.168.10.10";          // modbus slave IP address
            m_iPort      = 502;                      // modbus TCP port is 502
            adamModbus   = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamUDP = new AdamSocket();
            adamUDP.SetTimeout(1000, 1000, 1000);    // set timeout for UDP

            m_Adam6000Type = Adam6000Type.Adam6015;  // the sample is for ADAM-6015

            adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp);
            if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion))
            {
                m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1));
            }
            adamUDP.Disconnect();

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            //txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled = new bool[m_iAiTotal];

            //firmware version
            //fwversion.Text = m_DeviceFwVer.ToString();

            if (m_DeviceFwVer > m_Adam6000NewerFwVer)
            {
                m_usRange = new ushort[m_iAiTotal];
            }

            // start the retrieving datas and save to db;
            startRetrieving();
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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
            }
        }
Ejemplo n.º 10
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();
        }
Ejemplo n.º 11
0
        private ushort[] m_usRange; //for newer version

        public Form1()
        {
            InitializeComponent();

            m_bStart   = false;                      // the action stops at the beginning
            m_szIP     = "172.18.3.222";             // modbus slave IP address
            m_iPort    = 502;                        // modbus TCP port is 502
            adamModbus = new AdamSocket();
            adamModbus.SetTimeout(1000, 1000, 1000); // set timeout for TCP
            adamUDP = new AdamSocket();
            adamUDP.SetTimeout(1000, 1000, 1000);    // set timeout for UDP

            m_Adam6000Type = Adam6000Type.Adam6015;  // the sample is for ADAM-6015
            //m_Adam6000Type = Adam6000Type.Adam6017; // the sample is for ADAM-6017
            //m_Adam6000Type = Adam6000Type.Adam6018; // the sample is for ADAM-6018

            adamUDP.Connect(AdamType.Adam6000, m_szIP, ProtocolType.Udp);
            if (adamUDP.Configuration().GetFirmwareVer(out m_szFwVersion))
            {
                m_DeviceFwVer = int.Parse(m_szFwVersion.Trim().Substring(0, 1));
            }
            adamUDP.Disconnect();

            m_iAiTotal = AnalogInput.GetChannelTotal(m_Adam6000Type);
            m_iDoTotal = DigitalOutput.GetChannelTotal(m_Adam6000Type);

            txtModule.Text = m_Adam6000Type.ToString();
            m_bChEnabled   = new bool[m_iAiTotal];

            if (m_DeviceFwVer < m_Adam6000NewerFwVer)
            {
                m_byRange = new byte[m_iAiTotal];
            }
            else
            {
                //for newer version Adam6017
                m_usRange = new ushort[m_iAiTotal];
            }

            // arrange channel text box

            if (m_Adam6000Type == Adam6000Type.Adam6015)
            {
                // Channel
                chkboxCh7.Visible   = false;
                txtAIValue7.Visible = false;
                // DO
                panelDO.Visible = false;
            }
            else if (m_Adam6000Type == Adam6000Type.Adam6017)
            {
                // DO
                btnCh2.Visible = false;
                txtCh2.Visible = false;
                btnCh3.Visible = false;
                txtCh3.Visible = false;
                btnCh4.Visible = false;
                txtCh4.Visible = false;
                btnCh5.Visible = false;
                txtCh5.Visible = false;
                btnCh6.Visible = false;
                txtCh6.Visible = false;
                btnCh7.Visible = false;
                txtCh7.Visible = false;
            }
            else  //Adam6018
            {
                ;
            }
        }