Esempio n. 1
0
        private static List <EcuFunctionStructs.EcuFixedFuncStruct> GetEcuFixedFuncStructList(SQLiteConnection mDbConnection, string parentId)
        {
            List <EcuFunctionStructs.EcuFixedFuncStruct> ecuFixedFuncStructList = new List <EcuFunctionStructs.EcuFixedFuncStruct>();
            string sql = string.Format(@"SELECT ID, NODECLASS, " + SqlTitleItems + ", " +
                                       SqlPreOpItems + ", " + SqlProcItems + ", " + SqlPostOpItems + ", " +
                                       "SORT_ORDER, ACTIVATION, ACTIVATION_DURATION_MS " +
                                       "FROM XEP_ECUFIXEDFUNCTIONS WHERE (PARENTID = {0})", parentId);

            using (SQLiteCommand command = new SQLiteCommand(sql, mDbConnection))
            {
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string nodeClass = reader["NODECLASS"].ToString();
                        EcuFunctionStructs.EcuFixedFuncStruct ecuFixedFuncStruct = new EcuFunctionStructs.EcuFixedFuncStruct(reader["ID"].ToString(),
                                                                                                                             nodeClass,
                                                                                                                             GetNodeClassName(mDbConnection, nodeClass),
                                                                                                                             GetTranslation(reader),
                                                                                                                             GetTranslation(reader, "PREPARINGOPERATORTEXT"),
                                                                                                                             GetTranslation(reader, "PROCESSINGOPERATORTEXT"),
                                                                                                                             GetTranslation(reader, "POSTOPERATORTEXT"),
                                                                                                                             reader["SORT_ORDER"].ToString(),
                                                                                                                             reader["ACTIVATION"].ToString(),
                                                                                                                             reader["ACTIVATION_DURATION_MS"].ToString());

                        ecuFixedFuncStruct.EcuJobList = GetFixedFuncStructJobsList(mDbConnection, ecuFixedFuncStruct);
                        ecuFixedFuncStructList.Add(ecuFixedFuncStruct);
                    }
                }
            }

            return(ecuFixedFuncStructList);
        }
Esempio n. 2
0
        private static List <EcuFunctionStructs.EcuJob> GetFixedFuncStructJobsList(SQLiteConnection mDbConnection, EcuFunctionStructs.EcuFixedFuncStruct ecuFixedFuncStruct)
        {
            List <EcuFunctionStructs.EcuJob> ecuJobList = new List <EcuFunctionStructs.EcuJob>();
            string sql = string.Format(@"SELECT JOBS.ID JOBID, FUNCTIONNAMEJOB, NAME, PHASE, RANK " +
                                       "FROM XEP_ECUJOBS JOBS, XEP_REFECUJOBS REFJOBS WHERE JOBS.ID = REFJOBS.ECUJOBID AND REFJOBS.ID = {0}", ecuFixedFuncStruct.Id);

            using (SQLiteCommand command = new SQLiteCommand(sql, mDbConnection))
            {
                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        ecuJobList.Add(new EcuFunctionStructs.EcuJob(reader["JOBID"].ToString(),
                                                                     reader["FUNCTIONNAMEJOB"].ToString(),
                                                                     reader["NAME"].ToString(),
                                                                     reader["PHASE"].ToString(),
                                                                     reader["RANK"].ToString()));
                    }
                }
            }

            foreach (EcuFunctionStructs.EcuJob ecuJob in ecuJobList)
            {
                List <EcuFunctionStructs.EcuJobParameter> ecuJobParList = new List <EcuFunctionStructs.EcuJobParameter>();
                sql = string.Format(
                    @"SELECT PARAM.ID PARAMID, PARAMVALUE, FUNCTIONNAMEPARAMETER, ADAPTERPATH, NAME, ECUJOBID " +
                    "FROM XEP_ECUPARAMETERS PARAM, XEP_REFECUPARAMETERS REFPARAM WHERE " +
                    "PARAM.ID = REFPARAM.ECUPARAMETERID AND REFPARAM.ID = {0} AND PARAM.ECUJOBID = {1}", ecuFixedFuncStruct.Id, ecuJob.Id);
                using (SQLiteCommand command = new SQLiteCommand(sql, mDbConnection))
                {
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ecuJobParList.Add(new EcuFunctionStructs.EcuJobParameter(reader["PARAMID"].ToString(),
                                                                                     reader["PARAMVALUE"].ToString(),
                                                                                     reader["ADAPTERPATH"].ToString(),
                                                                                     reader["NAME"].ToString()));
                        }
                    }
                }

                ecuJob.EcuJobParList = ecuJobParList;

                List <EcuFunctionStructs.EcuJobResult> ecuJobResultList = new List <EcuFunctionStructs.EcuJobResult>();
                sql = string.Format(
                    @"SELECT RESULTS.ID RESULTID, " + SqlTitleItems + ", FUNCTIONNAMERESULT, ADAPTERPATH, NAME, STEUERGERAETEFUNKTIONENRELEVAN, LOCATION, UNIT, UNITFIXED, FORMAT, MULTIPLIKATOR, OFFSET, RUNDEN, ZAHLENFORMAT, ECUJOBID " +
                    "FROM XEP_ECURESULTS RESULTS, XEP_REFECURESULTS REFRESULTS WHERE " +
                    "ECURESULTID = RESULTS.ID AND REFRESULTS.ID = {0} AND RESULTS.ECUJOBID = {1}", ecuFixedFuncStruct.Id, ecuJob.Id);
                using (SQLiteCommand command = new SQLiteCommand(sql, mDbConnection))
                {
                    using (SQLiteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ecuJobResultList.Add(new EcuFunctionStructs.EcuJobResult(reader["RESULTID"].ToString(),
                                                                                     GetTranslation(reader),
                                                                                     reader["FUNCTIONNAMERESULT"].ToString(),
                                                                                     reader["ADAPTERPATH"].ToString(),
                                                                                     reader["NAME"].ToString(),
                                                                                     reader["STEUERGERAETEFUNKTIONENRELEVAN"].ToString(),
                                                                                     reader["LOCATION"].ToString(),
                                                                                     reader["UNIT"].ToString(),
                                                                                     reader["UNITFIXED"].ToString(),
                                                                                     reader["FORMAT"].ToString(),
                                                                                     reader["MULTIPLIKATOR"].ToString(),
                                                                                     reader["OFFSET"].ToString(),
                                                                                     reader["RUNDEN"].ToString(),
                                                                                     reader["ZAHLENFORMAT"].ToString()));
                        }
                    }
                }

                foreach (EcuFunctionStructs.EcuJobResult ecuJobResult in ecuJobResultList)
                {
                    ecuJobResult.EcuResultStateValueList = GetResultStateValueList(mDbConnection, ecuJobResult);
                }

                ecuJob.EcuJobResultList = ecuJobResultList;
            }

            return(ecuJobList);
        }
Esempio n. 3
0
        static int MergeEcuJob(TextWriter outTextWriter, string fileName, List <EcuFunctionStructs.EcuFixedFuncStruct> fixedFuncStructList,
                               EcuFunctionStructs.EcuJob ecuJobMerge, EcuFunctionStructs.EcuFixedFuncStruct ecuFixedFuncStructMerge)
        {
            if (ecuJobMerge == null || string.IsNullOrEmpty(ecuJobMerge.Name) || ecuJobMerge.EcuJobResultList?.Count == 0)
            {
                return(0);
            }

            int matches = 0;

            foreach (EcuFunctionStructs.EcuFixedFuncStruct ecuFixedFuncStruct in fixedFuncStructList)
            {
                if (ecuFixedFuncStruct.EcuJobList != null)
                {
                    foreach (EcuFunctionStructs.EcuJob ecuJob in ecuFixedFuncStruct.EcuJobList)
                    {
                        if (!string.IsNullOrEmpty(ecuJob.Name))
                        {
                            if ((string.Compare(ecuJob.Name.Trim(), ecuJobMerge.Name.Trim(), StringComparison.OrdinalIgnoreCase) == 0) &&
                                string.Compare(ecuJob.FuncNameJob.Trim(), ecuJobMerge.FuncNameJob.Trim(), StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                if (EcuJobsArgsIdentical(ecuJob, ecuJobMerge))
                                {
                                    int results = MergeEcuJobResults(null, fileName, ecuJob, ecuJobMerge);
                                    if (results > 0)
                                    {
                                        if (ecuFixedFuncStructMerge.CompatIdListList != null)
                                        {
                                            List <string> compatIdListList = ecuFixedFuncStruct.CompatIdListList ?? new List <string>();
                                            foreach (string compatId in ecuFixedFuncStructMerge.CompatIdListList)
                                            {
                                                if (!ecuFixedFuncStruct.IdPresent(compatId))
                                                {
                                                    compatIdListList.Add(compatId);
                                                }
                                            }

                                            ecuFixedFuncStruct.CompatIdListList = compatIdListList;
                                        }

                                        if (!ecuFixedFuncStruct.IdPresent(ecuFixedFuncStructMerge.Id))
                                        {
                                            List <string> compatIdListList = ecuFixedFuncStruct.CompatIdListList ?? new List <string>();
                                            compatIdListList.Add(ecuFixedFuncStructMerge.Id);
                                            ecuFixedFuncStruct.CompatIdListList = compatIdListList;
                                        }

                                        if (ecuJobMerge.CompatIdListList != null)
                                        {
                                            List <string> compatIdListList = ecuJob.CompatIdListList ?? new List <string>();
                                            foreach (string compatId in ecuJobMerge.CompatIdListList)
                                            {
                                                if (!ecuJob.IdPresent(compatId))
                                                {
                                                    compatIdListList.Add(compatId);
                                                }
                                            }

                                            ecuJob.CompatIdListList = compatIdListList;
                                        }

                                        if (!ecuJob.IdPresent(ecuJobMerge.Id))
                                        {
                                            List <string> compatIdListList = ecuJob.CompatIdListList ?? new List <string>();
                                            compatIdListList.Add(ecuJobMerge.Id.Trim());
                                            ecuJob.CompatIdListList = compatIdListList;
                                            if (compatIdListList.Count > 1)
                                            {
                                                outTextWriter?.WriteLine("Merge Jobs multi IDs: File='{0}', Job='{1}({2})', Args='{3}', Res='{4}', Count={5}",
                                                                         fileName, ecuJob.Name, ecuJob.FuncNameJob, JobsArgsToString(ecuJob), JobsResultsToString(ecuJob), compatIdListList.Count);
                                            }
                                        }

                                        matches += results;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (matches == 0)
            {
                outTextWriter?.WriteLine("Merge Jobs no match: File='{0}', Job='{1}({2})', Args='{3}', Res='{4}'",
                                         fileName, ecuJobMerge.Name, ecuJobMerge.FuncNameJob, JobsArgsToString(ecuJobMerge), JobsResultsToString(ecuJobMerge));
            }

            return(matches);
        }