Example #1
0
        public static CurrentOutputAtGivenLoadStep GetCurrentOutputAtGivenLoadStep(int CurrentLoadStep, AciModelInputs objAciInput, eRCM_KernelControl objACIkernal)
        {
            CurrentOutputAtGivenLoadStep resCurrentOutput = new CurrentOutputAtGivenLoadStep();

            objACIkernal.CurrentLoadStep = CurrentLoadStep;
            objACIkernal.ChangeOpCondition(objAciInput.PsG, objAciInput.PdG, objAciInput.Rpm,
                                           objAciInput.Ts1, objAciInput.Ts2, objAciInput.Ts3, objAciInput.Ts4, objAciInput.Ts5, objAciInput.Ts6);
            //Ideal Load Step
            resCurrentOutput.CurrentLoadStep       = CurrentLoadStep;
            resCurrentOutput.CurrentLoadStepDetail = objACIkernal.LoadStepName(CurrentLoadStep);
            resCurrentOutput.CurrentLoad           = objACIkernal.LoadArray(CurrentLoadStep);
            resCurrentOutput.CurrentFlow           = objACIkernal.FlowArray(CurrentLoadStep);
            resCurrentOutput.CurrentFuelRate       = objACIkernal.EngineDataFuelRate();
            return(resCurrentOutput);
        }
Example #2
0
        public static void GetACIOutput(Service unit, string ViewerFilePath)
        {
            PISystems  piSystems = new PISystems();
            PISystem   piSystem;
            AFDatabase database;

            string error  = "";
            string error1 = "";

            Outputs objOutputUnit = null;
            CurrentOutputAtGivenLoadStep resCurrentOutputs = null;
            IdealOutputAtGivenTorque     resIdealOtpsAt90T = null, resIdealOtpsAt95T = null, resIdealOtpsAt100T = null;

            IList <PIPoint> lstPiPointForUnit = null;
            AFNamedCollectionList <AFElement> AllElements = new AFNamedCollectionList <AFElement>();
            AFValue floatingValue             = null;

            AFElement   Model          = new AFElement();
            AFAttribute ErrorArrayCode = null;

            try
            {
                piSystem = piSystems["WINOSIT3D01"];
                database = piSystem.Databases["DCPDev"];

                if (File.Exists(ViewerFilePath))
                {
                    // Trace.Write(unit.UnitName + "   :"); Trace.WriteLine(ViewerFilePath);

                    var objERCM = objERCMKernal;
                    objERCM.Reset();
                    objERCM.eRCMViewerFilename = ViewerFilePath;
                    AciModelInputs objAciInput = new AciModelInputs(unit);
                    if (objERCM.SuccessfulFileLoad)
                    {
                        if (!string.IsNullOrEmpty(objAciInput.ErrorMsg))
                        {
                            Trace.TraceError("Valid Input data not available for " + unit.UnitName + " at" + DateTime.Now);
                            return;
                        }

                        objOutputUnit = GetACIOutputObjectForUnit(unit.UnitName, unit.ServiceName);

                        if (objAciInput.Rpm < 100)
                        {
                            error1 = " RPM is less than 100. Model wouold not run for " + unit.ServiceName + " " + unit.UnitName;
                            Console.WriteLine(error1);

                            AllElements = AFElement.FindElements(database, null, null, AFSearchField.Name, true, AFSortField.Name, AFSortOrder.Ascending, 1000000000);


                            foreach (AFElement ele in AllElements)
                            {
                                if (ele.Name.Equals(unit.UnitName) && ((ele.Parent != null && ele.Parent.Name.Equals(unit.ServiceName)) || (ele.Parent.Parent != null && ele.Parent.Parent.Name.Equals(unit.ServiceName))))
                                {
                                    Model          = ele.Elements["Model"];
                                    ErrorArrayCode = Model.Attributes["ACI Error Array Code"];

                                    floatingValue = new AFValue(error1);
                                    ErrorArrayCode.Data.UpdateValue(floatingValue, AFUpdateOption.NoReplace, AFBufferOption.DoNotBuffer);
                                }
                            }

                            return;
                        }

                        objERCM.CurrentLoadStep = unit.LoadStep;
                        resCurrentOutputs       = GetCurrentOutputAtGivenLoadStep(unit.LoadStep, objAciInput, objERCM);
                        resIdealOtpsAt90T       = GetIdealOutputAtGivenTorque(unit.LoadStep, 90, objAciInput, objERCM);
                        resIdealOtpsAt95T       = GetIdealOutputAtGivenTorque(unit.LoadStep, 95, objAciInput, objERCM);
                        resIdealOtpsAt100T      = GetIdealOutputAtGivenTorque(unit.LoadStep, 100, objAciInput, objERCM);

                        objERCM.TorqueLimit     = 100;
                        objERCM.CurrentLoadStep = unit.LoadStep;
                        objERCM.ChangeOpCondition(objAciInput.PsG, objAciInput.PdG, objAciInput.Rpm,
                                                  objAciInput.Ts1, objAciInput.Ts2, objAciInput.Ts3, objAciInput.Ts4, objAciInput.Ts5, objAciInput.Ts6);

                        string ACIInputValues = "PsG:" + objAciInput.PsG + " PdG:" + objAciInput.PdG + " Rpm:" + objAciInput.Rpm + " Ts1:" +
                                                objAciInput.Ts1 + " Ts2:" + objAciInput.Ts2 + " Ts3:" + objAciInput.Ts3 + " Ts4:" + objAciInput.Ts4 + " Ts5:" + objAciInput.Ts5 + " Ts6:" + objAciInput.Ts6;
                        Trace.TraceInformation(ACIInputValues);
                        //Max Allowed Dischage Pressure
                        var MaxAllowedPd = objERCM.CalcMaxAllowedPd(objAciInput.PsG, objAciInput.Rpm, objAciInput.Ts1, objAciInput.Ts2, objAciInput.Ts3, objAciInput.Ts4, objAciInput.Ts5, objAciInput.Ts6, unit.LoadStep);
                        objERCM.ErrorArray(objERCM.CurrentLoadStep);
                        error = objERCM.FullEnglishErrors(objERCM.ErrorArray(objERCM.CurrentLoadStep), 0);

                        if (error != string.Empty)
                        {
                            Trace.TraceInformation(ACIInputValues);
                            Trace.TraceError(error);
                        }
                        error = error + error1;

                        string CurrentTorq = objERCM.CurrentTorque.ToString();
                        //Output Result
                        //objOutputUnit = GetACIOutputObjectForUnit(unit.UnitName, unit.ServiceName);//at here Error Occurs!!!
                        //Assign Value to tags
                        lstPiPointForUnit = GetOutputTagList(objOutputUnit);
                        //Update in PI Server
                        // var result = SaveOutputDataInPi(objUnit, lstPiPointForUnit, objERCM);
                        objOutputUnit.MaxAllowedDischargePressure.Value = MaxAllowedPd;

                        //Current Operating Outputs
                        objOutputUnit.LoadStep.Current.Value        = resCurrentOutputs.CurrentLoadStep;
                        objOutputUnit.LoadStep.CurrentDetails.Value = resCurrentOutputs.CurrentLoadStepDetail;
                        objOutputUnit.LoadPrediction.Current.Value  = resCurrentOutputs.CurrentLoad;
                        objOutputUnit.FlowPrediction.Current.Value  = resCurrentOutputs.CurrentFlow;
                        objOutputUnit.FuelRate.Current.Value        = resCurrentOutputs.CurrentFuelRate;

                        //Ideal Outputs at 90% Torque
                        objOutputUnit.IdealFlow90T.Value           = resIdealOtpsAt90T.IdealFlowAtGivenTorque;
                        objOutputUnit.IdealFuelRate90T.Value       = resIdealOtpsAt90T.IdealFuelRateAtGivenTorque;
                        objOutputUnit.IdealLoad90T.Value           = resIdealOtpsAt90T.IdealLoadAtGivenTorque;
                        objOutputUnit.IdealLoadStep90T.Value       = resIdealOtpsAt90T.IdealLoadStepAtGivenTorque;
                        objOutputUnit.IdealLoadStepDetail90T.Value = resIdealOtpsAt90T.IdealLoadStepDetailAtGivenTorque;
                        //Ideal Outputs at 95% Torque
                        objOutputUnit.IdealFlow95T.Value           = resIdealOtpsAt95T.IdealFlowAtGivenTorque;
                        objOutputUnit.IdealFuelRate95T.Value       = resIdealOtpsAt95T.IdealFuelRateAtGivenTorque;
                        objOutputUnit.IdealLoad95T.Value           = resIdealOtpsAt95T.IdealLoadAtGivenTorque;
                        objOutputUnit.IdealLoadStep95T.Value       = resIdealOtpsAt95T.IdealLoadStepAtGivenTorque;
                        objOutputUnit.IdealLoadStepDetail95T.Value = resIdealOtpsAt95T.IdealLoadStepDetailAtGivenTorque;
                        //Ideal Outputs at 100% Torque
                        objOutputUnit.LoadStep.Ideal.Value        = resIdealOtpsAt100T.IdealLoadStepAtGivenTorque;
                        objOutputUnit.LoadStep.IdealDetails.Value = resIdealOtpsAt100T.IdealLoadStepDetailAtGivenTorque;
                        objOutputUnit.LoadPrediction.Ideal.Value  = resIdealOtpsAt100T.IdealLoadAtGivenTorque;
                        objOutputUnit.FlowPrediction.Ideal.Value  = resIdealOtpsAt100T.IdealFlowAtGivenTorque;
                        objOutputUnit.FuelRate.Ideal.Value        = resIdealOtpsAt100T.IdealFuelRateAtGivenTorque;

                        if (resCurrentOutputs.CurrentFlow < resIdealOtpsAt100T.IdealFlowAtGivenTorque || resCurrentOutputs.CurrentLoad < resIdealOtpsAt100T.IdealLoadAtGivenTorque)
                        {
                            Console.WriteLine("Current load & Flow lower than ideal.");
                            string message = string.Format("Service Name:{0}, Unit Name:{1},Current Load:{2},Ideal Load:{3}, Current Flow:{4}, Ideal Flow: {5}",
                                                           unit.ServiceName, unit.UnitName, resCurrentOutputs.CurrentLoad, resIdealOtpsAt100T.IdealLoadAtGivenTorque, resCurrentOutputs.CurrentFlow, resIdealOtpsAt100T.IdealFlowAtGivenTorque);
                            Trace.WriteLine(message);
                            //Ideal Outputs at 90% Torque
                            objOutputUnit.IdealFlow90T.Value           = "No Data";
                            objOutputUnit.IdealFuelRate90T.Value       = "No Data";
                            objOutputUnit.IdealLoad90T.Value           = "No Data";
                            objOutputUnit.IdealLoadStep90T.Value       = "No Data";
                            objOutputUnit.IdealLoadStepDetail90T.Value = "No Data";
                            //Ideal Outputs at 95% Torque
                            objOutputUnit.IdealFlow95T.Value           = "No Data";
                            objOutputUnit.IdealFuelRate95T.Value       = "No Data";
                            objOutputUnit.IdealLoad95T.Value           = "No Data";
                            objOutputUnit.IdealLoadStep95T.Value       = "No Data";
                            objOutputUnit.IdealLoadStepDetail95T.Value = "No Data";
                            objOutputUnit.LoadStep.Ideal.Value         = "No Data";
                            objOutputUnit.LoadStep.IdealDetails.Value  = "No Data";
                            objOutputUnit.LoadPrediction.Ideal.Value   = "No Data";
                            objOutputUnit.FlowPrediction.Ideal.Value   = "No Data";
                            objOutputUnit.FuelRate.Ideal.Value         = "No Data";
                        }

                        objOutputUnit.ErrorCode.Value = error;
                        SaveOutputDataInPi(objOutputUnit, lstPiPointForUnit, objERCM, unit);
                    }
                    else
                    {
                        Trace.WriteLine("Failed to load in Viewer file!");
                    }
                }
                else
                {
                    Trace.WriteLine("File doesn't exist at " + ViewerFilePath);
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Trace.WriteLine(ex.StackTrace);
            }
        }