Exemplo n.º 1
0
        private void cmdGO_Click(object sender, EventArgs e)
        {
            RESTClient rClient = new RESTClient();

            rClient.endPoint = txtRequestURI.Text;
            debugOutput("RESTClient Object created.");

            string strJSON = string.Empty;

            strJSON = rClient.makeRequest();

            debugOutput(strJSON);
        }
Exemplo n.º 2
0
        private void cmdGO_Click(object sender, EventArgs e)
        {
            string strJSON = string.Empty;

            if (!CBMirConnection.Checked)
            {
                RESTClient rClient = new RESTClient();
                rClient.endPoint = txtRequestURI.Text;
                debugOutput("RESTClient Object created.");

                strJSON = rClient.makeRequest();
            }
            else
            {
                RESTClient rClient = new RESTClient();

                rClient.endPoint = "http://www.mir.com/api/v2.0.0/registers/1";

                debugOutput("RESTClient Object created.");
                int iA, iB;
                if (int.TryParse(tbID.Text, out iA) && int.TryParse(tbValue.Text, out iB))
                {
                    strJSON = rClient.makeRequestMir(iB);
                }
                else
                {
                    // Initializes the variables to pass to the MessageBox.Show method.
                    string            message = "Please insert both Numbers";
                    string            caption = "Error";
                    MessageBoxButtons buttons = MessageBoxButtons.OK;
                    DialogResult      result;

                    // Displays the MessageBox.
                    result = MessageBox.Show(message, caption, buttons);
                    //if (result == System.Windows.Forms.DialogResult.Yes)
                    //{
                    //    // Closes the parent form.
                    //    this.Close();
                    //}
                }
            }


            debugOutput(strJSON);
        }
Exemplo n.º 3
0
        private void OnNotification(object sender, AdsNotificationEventArgs e)
        {
            int    f = 0;
            string sID;

            if (e.NotificationHandle == hConnect[0])
            {
                f = binRead.ReadInt32();
            }

            RESTClient rClient = new RESTClient();

            sID = "http://www.mir.com/api/v2.0.0/registers/xx";
            sID = sID.Replace("xx", m_sVariableNumber);
            rClient.endPoint = sID;

            rClient.makeRequestMir(f);
        }
Exemplo n.º 4
0
        public static void Method(object obj)
        {
            ADSWriteInterface Interface = new ADSWriteInterface();

            while (true)
            {
                List <cMirRegister> RegisterList;

                string sRequest;

                RESTClient rClient = new RESTClient();

                rClient.endPoint = "http://www.mir.com/api/v2.0.0/registers";


                sRequest = rClient.makeRequestMiRReg();
                try
                {
                    RegisterList = JsonConvert.DeserializeObject <List <cMirRegister> >(sRequest);


                    for (int i = 10; i < 20; i++) // Nur die Register ab 11-20 werden von dem MHS and die PLC geschickt (1-10 von PLC zu MHS)
                    {
                        int iValue;
                        int.TryParse(RegisterList[i].value, out iValue);
                        string sName = "MAIN.fbMHS.aMHS[x]";
                        sName = sName.Replace("x", RegisterList[i].id);


                        Interface.writeToPLC(sName, iValue);
                    }
                }
                catch (Exception e)
                {
                    // ThFe
                }
                // ADS Übertragung der Register


                Thread.Sleep(1000);
            }
        }