示例#1
0
        public static void InsertAcc(List <string> insertFileList, InsertConfig config, List <InsertDatum> insertDatumList)
        {
            foreach (var filePath in insertFileList)
            //Parallel.For(0, insertFileList.Count, i =>
            {
                string[] word = filePath.Split('\\');

                // ACCファイルでない場合はcontinue
                if (System.Text.RegularExpressions.Regex.IsMatch(word[word.Length - 1], @"\d{14}Unsent16HzAccel.csv"))
                {
                    int sensorId = SensorNames.GetSensorId(word[SensorIndex]);

                    if (sensorId == -1)
                    {
                        SlackUtil.noSensorData(filePath);
                        return;
                    }

                    var datum = new InsertDatum()
                    {
                        DriverId          = DriverNames.GetDriverId(word[DriverIndex]),
                        CarId             = CarNames.GetCarId(word[CarIndex]),
                        SensorId          = sensorId,
                        StartTime         = config.StartDate,
                        EndTime           = config.EndDate,
                        EstimatedCarModel = EstimatedCarModel.GetModel(config.CarModel)
                    };

                    InsertDatum.AddDatumToList(insertDatumList, datum);

                    InsertAccRaw(filePath, datum);
                }
                //});
            }
        }
        public void Deve_Enviar_Mensagem_Para_Slack_Tipo_Erro()
        {
            var slackUtil = new SlackUtil(_urlWebhook);

            var mensagem = new SlackMensagem(_nomeCanal, "Essa é uma mensagem enviada para o Slack", _nomeUsuario, "Você recebeu uma mensagem.");

            mensagem.DefinirTipo(TipoSlackMensagem.Erro);

            Assert.IsTrue(slackUtil.Postar(mensagem));
        }
        public void Deve_Enviar_Mensagem_Para_Slack_Com_Informacoes_Adicionais()
        {
            var slackUtil = new SlackUtil(_urlWebhook);

            var mensagem = new SlackMensagem(_nomeCanal, "Essa é uma mensagem enviada para o Slack com informações adicionais.", _nomeUsuario, "Você recebeu uma mensagem.", TipoSlackEmoji.RobotFace);

            Assert.IsTrue(slackUtil.Postar(mensagem, infoAdicionais: new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Data atual", DateTime.Now.ToString("dd/MM/yyyy")),
                new KeyValuePair <string, string>("Outra informação", "Qualquer informação aqui.")
            }));
        }
        public void Deve_Enviar_Mensagem_Para_Slack()
        {
            var slackUtil = new SlackUtil(_urlWebhook);

            try
            {
                var mensagem = new SlackMensagem(_nomeCanal, "Essa é uma mensagem enviada para o Slack", _nomeUsuario, "Você recebeu uma mensagem.");

                Assert.IsTrue(slackUtil.Postar(mensagem));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void Deve_Enviar_Mensagem_Para_Slack_Por_Exception()
        {
            var slackUtil = new SlackUtil(_urlWebhook);

            try
            {
                var a = 0;
                var i = 5 / a;
            }
            catch (Exception ex)
            {
                var mensagem = new SlackMensagem(_nomeCanal, "Esse é um exemplo de exception enviada para o Slack.", _nomeUsuario, "Você recebeu uma nova exception");

                Assert.IsTrue(slackUtil.Postar(mensagem, ex));
            }
        }
示例#6
0
        public static DataTable getResultMapMatchingDoppler(DataTable gpsRawTable, InsertDatum datum)
        {
            if (gpsRawTable.Rows.Count == 0)
            {
                return(new DataTable());
            }

            List <DataTable> dt = new List <DataTable>();

            if (datum.DriverId == 1)//被験者1用のマップマッチング道路リンクを取得
            {
                int[]     id        = new int[] { 220 };
                DataTable tempTable = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "復路,代官山下ルート";
                dt.Add(tempTable);
                dt[0].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 224 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "復路,代官山上ルート";
                dt.Add(tempTable);
                dt[1].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 221 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "往路,小学校上ルート";
                dt.Add(tempTable);
                dt[2].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 225 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "往路,小学校下ルート";
                dt.Add(tempTable);
                dt[3].DefaultView.Sort = "START_LAT, " +
                                         "" +
                                         "" +
                                         "" +
                                         "" +
                                         "" +
                                         "" +
                                         "" +
                                         "" +
                                         "START_LONG";
            }
            else if (datum.DriverId == 17)//マップマッチング道路リンクを取得
            {
                int[]     id        = new int[] { 328 };
                DataTable tempTable = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者17復路ルート1";
                dt.Add(tempTable);
                dt[0].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 329 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者17往路ルート1";
                dt.Add(tempTable);
                dt[1].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 330 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者17往路ルート2";
                dt.Add(tempTable);
                dt[2].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 331 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者17往路ルート2";
                dt.Add(tempTable);
                dt[2].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 340 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者17往路ルート3";
                dt.Add(tempTable);
                dt[2].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 341 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者17復路ルート3";
                dt.Add(tempTable);
                dt[2].DefaultView.Sort = "START_LAT, START_LONG";
            }
            else if (datum.DriverId == 28)
            {
                int[]     id        = new int[] { 365 };
                DataTable tempTable = LinkDao.GetLinkTableforMM(id);
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者28 往路ルート1";
                dt.Add(tempTable);
                dt[0].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 366 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者28 復路ルート1";
                dt.Add(tempTable);
                dt[1].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 369 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者28 往路ルート2";
                dt.Add(tempTable);
                dt[2].DefaultView.Sort = "START_LAT, START_LONG";

                id                  = new int[] { 370 };
                tempTable           = LinkDao.GetLinkTableforMM(id);
                tempTable.TableName = "被験者28 復路ルート2";
                dt.Add(tempTable);
                dt[3].DefaultView.Sort = "START_LAT, START_LONG";
            }
            //TODO マップマッチング処理
            double[]    sumDist            = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の総和
            double[]    maxDist            = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の最大値
            DataTable[] mapMatchedGpsTable = DataTableUtil.GetAndroidGpsRawDopplerTableArray(dt.Count);
            for (int i = 0; i < gpsRawTable.Rows.Count; i++)
            {
                for (int n = 0; n < dt.Count; n++)
                {
                    double tempDist = searchNearestLinkDoppler(dt[n], gpsRawTable.Rows[i], ref mapMatchedGpsTable[n]);
                    sumDist[n] += tempDist;

                    if (tempDist > maxDist[n])
                    {
                        maxDist[n] = tempDist;
                    }
                }
            }
            int element = getMinElement(sumDist);

            if (sumDist.Length == 0)
            {
                SlackUtil.noMapMatching(datum, gpsRawTable.Rows[0]);
                return(new DataTable());
            }
            if (sumDist[element] > 0.5 || maxDist[element] > 0.003)
            {
                SlackUtil.noMapMatching(datum, gpsRawTable.Rows[0]);
                return(new DataTable());
            }


            return(mapMatchedGpsTable[element]);
        }
        public async void Insert()
        {
            this.InsertDatumList       = new List <InsertDatum>();
            this.InsertFileList        = new List <string>();
            IsEnabledInsertButton      = false;
            IsEnabledStartUpLoopButton = false;
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            this.InsertConfig = this.GenerateInsertConfig();

            #region ファイル検索

            this.LogText += LogTexts.DuringCheckOfTheUpdateFile + "\n";
            LogWritter.WriteLog(LogWritter.LogMode.Search, LogTexts.DuringCheckOfTheUpdateFile + "\n");

            await Task.Run(() =>
            {
                this.InsertFileList = DirectorySearcher.DirectorySearch(this.InsertConfig);
            });

            this.LogText += $"{LogTexts.NumberOfTheInsertedFile}: {this.InsertFileList.Count}\n";
            LogWritter.WriteLog(LogWritter.LogMode.Search, $"{LogTexts.NumberOfTheInsertedFile}: {this.InsertFileList.Count}\n");

            #endregion

            #region GPS挿入

            this.LogText += LogTexts.TheSrartOfTheInsertingGps + "\n";
            LogWritter.WriteLog(LogWritter.LogMode.Gps, LogTexts.TheSrartOfTheInsertingGps + "\n");

            for (int i = 0; i < this.InsertConfig.Correction.Count; i++)
            {
                await GpsInserter.InsertGps(this.InsertFileList, this.InsertConfig, i, this.InsertDatumList);
            }

            // Parallel.For(0, this.InsertConfig.Correction.Count, i =>
            //{
            //    GpsInserter.InsertGps(this.InsertFileList, this.InsertConfig, i, this.InsertDatumList);
            //});

            this.LogText += LogTexts.TheEndOfTheInsertingGps + "\n";
            LogWritter.WriteLog(LogWritter.LogMode.Gps, LogTexts.TheEndOfTheInsertingGps + "\n");

            #endregion

            #region 加速度挿入

            if (IsCheckedInsertAcc)
            {
                this.LogText += LogTexts.TheSrartOfTheInsertingAcc + "\n";
                LogWritter.WriteLog(LogWritter.LogMode.Acc, LogTexts.TheSrartOfTheInsertingAcc + "\n");

                await Task.Run(() =>
                {
                    AccInserter.InsertAcc(this.InsertFileList, this.InsertConfig, this.InsertDatumList);
                });

                this.LogText += LogTexts.TheEndOfTheInsertingAcc + "\n";
                LogWritter.WriteLog(LogWritter.LogMode.Acc, LogTexts.TheEndOfTheInsertingAcc + "\n");
            }

            #endregion

            await Task.Run(() =>
            {
                foreach (var datum in InsertDatumList)
                {
                    #region トリップ挿入


                    for (int i = 0; i < this.InsertConfig.Correction.Count; i++)
                    {
                        TripInserter.InsertTrip(datum, InsertConfig.Correction[i], InsertConfig.IsCheckedSightseeingInsert);
                    }


                    #endregion

                    #region 補正加速度挿入

                    //if (IsCheckedInsertCorrectedAcc)
                    //{
                    //    await Task.Run(() =>
                    //    {
                    //        AccInserter.InsertCorrectedAcc(datum, InsertConfig);
                    //    });
                    //}

                    #endregion
                }
            });

            int count = 0;

            await Task.Run(() =>
            {
                Parallel.For(0, InsertDatumList.Count, i =>
                {
                    #region ECOLOG挿入
                    sw.Start();

                    if (IsCheckedSpeedLPFMapMatching)
                    {
                        EcologInserter.InsertEcologSpeedLPF005MM(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.SpeedLPFMapMatching);
                    }
                    if (IsCheckedMapMatching)
                    {
                        EcologInserter.InsertEcologMM(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.MapMatching);
                    }

                    if (IsCheckedNormal)
                    {
                        EcologInserter.InsertEcolog(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.Normal, out count);
                    }
                    if (IsCheckedDopplerSpeed)
                    {
                        EcologInserter.InsertEcologDoppler(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.DopplerSpeed, out count);
                    }
                    if (IsCheckedDopplerNotMM)
                    {
                        EcologInserter.InsertEcologDopplerNotMM(InsertDatumList[i], this.UpdateText, InsertConfig.GpsCorrection.DopplerNotMM);
                    }


                    sw.Stop();
                    LogWritter.WriteLog(LogWritter.LogMode.Elapsedtime, "Total Time:" + sw.Elapsed);
                    #endregion
                });
            });

            this.LogText += LogTexts.TheEndOfTheInsertingEcolog + "\n";
            await Task.Run(() =>
            {
                if (count > 0)
                {
                    SlackUtil.insertIsFinished(InsertConfig.StartDate, InsertConfig.EndDate, InsertConfig.Correction);
                }
                else
                {
                    SlackUtil.noInsertFile(InsertConfig.StartDate, InsertConfig.EndDate, InsertConfig.Correction);
                }
                IsEnabledInsertButton      = true;
                IsEnabledStartUpLoopButton = true;
            });
        }