Esempio n. 1
0
        private void SetWorkTimeGA(BaseComponent powerUnit, FlightRegime flightRegime)
        {
            if (powerUnit == null)
            {
                return;
            }
            List <PowerUnitTimeInRegimeControlItem> fcs =
                flowLayoutPanelMain.Controls
                .OfType <PowerUnitTimeInRegimeControlItem>()
                .Where(c => c.PowerUnit != null &&
                       c.PowerUnit.ItemId == powerUnit.ItemId &&
                       c.FlightRegime == flightRegime)
                .ToList();
            int t = fcs.Sum(cr => cr.WorkTime);

            Lifelength baseDetailLifeLenghtInRegimeSinceLastOverhaul = null;
            Lifelength baseDetailLifeLenghtSinceLastOverhaul         = null;
            Lifelength baseDetailOhInterval = null;
            Lifelength baseDetailLifeLenghtInRegimeSinceNew =
                GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate, flightRegime);
            Lifelength baseDetailLifeLenghtSinceNew =
                GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate);
            Lifelength baseDetailLifeLimit = powerUnit.LifeLimit;

            ComponentWorkInRegimeParams inRegimeParams =
                powerUnit.ComponentWorkParams.Where(p => p.FlightRegime == flightRegime).FirstOrDefault();

            if (inRegimeParams != null &&
                inRegimeParams.ResorceProvider == SmartCoreType.ComponentDirective &&
                powerUnit.ComponentDirectives.GetItemById(inRegimeParams.ResorceProviderId) != null)
            {
                //в парамтрах работы требуется расчитать время работы в режиме с
                //последнего выполнения директивы
                ComponentDirective dd = powerUnit.ComponentDirectives.GetItemById(inRegimeParams.ResorceProviderId);
                if (dd.LastPerformance == null)
                {
                    baseDetailOhInterval = dd.Threshold.FirstPerformanceSinceNew;
                    //если последнего выполнения директивы нет,
                    //то расчитывается полная работа агрегата в указанном режиме
                    baseDetailLifeLenghtInRegimeSinceLastOverhaul =
                        GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate, flightRegime);
                    baseDetailLifeLenghtSinceLastOverhaul =
                        GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthOnStartOfDay(powerUnit, _flightDate);
                }
                else
                {
                    baseDetailOhInterval = dd.Threshold.RepeatInterval;
                    //т.к. может просматриваться старый полет (н: месячной давности)
                    //производится поиск последней записи о выполнении перед текущим полетов
                    AbstractPerformanceRecord r = dd.PerformanceRecords.GetLastKnownRecord(_flightDate);
                    if (r != null)
                    {
                        baseDetailLifeLenghtInRegimeSinceLastOverhaul =
                            GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(powerUnit, r.RecordDate, _flightDate.AddHours(-1), flightRegime);
                        baseDetailLifeLenghtSinceLastOverhaul =
                            GlobalObjects.CasEnvironment.Calculator.GetFlightLifelengthForPeriod(powerUnit, r.RecordDate, _flightDate.AddHours(-1));//TODO:(Evgenii Babak) выяснить почему AddHours(-1)
                    }
                }
            }

            if (Flight.AircraftId <= 0)
            {
                //извлечение всех полетов ВС
                var flights = GlobalObjects.AircraftFlightsCore.GetAircraftFlightsOnDate(Flight.AircraftId, _flightDate);
                //И поиск всех полетов, что были раньше текущего
                foreach (AircraftFlight aircraftFlight in flights)
                {
                    //Если полет был раньше текущего, то его наработка добавляется
                    //к рассчитываемым ресурсам базового агрегата
                    if (aircraftFlight.FlightDate < _flightDate.Date.Add(_outTime.TimeOfDay))
                    {
                        baseDetailLifeLenghtInRegimeSinceNew.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit, flightRegime));
                        baseDetailLifeLenghtSinceNew.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit));
                        if (baseDetailLifeLenghtInRegimeSinceLastOverhaul == null)
                        {
                            continue;
                        }
                        baseDetailLifeLenghtInRegimeSinceLastOverhaul.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit, flightRegime));
                        if (baseDetailLifeLenghtSinceLastOverhaul == null)
                        {
                            continue;
                        }
                        baseDetailLifeLenghtSinceLastOverhaul.Add(GlobalObjects.CasEnvironment.Calculator.GetFlightLifelength(aircraftFlight, powerUnit));
                    }
                }
            }
            baseDetailLifeLenghtInRegimeSinceNew.Add(LifelengthSubResource.Minutes, t);

            if (baseDetailLifeLenghtInRegimeSinceLastOverhaul != null)
            {
                baseDetailLifeLenghtInRegimeSinceLastOverhaul.Add(LifelengthSubResource.Minutes, t);
            }


            double persentSN = 0, persentLifeLimit = 0, persentSLO = 0, persentOhInt = 0;
            int?   resInRegimeSN = baseDetailLifeLenghtInRegimeSinceNew.GetSubresource(LifelengthSubResource.Minutes);
            int?   resSN         = baseDetailLifeLenghtSinceNew.GetSubresource(LifelengthSubResource.Minutes);
            int?   resLl         = baseDetailLifeLimit.GetSubresource(LifelengthSubResource.Minutes);

            if (resSN != null && resInRegimeSN != null && resSN > 0)
            {
                persentSN = Convert.ToDouble((double)resInRegimeSN * 100 / resSN);
            }
            if (resLl != null && resInRegimeSN != null && resLl > 0)
            {
                persentLifeLimit = Convert.ToDouble((double)resInRegimeSN * 100 / resLl);
            }

            if (baseDetailLifeLenghtInRegimeSinceLastOverhaul != null)
            {
                int?resInRegimeSLO = baseDetailLifeLenghtInRegimeSinceLastOverhaul.GetSubresource(LifelengthSubResource.Minutes);

                if (baseDetailLifeLenghtSinceLastOverhaul != null)
                {
                    int?resSLO = baseDetailLifeLenghtSinceLastOverhaul.GetSubresource(LifelengthSubResource.Minutes);
                    if (resSLO != null && resInRegimeSLO != null && resSLO > 0)
                    {
                        persentSLO = Convert.ToDouble((double)resInRegimeSLO * 100 / resSLO);
                    }
                }
                if (baseDetailOhInterval != null)
                {
                    int?resOhInt = baseDetailOhInterval.GetSubresource(LifelengthSubResource.Minutes);
                    if (resOhInt != null && resInRegimeSLO != null && resOhInt > 0)
                    {
                        persentOhInt = Convert.ToDouble((double)resInRegimeSLO * 100 / resOhInt);
                    }
                }
            }


            foreach (PowerUnitTimeInRegimeControlItem fc in fcs)
            {
                fc.WorkTimeGA       = t;
                fc.WorkTimeSinceNew = baseDetailLifeLenghtInRegimeSinceNew;
                fc.WorkTimeSLO      = baseDetailLifeLenghtInRegimeSinceLastOverhaul;
                fc.PersentSN        = persentSN;
                fc.PersentLifeLimit = persentLifeLimit;
                fc.PersentSLO       = persentSLO;
                fc.PersentOhInt     = persentOhInt;
            }
        }
Esempio n. 2
0
        private void GenerateRows()
        {
            listViewProgramChecks.Items.Clear();
            if (_grouping)
            {
                MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems);
                MaintenanceCheck           mc  = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule);
                if (mc == null)
                {
                    return;
                }
                MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0
                                  ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG
                                  : MSG.MSG2;
                if (msg < MSG.MSG3)
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                else
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupWhereCheckIsSeniorByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                mcc.Clear();
            }
            else
            {
                foreach (MaintenanceCheck t in _maintenanceCheckItems)
                {
                    ListViewItem listViewItem = new ListViewItem {
                        Text = t.Name
                    };

                    listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                    listViewItem.SubItems.Add(t.Cost.ToString());
                    listViewItem.SubItems.Add(t.ManHours.ToString());

                    Lifelength lastPerformance = t.LastPerformance != null
                        ? new Lifelength(t.LastPerformance.OnLifelength)
                        : Lifelength.Null;
                    int?last = lastPerformance.GetSubresource(_subResource);

                    listViewItem.SubItems.Add(last != null ? lastPerformance.ToString(_subResource, true) : "");

                    if (t.Schedule == _schedule)
                    {
                        Lifelength nextPerformance = lastPerformance + t.Interval;
                        int?       next            = nextPerformance.GetSubresource(_subResource);
                        listViewItem.SubItems.Add(next != null ? nextPerformance.ToString(_subResource, true) : "");
                    }
                    else
                    {
                        listViewItem.SubItems.Add("N/A");
                    }
                    listViewProgramChecks.Items.Add(listViewItem);
                }
            }
        }