Example #1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     try
     {
         this.result = this.Client.DBRead(10, 38, 10, this.db1Buffer);
     }
     catch (Exception ex)
     {
         int num = (int)MessageBox.Show(ex.Message);
         this.result = -1;
     }
     if ((uint)this.result > 0U)
     {
         this.ShowResult(this.result);
     }
     try
     {
         //  Setta la word del DB10 all'int che ha il PLC(?)
         //  dbBuffer = Array di byte
         this.db10.Word01 = S7.GetIntAt(this.db1Buffer, 0);
         this.db10.Word02 = S7.GetIntAt(this.db1Buffer, 2);
         this.db10.Word03 = S7.GetIntAt(this.db1Buffer, 4);
         this.db10.Word04 = S7.GetIntAt(this.db1Buffer, 6);
         this.db10.Word05 = S7.GetIntAt(this.db1Buffer, 8);
         //  Setta i vari label/etc... dell'UI
         Label  lblValore01 = this.lblValore01;
         short  num         = this.db10.Word01;
         string str1        = num.ToString();
         lblValore01.Text = str1;
         Label lblValore02 = this.lblValore02;
         num = this.db10.Word02;
         string str2 = num.ToString();
         lblValore02.Text = str2;
         Label lblValore03 = this.lblValore03;
         num = this.db10.Word03;
         string str3 = num.ToString();
         lblValore03.Text = str3;
         Label lblValore04 = this.lblValore04;
         num = this.db10.Word04;
         string str4 = num.ToString();
         lblValore04.Text = str4;
         Label lblValore05 = this.lblValore05;
         num = this.db10.Word05;
         string str5 = num.ToString();
         lblValore05.Text = str5;
         //  Scrive il db10 nel file XML, noi prob. dovremmo usare il DBSQL
         CSerialDeserial.WriteFile(this.db10);
     }
     catch (Exception ex)
     {
         int num = (int)MessageBox.Show(ex.Message);
         this.result = -1;
     }
 }
Example #2
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //  Legge il file XML, noi prob. dovremmo leggere dal DBSQL
            CSerialDeserial.ReadFile(ref this.db30);
            //  Penso che questo db3 sia di appoggio
            //  Non ho capito perchè ha fatto un nuovo buffer
            //  TODO: Capire perchè
            this.db3Buffer = new byte[10];
            S7.SetIntAt(this.db3Buffer, 0, this.db30.Word01);
            S7.SetIntAt(this.db3Buffer, 2, this.db30.Word02);
            S7.SetIntAt(this.db3Buffer, 4, this.db30.Word03);
            S7.SetIntAt(this.db3Buffer, 6, this.db30.Word04);
            S7.SetIntAt(this.db3Buffer, 8, this.db30.Word05);
            //  Scrive nel DB del PLC
            this.result = this.Client.DBWrite(30, 18, this.db3Buffer.Length, this.db3Buffer);
            //  Visualizza i risultati nell'UI
            if ((uint)this.result > 0U)
            {
                this.ShowResult(this.result);
            }
            this.lblValore31.Text = this.db30.Word01.ToString();
            Label  lblValore32 = this.lblValore32;
            short  num         = this.db30.Word02;
            string str1        = num.ToString();

            lblValore32.Text = str1;
            Label lblValore33 = this.lblValore33;

            num = this.db30.Word03;
            string str2 = num.ToString();

            lblValore33.Text = str2;
            Label lblValore34 = this.lblValore34;

            num = this.db30.Word04;
            string str3 = num.ToString();

            lblValore34.Text = str3;
            Label lblValore35 = this.lblValore35;

            num = this.db30.Word05;
            string str4 = num.ToString();

            lblValore35.Text = str4;
        }