コード例 #1
0
        private void InsertButton_Click(object sender, EventArgs e)
        {
            int id       = 0; //セマンティックリンクID
            int startNum = 0; //スタート地点NUM

            #region 仮想ログデータ(JST,車速,車間距離)を生成する処理
            //ECOLOGテーブルから,SQLで指定した範囲のECOLOGデータをDataTable型で取得する処理
            DataTable ECOLOGData = EcologSimulationDao.GetSelectedData();
            //ソートされたリンク(線)を取得する処理
            List <LinkData> linkList = getLinkList(id, startNum);
            //仮想ログデータを生成するメソッド
            DataTable logData = generateSimulationLog(ECOLOGData, linkList);
            #endregion

            DataTable EcologSimulationTable = new DataTable();      //仮想の走行ログから生成したECOLOGデータを格納するDataTableを作成
            EcologSimulationTable = DataTableUtil.GetEcologTable(); //↑で生成したDataTableのスキーマをECOLOGテーブルの形にする

            //ECOLOG計算をして,仮想ECOLOGデータを生成するメソッド
            for (int i = 0; i < logData.Rows.Count; i++)
            {
                DataRow ecologRow = HagimotoEcologCalculator.CalcEcologSimulation(DataRow tripRow, InsertDatum datum, InsertConfig.GpsCorrection.Normal);//TODO: 仮想のGPSログを元にtripRow, Datumを設定
                EcologSimulationTable.Rows.Add(ecologRow);
            }

            #region 仮想ECOLOGデータをデータベースインサートする処理
            //仮想ECOLOGデータをECOLOG_SIMULATIONテーブルへインサートするメソッド
            EcologSimulationDao.Insert(EcologSimulationTable);
            #endregion
        }
コード例 #2
0
        public static void InsertEcolog(InsertDatum datum, MainWindowViewModel.UpdateTextDelegate updateTextDelegate, InsertConfig.GpsCorrection correction, out int count)
        {
            count = 0;
            var tripsTable = TripsDao.Get(datum);
            //int i = 1;

            //foreach (DataRow row in tripsTable.Rows)
            //{
            //    updateTextDelegate($"Insetring ECOLOG ... , {i} / {tripsTable.Rows.Count}");
            //    LogWritter.WriteLog(LogWritter.LogMode.Ecolog, $"Insetring ECOLOG... , { i} / { tripsTable.Rows.Count}, Datum: {datum}");
            //    var ecologTable = HagimotoEcologCalculator.CalcEcolog(row, datum, correction);
            //    EcologDao.Insert(ecologTable);

            //    i++;
            //}
            int t = 0;

            Parallel.For(0, tripsTable.Rows.Count, i =>
            {
                if (tripsTable.Rows[i][(TripsDao.ColumnConsumedEnergy)] == DBNull.Value)
                {
                    updateTextDelegate($"Insetring ECOLOG ... , {i + 1} / {tripsTable.Rows.Count}");
                    LogWritter.WriteLog(LogWritter.LogMode.Ecolog, $"Insetring ECOLOG... , { i} / { tripsTable.Rows.Count}, Datum: {datum}");
                    var ecologTable = HagimotoEcologCalculator.CalcEcolog(tripsTable.Rows[i], datum, InsertConfig.GpsCorrection.Normal);
                    EcologSimulationDao.Insert(ecologTable);
                    t++;
                }
            });
            count = t;
            TripsDao.UpdateConsumedEnergy();
        }