Пример #1
0
 private void UpdateProgrammingAction(IPsdzTransactionEvent psdzEvent)
 {
     try
     {
         EcuProgrammingInfo correspondingEcu = this.GetCorrespondingEcu(psdzEvent);
         if (correspondingEcu != null)
         {
             PsdzTransactionInfo transactionInfo = psdzEvent.TransactionInfo;
             PsdzTaCategories    transactionType = psdzEvent.TransactionType;
             if (transactionType != PsdzTaCategories.FscDeploy)
             {
                 if (transactionType != PsdzTaCategories.SFADeploy)
                 {
                     ProgrammingActionType? programmingActionType  = this.Map(transactionType);
                     ProgrammingActionState?programmingActionState = this.Map(transactionInfo);
                     if (programmingActionType != null && programmingActionState != null)
                     {
                         correspondingEcu.UpdateSingleProgrammingAction(programmingActionType.Value, programmingActionState.Value, false);
                         return;
                     }
                     return;
                 }
             }
             IEnumerable <IPsdzTalLine> talLines = from talLine in this.psdzContext.Tal.TalLines
                                                   where talLine.EcuIdentifier.Equals(psdzEvent.EcuId)
                                                   select talLine;
             correspondingEcu.UpdateProgrammingActions(talLines, false, 0);
         }
         return;
     }
     catch (Exception)
     {
     }
 }
Пример #2
0
        private void FillEcusIfSeveralTimesPossible(EcuProgrammingInfos ecuProgrammingInfos)
        {
            using (IEnumerator <IEcuProgrammingInfo> enumerator = ecuProgrammingInfos.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    EcuProgrammingInfo ecuProgrammingInfo = (EcuProgrammingInfo)enumerator.Current;
                    bool flag = false;
                    using (IEnumerator <IProgrammingAction> enumerator2 = ecuProgrammingInfo.GetProgrammingActions(null).GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            if (enumerator2.Current.IsSelected)
                            {
                                flag = true;
                                break;
                            }
                        }

                        if (flag)
                        {
                            this.diagAddrToEcuMap.Add(ecuProgrammingInfo.Ecu.ID_SG_ADR, ecuProgrammingInfo);
                        }
                    }
                }
            }
        }
Пример #3
0
        private void UpdateProgrammingInfo(ISvt svt)
        {
            foreach (IEcuObj ecuObj in svt.Ecus)
            {
                EcuProgrammingInfo itemFromProgrammingInfos = this.GetItemFromProgrammingInfos((long)ecuObj.EcuIdentifier.DiagAddrAsInt);
                if (itemFromProgrammingInfos != null)
                {
                    if (ecuObj.BnTnName == null && itemFromProgrammingInfos.Ecu.ProgrammingVariantName != null)
                    {
#if false
                        Log.Info("EcuProgrammingInfos.SetSvkCurrentForEachEcu()", "Do not replace \"{0}\" with null for ECU: {1}.", new object[]
                        {
                            itemFromProgrammingInfos.Ecu.ProgrammingVariantName,
                            itemFromProgrammingInfos.Ecu.LogEcu()
                        });
#endif
                    }
                    else
                    {
                        itemFromProgrammingInfos.Ecu.ProgrammingVariantName = ecuObj.BnTnName;
                    }
                    itemFromProgrammingInfos.Ecu.StatusInfo = ecuObj.EcuStatusInfo;
                    itemFromProgrammingInfos.SvkCurrent     = ecuObj.StandardSvk;
                }
            }
        }
Пример #4
0
 internal void SetSvkTargetForEachEcu(ISvt svt)
 {
     if (svt == null)
     {
         foreach (EcuProgrammingInfo ecuProgrammingInfo in this.ecuProgrammingInfos)
         {
             ecuProgrammingInfo.SvkTarget = null;
         }
         return;
     }
     foreach (IEcuObj ecuObj in svt.Ecus)
     {
         EcuProgrammingInfo ecuProgrammingInfo2 = this.GetItemFromProgrammingInfos((long)ecuObj.EcuIdentifier.DiagAddrAsInt);
         if (ecuProgrammingInfo2 != null)
         {
             ecuProgrammingInfo2.SvkTarget = ecuObj.StandardSvk;
         }
         else
         {
             ECU ecu = this.programmingObjectBuilder.Build(ecuObj);
             if (ecu != null)
             {
                 ecuProgrammingInfo2           = this.GetEcuProgrammingInfo(ecu);
                 ecuProgrammingInfo2.SvkTarget = ecuObj.StandardSvk;
             }
         }
     }
 }
Пример #5
0
        internal void ResetProgrammingInfos(bool unregister = true, bool resetAll = true)
        {
            if (resetAll)
            {
                if (unregister)
                {
                    this.UnregisterEventHandler();
                }
                this.programmingObjectBuilder = new ProgrammingObjectBuilder(this.vehicle as Vehicle, this.ffmResolver);
                this.CreateEcuProgrammingInfos(this.vehicle.ECU);
                this.ecuProgrammingInfosMap = new Dictionary <IEcu, EcuProgrammingInfo>();
                this.ecuProgrammingInfos.ForEach(delegate(EcuProgrammingInfo info)
                {
                    this.ecuProgrammingInfosMap.Add(info.Ecu, info);
                });
                return;
            }

            foreach (IEcu key in ((IEnumerable <IEcu>) new List <IEcu>(from ecu in this.ecuProgrammingInfosMap.Keys
                                                                       where !this.vehicle.ECU.Contains(ecu)
                                                                       select ecu)))
            {
                EcuProgrammingInfo ecuProgrammingInfo = this.ecuProgrammingInfosMap[key];
                this.ecuProgrammingInfos.Remove(ecuProgrammingInfo);
                this.DataContext.List.Remove(ecuProgrammingInfo.Data);
                this.DataContext.ECUsWithIndividualData.Remove(ecuProgrammingInfo.Data);
                this.ecuProgrammingInfosMap.Remove(key);
            }
        }
Пример #6
0
        private void UpdateProgrammingProgress(IPsdzTransactionProgressEvent psdzEvent)
        {
            EcuProgrammingInfo correspondingEcu = this.GetCorrespondingEcu(psdzEvent);

            if (correspondingEcu != null)
            {
                correspondingEcu.ProgressValue = (double)psdzEvent.Progress * 0.01;
            }
        }
Пример #7
0
        IEcuProgrammingInfo IEcuProgrammingInfos.GetItem(IEcu ecu)
        {
            EcuProgrammingInfo item = this.GetItem(ecu);

            if (item == null)
            {
                return(null);
            }
            return(item.Data);
        }
Пример #8
0
        private EcuProgrammingInfo GetEcuProgrammingInfo(ECU ecuFromTargetSvt)
        {
            EcuProgrammingInfo ecuProgrammingInfo = new EcuProgrammingInfo(ecuFromTargetSvt, this.programmingObjectBuilder, true);

            this.ecuProgrammingInfos.Add(ecuProgrammingInfo);
            this.DataContext.List.Add(ecuProgrammingInfo.Data);
            this.AddProgrammingInfoBeforeReplace(ecuProgrammingInfo.Data);
            this.ecuProgrammingInfosMap.Add(ecuFromTargetSvt, ecuProgrammingInfo);
            return(ecuProgrammingInfo);
        }
Пример #9
0
 internal EcuProgrammingInfo GetItemFromProgrammingInfos(long diagAddress)
 {
     using (IEnumerator <EcuProgrammingInfo> enumerator = this.ecuProgrammingInfos.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             EcuProgrammingInfo ecuProgrammingInfo = enumerator.Current;
             if (ecuProgrammingInfo.Ecu.ID_SG_ADR == diagAddress)
             {
                 return(ecuProgrammingInfo);
             }
         }
     }
     return(null);
 }
Пример #10
0
        internal EcuProgrammingInfo AddEcuProgrammingInfo(IEcu ecu)
        {
            if (this.GetItemFromProgrammingInfos(ecu.ID_SG_ADR) != null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Diagnosis address 0x{0:X2} is already added.", ecu.ID_SG_ADR));
            }
            EcuProgrammingInfo ecuProgrammingInfo = new EcuProgrammingInfo(ecu, this.programmingObjectBuilder, true);

            this.RegisterEventHandler(ecuProgrammingInfo);
            this.ecuProgrammingInfos.Add(ecuProgrammingInfo);
            this.DataContext.List.Add(ecuProgrammingInfo.Data);
            this.AddProgrammingInfoBeforeReplace(ecuProgrammingInfo.Data);
            this.ecuProgrammingInfosMap.Add(ecuProgrammingInfo.Ecu, ecuProgrammingInfo);
            return(ecuProgrammingInfo);
        }
Пример #11
0
        private IDictionary <ProgrammingActionType, IList <SgbmIdChange> > CalculateActionStates(IEnumerable <IPsdzTalLine> talLines)
        {
            Dictionary <ProgrammingActionType, IList <SgbmIdChange> > dictionary = new Dictionary <ProgrammingActionType, IList <SgbmIdChange> >();

            foreach (IPsdzTalLine talLine in talLines)
            {
                foreach (ProgrammingActionType key in EcuProgrammingInfo.MapProgrammingActionType(talLine))
                {
                    if (!dictionary.ContainsKey(key))
                    {
                        dictionary.Add(key, new List <SgbmIdChange>());
                    }
                    IList <SgbmIdChange> sgbmIds = this.GetSgbmIds(talLine);
                    dictionary[key].AddRange(sgbmIds);
                }
            }
            return(dictionary);
        }
Пример #12
0
        private void CreateEcuProgrammingInfos(IEnumerable <IEcu> ecus)
        {
            if (ecus == null)
            {
                throw new ArgumentNullException();
            }
            this.ecuProgrammingInfos.Clear();
            IList <EcuProgrammingInfoData> list = new List <EcuProgrammingInfoData>();

            foreach (IEcu ecu in ecus)
            {
                EcuProgrammingInfo ecuProgrammingInfo = new EcuProgrammingInfo(ecu, this.programmingObjectBuilder, true);
                this.RegisterEventHandler(ecuProgrammingInfo);
                this.ecuProgrammingInfos.Add(ecuProgrammingInfo);
                list.Add(ecuProgrammingInfo.Data);
            }
            this.RefreshProgrammingInfoBeforeReplace(list);
            this.RefreshProgrammingInfo(list);
        }
Пример #13
0
 public VehicleProgrammingEventHandler(EcuProgrammingInfos ecuProgrammingInfos, PsdzContext psdzContext, bool ecusSeveralTimesPossible = false)
 {
     this.psdzContext      = psdzContext;
     this.diagAddrToEcuMap = new Dictionary <long, EcuProgrammingInfo>();
     if (!ecusSeveralTimesPossible)
     {
         using (IEnumerator <IEcuProgrammingInfo> enumerator = ecuProgrammingInfos.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 IEcuProgrammingInfo ecuProgrammingInfo  = enumerator.Current;
                 EcuProgrammingInfo  ecuProgrammingInfo2 = (EcuProgrammingInfo)ecuProgrammingInfo;
                 if (!this.diagAddrToEcuMap.ContainsKey(ecuProgrammingInfo2.Ecu.ID_SG_ADR))
                 {
                     this.diagAddrToEcuMap.Add(ecuProgrammingInfo2.Ecu.ID_SG_ADR, ecuProgrammingInfo2);
                 }
             }
             return;
         }
     }
     this.FillEcusIfSeveralTimesPossible(ecuProgrammingInfos);
 }
Пример #14
0
 internal void UpdateProgrammingActions(IPsdzTal tal, int escalationStep)
 {
     foreach (IPsdzEcuIdentifier psdzEcuIdentifier in tal.AffectedEcus)
     {
         EcuProgrammingInfo itemFromProgrammingInfos = this.GetItemFromProgrammingInfos((long)psdzEcuIdentifier.DiagAddrAsInt);
         if (itemFromProgrammingInfos != null)
         {
             IPsdzEcuIdentifier         id       = psdzEcuIdentifier;
             IEnumerable <IPsdzTalLine> talLines = from talLine in tal.TalLines
                                                   where talLine.EcuIdentifier.Equals(id)
                                                   select talLine;
             itemFromProgrammingInfos.UpdateProgrammingActions(talLines, true, escalationStep);
         }
         else
         {
             //Log.Warning("EcuProgrammingInfos.UpdateProgrammingActions", "Could not find ecu programming object for 0x{0:X2}", new object[]
             //{
             //	psdzEcuIdentifier.DiagAddrAsInt
             //});
         }
     }
 }
Пример #15
0
        internal void UpdateProgrammingActions(IEnumerable <IPsdzTalLine> talLines, bool isTalExecuted, int escalationSteps = 0)
        {
            IDictionary <ProgrammingActionType, ICollection <IPsdzTalLine> > dictionary = new Dictionary <ProgrammingActionType, ICollection <IPsdzTalLine> >();

            foreach (IPsdzTalLine psdzTalLine in talLines)
            {
                foreach (ProgrammingActionType key in EcuProgrammingInfo.MapProgrammingActionType(psdzTalLine))
                {
                    if (dictionary.ContainsKey(key))
                    {
                        dictionary[key].Add(psdzTalLine);
                    }
                    else
                    {
                        dictionary.Add(key, new List <IPsdzTalLine>
                        {
                            psdzTalLine
                        });
                    }
                }
            }
            foreach (ProgrammingActionType programmingActionType in dictionary.Keys)
            {
                ProgrammingAction programmingAction = this.GetProgrammingAction(programmingActionType) as ProgrammingAction;
                if (programmingAction != null)
                {
                    if (isTalExecuted)
                    {
                        programmingAction.Update(dictionary[programmingActionType], escalationSteps);
                    }
                    else
                    {
                        programmingAction.UpdateState(dictionary[programmingActionType]);
                    }
                }
            }
        }