public static PiConnectionMgr ConnectAndGetServer(string server, out PIServer piServer)
        {
            var manager=new PiConnectionMgr(server);
            manager.Connect();
            piServer = manager.GetPiServer();

            return manager;
        }
Ejemplo n.º 2
0
        public static PiConnectionMgr ConnectAndGetServer(string server, out PIServer piServer)
        {
            var manager = new PiConnectionMgr(server);

            manager.Connect();
            piServer = manager.GetPiServer();

            return(manager);
        }
Ejemplo n.º 3
0
        public override void Run()
        {
            try
            {
                PiConnectionMgr piConnectionMgr = new PiConnectionMgr(Server);
                piConnectionMgr.Connect();

                PIServer pi = piConnectionMgr.GetPiServer();

                List<PIPoint> points = PIPoint.FindPIPoints(pi, NameFilter,SourceFilter).ToList();

                Logger.InfoFormat("{0} Tags Found",points.Count());
                Logger.Info(string.Join(",",points.Select(p=>p.Name)));

            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
        public override void Run()
        {
            try
            {
                PiConnectionMgr piConnectionMgr = new PiConnectionMgr(Server);
                piConnectionMgr.Connect();

                PIServer pi = piConnectionMgr.GetPiServer();

                PIPoint point = PIPoint.FindPIPoint(pi, Tag);
                AFValue value=point.CurrentValue();

                Logger.InfoFormat("The current value for PI Point {0} is : {1} - {2}", Tag,value.Timestamp,value.Value);

            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
        public override void Run()
        {
            try
            {
                PiConnectionMgr piConnectionMgr = new PiConnectionMgr(Server);
                piConnectionMgr.Connect();

                PIServer pi = piConnectionMgr.GetPiServer();

                PIPointList pointList = new PIPointList(PIPoint.FindPIPoints(pi, TagMask));

                AFListResults<PIPoint, AFValue> values = pointList.CurrentValue();

                foreach (AFValue val in values)
                {
                    Logger.InfoFormat("The current value for PI Point {0} is : {1} - {2}", val.PIPoint, val.Timestamp, val.Value);
                }

            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method deletes the data stored in specified tags of the PI Data Archive
        /// To delete data, it is required to first read the values that you want to delete, and then
        /// Call the update values method with the AFUpdateOption.Remove option
        /// <remarks>
        /// </remarks>
        /// </summary>
        private void DeleteData()
        {
            try
            {
                ValidateParameters();

                piConnectionMgr = new PiConnectionMgr(Server);
                piConnectionMgr.Connect();
                PIServer server = piConnectionMgr.GetPiServer();

                var timer = Stopwatch.StartNew();

                // Gets the tags and creates a point list with the tags, to prepare for bulk read call
                var points = PIPoint.FindPIPoints(server, TagList);
                var pointList = new PIPointList(points);
                Logger.InfoFormat("Initialized PI Points for deletion: {0}", string.Join(", ", points.Select(p => p.Name)));

                // converts strings to AFTime objects this will throw an error if invalid
                var startTime = new AFTime(StartTime);
                var endTime = new AFTime(EndTime);

                if (startTime > endTime)
                    throw new PIDeleteUtilInvalidParameterException("Start Time must be smaller than End Time");

                // defines the data eraser task that will work in parallel as the data querying task
                dataEraser = new DataProcessor(EraseData);
                var eraseTask = Task.Run(() => dataEraser.Run());

                // splits iterates the period, over
                foreach (var period in Library.Helpers.EachNDay(startTime, endTime, Days))
                {
                    Logger.InfoFormat("Getting tags information for period {0} to {1} ({2} Days chunk)", startTime, endTime,
                        Days);

                    // makes the first data call
                    var data = pointList.RecordedValues(period, AFBoundaryType.Inside, null, false,
                        new PIPagingConfiguration(PIPageType.TagCount, 100));

                    Logger.InfoFormat("Adding the data to the queue for deletion. ({0} to {1})", startTime, endTime);
                    // we push this data into the data processor queue so we can continue to query for the rest of the data.
                    dataEraser.DataQueue.Add(data);
                }

                dataEraser.DataQueue.CompleteAdding();
                    // // this will tell the data eraser that no more data will be added and allow it to complete

                eraseTask.Wait(); // waiting for the data processor to complete

                Logger.InfoFormat(
                    "Deletion process completed in {0} seconds.  With {1} events deleted (assuming there was no errors).",
                    Math.Round(timer.Elapsed.TotalSeconds, 0), dataEraser.TotalEventProcessed);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }