예제 #1
0
        private void WriteData(CancellationToken cancelToken)
        {
            foreach (var vals in _dataQueue.GetConsumingEnumerable(cancelToken))
            {
                _logger.InfoFormat("WRITTING {0} values", vals.Data.Count);
                var insertMode = AFUpdateOption.InsertNoCompression;

                if (vals.IsBackFillData)
                {
                    insertMode = AFUpdateOption.Insert;
                }

                //foreach (var val in vals.Data)
                //{
                //    _logger.DebugFormat("writing {0} at {1}", val.Value,val.Timestamp);
                //}



                // sorting values before writing
                vals.Data.Sort();

                var errors = _server.UpdateValues(vals.Data, insertMode, AFBufferOption.BufferIfPossible);

                if (errors != null && errors.HasErrors)
                {
                    _logger.Error(errors.Errors);
                    _logger.Error(errors.PIServerErrors);
                }
            }
        }
예제 #2
0
        public void Run()
        {
            PIServers piServers = new PIServers();
            PIServer  piServer  = piServers["<PISERVER>"];

            IList <PIPoint> points = PIPoint.FindPIPoints(piServer, new[] { "sample_floatpoint", "sample_digitalpoint" });

            PIPoint floatingPIPoint = points[0];
            PIPoint digitalPIPoint  = points[1];

            AFEnumerationSet digSet = piServer.StateSets["Modes"];

            IList <AFValue> valuesToWrite = new List <AFValue>();

            for (int i = 0; i < 10; i++)
            {
                AFTime time = new AFTime(new DateTime(2015, 1, 1, i, 0, 0, DateTimeKind.Local));

                AFValue afValueFloat = new AFValue(i, time);
                // Associate the AFValue to a PI Point so we know where to write to.
                afValueFloat.PIPoint = floatingPIPoint;

                AFEnumerationValue digSetValue    = i % 2 == 0 ? digSet["Auto"] : digSet["Manual"];
                AFValue            afValueDigital = new AFValue(digSetValue, time);
                afValueDigital.PIPoint = digitalPIPoint;

                valuesToWrite.Add(afValueFloat);
                valuesToWrite.Add(afValueDigital);
            }

            // Perform a bulk write. Use a single local call to PI Buffer Subsystem if possible.
            // Otherwise, make a single call to the PI Data Archive.
            // We use no compression just so we can check all the values are written.
            piServer.UpdateValues(valuesToWrite, AFUpdateOption.InsertNoCompression, AFBufferOption.BufferIfPossible);
        }
예제 #3
0
        public static void SaveOutputDataInPi(Outputs UnitOutputTags, IList <PIPoint> points, eRCM_KernelControl objACIkernal, Service unit)
        {
            IList <AFValue> valuesToWrite = new List <AFValue>();
            List <Tag>      lstTagResult  = new List <Tag>();
            var             LoadArray     = objACIkernal.LoadArray(unit.LoadStep);
            //Load Step
            object IdealLS        = UnitOutputTags.LoadStep.Ideal.Value;
            object IdealLSDetails = UnitOutputTags.LoadStep.IdealDetails.Value;
            var    loadStep       = LoadSteps.GetLoadSteps(objACIkernal, UnitOutputTags.LoadStep);

            //lstTagResult.Add(loadStep.Current);
            //lstTagResult.Add(loadStep.CurrentDetails);
            //lstTagResult.Add(loadStep.Ideal);
            //lstTagResult.Add(loadStep.IdealDetails);
            lstTagResult.Add(loadStep.NextDown);
            lstTagResult.Add(loadStep.NextUp);
            //Load Prediction
            //var loadPredictionResult = LoadPrediction.GetLoadPrediction(objACIkernal, UnitOutputTags.LoadPrediction);
            //lstTagResult.Add(loadPredictionResult.Current);
            //lstTagResult.Add(loadPredictionResult.Ideal);
            //Flow Prediction
            //var flowPredictionResult = FlowPrediction.GetFlowPrediction(objACIkernal, UnitOutputTags.FlowPrediction);
            //lstTagResult.Add(flowPredictionResult.Current);
            //lstTagResult.Add(flowPredictionResult.Ideal);
            //Meachinical Efficiency
            UnitOutputTags.MechanicalEfficiency.Value = objACIkernal.MechanicalEfficiency;
            lstTagResult.Add(UnitOutputTags.MechanicalEfficiency);
            //Current Torque
            UnitOutputTags.CurrentTorque.Value = objACIkernal.CurrentTorque;
            lstTagResult.Add(UnitOutputTags.CurrentTorque);
            //Max Load
            UnitOutputTags.MaxLoad.Value = objACIkernal.MaxAllowedLoad;
            lstTagResult.Add(UnitOutputTags.MaxLoad);
            //ErroCode objERCM.FullEnglishErrors(objERCM.ErrorArray(objERCM.CurrentLoadStep), 0)
            //UnitOutputTags.ErrorCode.Value = objACIkernal.FullEnglishErrors(objACIkernal.ErrorArray(objACIkernal.CurrentLoadStep), 0);
            //UnitOutputTags.ErrorCode.Value = objACIkernal.ErrorArray(objACIkernal.CurrentLoadStep);
            //lstTagResult.Add(UnitOutputTags.ErrorCode);
            //Rated Load
            UnitOutputTags.RatedLoad.Value = objACIkernal.RatedLoad;
            lstTagResult.Add(UnitOutputTags.RatedLoad);
            //Rated Speed
            UnitOutputTags.RatedSpeed.Value = objACIkernal.RatedSpeed;
            lstTagResult.Add(UnitOutputTags.RatedSpeed);
            //Min Load/Flow Change Allowed
            UnitOutputTags.MinChangeAllowed.Value = objACIkernal.MinLoadFlowChangeAllowed;
            lstTagResult.Add(UnitOutputTags.MinChangeAllowed);
            //Max Load Change Allowed
            UnitOutputTags.MaxChangeAllowed.Value = objACIkernal.MaxLoadChangeAllowed;
            lstTagResult.Add(UnitOutputTags.MaxChangeAllowed);
            //Min Speed
            UnitOutputTags.MinSpeed.Value = objACIkernal.MinSpeedCurrentLS();
            lstTagResult.Add(UnitOutputTags.MinSpeed);
            //Max Speed
            UnitOutputTags.MaxSpeed.Value = objACIkernal.MaxSpeedCurrentLS();
            lstTagResult.Add(UnitOutputTags.MaxSpeed);
            //Stage Info
            var stageInfoResult = StageInfo.GetStageInfoList(objACIkernal, UnitOutputTags.StageInfo, unit);

            foreach (var stage in stageInfoResult)
            {
                // Trace.WriteLine("StageNumber:" + stage.StageNumber);
                lstTagResult.Add(stage.CompressionRatio);
                lstTagResult.Add(stage.DischargePressureAtFlange);
                lstTagResult.Add(stage.DischargePressureAtGadge);
                lstTagResult.Add(stage.DischargeTemperature);
                lstTagResult.Add(stage.Load);
                lstTagResult.Add(stage.RatioActualVsTheoriticalPressure);
                lstTagResult.Add(stage.RatioActualVsTheoriticalTemperature);
            }
            //Load Balance
            var lbResult = LoadBalance.GetLoadBalance(objACIkernal, UnitOutputTags.LoadBalance);

            foreach (var stage in lbResult)
            {
                // Trace.WriteLine("StageNumber:" + stage.Stages);
                lstTagResult.Add(stage.Ratio);
            }
            //Head End Info
            var headEndResult = HeadEndInfo.GetHeadEndInfo(objACIkernal, UnitOutputTags.HeadEndInfo);

            foreach (var headEndCylinder in headEndResult)
            {
                lstTagResult.Add(headEndCylinder.DischargeVE);
                lstTagResult.Add(headEndCylinder.Flow);
                lstTagResult.Add(headEndCylinder.Load);
                lstTagResult.Add(headEndCylinder.SuctionVE);
            }
            //Crank End
            var crankEndResult = CrankEndInfo.GetHeadEndInfo(objACIkernal, UnitOutputTags.CrankEndInfo);

            foreach (var crankEndCylinder in crankEndResult)
            {
                lstTagResult.Add(crankEndCylinder.DischargeVE);
                lstTagResult.Add(crankEndCylinder.Flow);
                lstTagResult.Add(crankEndCylinder.Load);
                lstTagResult.Add(crankEndCylinder.SuctionVE);
                lstTagResult.Add(crankEndCylinder.EstimatedDischargeTemperature);
            }
            //Compression Forces
            var compForcesResults = CompressionForces.GetCompressionForces(objACIkernal, UnitOutputTags.CompressionForces);

            foreach (var throws in compForcesResults)
            {
                lstTagResult.Add(throws.Force);
            }
            //Tension Forces
            var tensForcesResults = TensionForces.GetTensionForces(objACIkernal, UnitOutputTags.TensionForces);

            foreach (var throws in tensForcesResults)
            {
                lstTagResult.Add(throws.Force);
            }
            //Fuel Rate
            //var fuelRatesResult = FuelRates.GetFuelRates(objACIkernal, UnitOutputTags.FuelRate, unit);
            //lstTagResult.Add(fuelRatesResult.Current);
            //lstTagResult.Add(fuelRatesResult.Ideal);
            lstTagResult.Add(UnitOutputTags.MaxAllowedDischargePressure);
            lstTagResult.Add(UnitOutputTags.IdealFlow90T);
            lstTagResult.Add(UnitOutputTags.IdealFuelRate90T);
            lstTagResult.Add(UnitOutputTags.IdealLoad90T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStep90T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStepDetail90T);
            lstTagResult.Add(UnitOutputTags.IdealFlow95T);
            lstTagResult.Add(UnitOutputTags.IdealFuelRate95T);
            lstTagResult.Add(UnitOutputTags.IdealLoad95T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStep95T);
            lstTagResult.Add(UnitOutputTags.IdealLoadStepDetail95T);
            UnitOutputTags.LoadStep.Ideal.Value = IdealLS;
            lstTagResult.Add(UnitOutputTags.LoadStep.Ideal);
            UnitOutputTags.LoadStep.IdealDetails.Value = IdealLSDetails;
            lstTagResult.Add(UnitOutputTags.LoadStep.IdealDetails);
            lstTagResult.Add(UnitOutputTags.LoadPrediction.Ideal);
            lstTagResult.Add(UnitOutputTags.FlowPrediction.Ideal);
            lstTagResult.Add(UnitOutputTags.FuelRate.Ideal);
            lstTagResult.Add(UnitOutputTags.LoadStep.Current);
            lstTagResult.Add(UnitOutputTags.LoadStep.CurrentDetails);
            lstTagResult.Add(UnitOutputTags.LoadPrediction.Current);
            lstTagResult.Add(UnitOutputTags.FlowPrediction.Current);
            lstTagResult.Add(UnitOutputTags.FuelRate.Current);
            lstTagResult.Add(UnitOutputTags.ErrorCode);

            foreach (var pipoint in points)
            {
                var     tagValue     = lstTagResult.Where(x => x.Name == pipoint.Name).Select(x => x.Value).FirstOrDefault();
                AFValue afValueFloat = new AFValue(tagValue, DateTime.Now)
                {
                    PIPoint = pipoint
                };
                valuesToWrite.Add(afValueFloat);
            }

            piServer.UpdateValues(valuesToWrite, AFUpdateOption.InsertNoCompression, AFBufferOption.BufferIfPossible);
            Console.WriteLine("Pi Values Added for " + unit.UnitName + " at" + DateTime.Now + " Successfully");
        }