Beispiel #1
0
 public void RefreshFromEvents(OPCController opcgroup)
 {
     for (int opcIndex = 1; opcIndex < opcgroup.TotalItemNumber + 1; opcIndex++)
     {
         string tag   = opcgroup.GetTagName(opcIndex);
         int    index = SearchTag(tag);
         if (index > -1)
         {
             InternalTag dt = Values[index];
             if (Convert.ToInt32(dt.LastValue) != Convert.ToInt32(dt.Value))
             {
                 dt.LastValue   = dt.Value;
                 dt.Activated   = Convert.ToInt32(dt.Value) > 0;
                 dt.Deactivated = !dt.Activated;
             }
             else
             {
                 if (dt.Activated)
                 {
                     dt.LastValue   = 0;
                     dt.Value       = 0;
                     dt.Activated   = false;
                     dt.Deactivated = true;
                 }
                 else
                 {
                     dt.Deactivated = false;
                 }
             }
             Values[index] = dt;
         }
     }
 }
Beispiel #2
0
        /*It creates all the items, for each group of where (group by OPCName)*/
        private bool CreateItemsFromSelect(string sqlquery, ref OPCController opcgroup)
        {
            Logging log = new Logging(sqlquery);

            try
            {
                using (SqlConnection connection = new SqlConnection(IntData.CfgConn))
                {
                    connection.Open();
                    SqlCommand    cmd = new SqlCommand(sqlquery, connection);
                    SqlDataReader sdr = cmd.ExecuteReader();
                    while (sdr.Read())
                    {
                        string Tag         = "";
                        string Register    = "";
                        string Description = "";
                        string PLCName     = "";
                        for (int i = 0; i < sdr.FieldCount; i++)
                        {
                            switch (sdr.GetName(i))
                            {
                            case "Tag": Tag = sdr[i].ToString().Trim(); break;

                            case "Register": Register = sdr[i].ToString().Trim(); break;

                            case "Description": Description = sdr[i].ToString().Trim(); break;

                            case "PLCName": PLCName = sdr[i].ToString().Trim(); break;
                            }
                        }
                        opcgroup.AddItem(Tag, Register, Description, PLCName);
                    }
                    if (opcgroup.ServerName.Length > 1)
                    {
                        opcgroup.Create();
                    }
                    sdr.Close();
                }
                log.Success();
                return(true);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                return(false);
            }
        }
Beispiel #3
0
 public void RefreshFromGroup(OPCController opcgroup)
 {
     for (int index = 1; index < opcgroup.TotalItemNumber + 1; index++)
     {
         for (int i = 0; i < Values.Count; i++)
         {
             InternalTag dt = Values[i];
             if (dt.Tag == opcgroup.GetTagName(index))
             {
                 dt.Value       = opcgroup.GetTagValue(dt.Tag);
                 dt.Activated   = opcgroup.Activated(dt.Tag);
                 dt.Deactivated = opcgroup.Deactivated(dt.Tag);
             }
             Values[i] = dt;
         }
     }
 }