Beispiel #1
0
        //Method for creating OPC tags, this is done by reading opcTag.txt file located on the desktop, this file is generated by the DAtalogging app
        //Each line in the text file is a tag with commas sperating the parameters for the tag. It returns a array of type OPC.
        public static OPC[] creatOPCTags()
        {
            string path     = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string fileName = "opcTags.txt";
            string filePath = Path.Combine(path, fileName);

            OPC[] tagObj = new OPC[File.ReadAllLines(filePath).Length];
            try
            {
                using (StreamReader reader = new StreamReader(filePath))
                {
                    int    count = 0;
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] data    = line.Split(',');
                        int      tagID   = Convert.ToInt16(data[0]);
                        string   tagName = data[1].ToString();
                        string   ItemID  = data[2].ToString();
                        string   itemUrl = data[3].ToString();
                        tagObj[count] = new OPC(tagID, tagName, ItemID, itemUrl);
                        count++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(tagObj);
        }
Beispiel #2
0
 public frmLogging()
 {
     InitializeComponent();
     setUpFRM();
     testOPC = new OPC(Settings.Default.opcCheckURL);
     opcTags = opcHandler.creatOPCTags();
     tmrCheck.Start();
 }