예제 #1
0
파일: TurboTrainer.cs 프로젝트: Cycli/Cycli
        public static TurboTrainer Load(string userId, string turboType, bool turboIsCalibrated)
        {
            TurboTrainer thisTurbo = null;
              SQLiteDatabase db = new SQLiteDatabase();

              string sqlNonCalibrated = @"select t.type, t.power_model_c1, t.power_model_c2, t.power_model_c3 from " +
            "cycli_turbos t where t.type=@t";

              string sqlCalibrated = @"select t.type, t.power_model_c1, t.power_model_c2, t.power_model_c3 from " +
            "cycli_rider_turbos t where t.UserId=@u and t.type=@t";

              DataTable dtUser = null;
              if (turboIsCalibrated)
              {
            dtUser = db.GetDataTable(sqlCalibrated,"@u",userId,"@t",turboType);
            // Not defined yet - use the non standard values
            if (dtUser.Rows.Count == 0)
            {
              dtUser = db.GetDataTable(sqlNonCalibrated, "@t", turboType);
            }
              }
              else
              {
            dtUser = db.GetDataTable(sqlNonCalibrated, "@t", turboType);
              }

              if (dtUser.Rows.Count > 0)
              {
            DataRow dr = dtUser.Rows[0];
            thisTurbo = new TurboTrainer();
            thisTurbo.UserId = userId;
            thisTurbo.Type = (string)(dr["type"]);
            thisTurbo.Coefficients = new double[]{(double)dr["power_model_c1"],(double)dr["power_model_c2"],(double)dr["power_model_c3"]};
              }
              db.Close();
              return thisTurbo;
        }
예제 #2
0
파일: DataHub.cs 프로젝트: Cycli/Cycli
 public void SetTurboDetails(TurboTrainer turbo)
 {
     string userId = Context.User.Identity.Name;
       turbo.Save(userId);
 }
예제 #3
0
파일: TurboTrainer.cs 프로젝트: Cycli/Cycli
        public static TurboTrainer[] LoadAll()
        {
            TurboTrainer[] turbos = new TurboTrainer[]{};

            SQLiteDatabase db = new SQLiteDatabase();
            string sql = @"select type, power_model_c1, power_model_c2, power_model_c3 from cycli_turbos order by type";
            DataTable dtTurbos = db.GetDataTable(sql);
            db.Close();

            if (dtTurbos.Rows.Count > 0)
            {
            turbos = dtTurbos.AsEnumerable().Select(p => new TurboTrainer
            {
                Type = (string)(p["type"]),
                Coefficients = new double[] { (double)p["power_model_c1"], (double)p["power_model_c2"], (double)p["power_model_c3"] }
            }).ToArray();
            }
            return turbos;
        }
예제 #4
0
파일: DataHub.cs 프로젝트: Cycli/Cycli
 public void SetRiderEquipment(UserRider rider, TurboTrainer turbo)
 {
     string userId = Context.User.Identity.Name;
     rider.SaveEquipment(userId);
     if (turbo != null)
     {
     turbo.Save(userId);
     }
     // This may have changed the configuration - kill the existing processor
     CycliManager.Instance.Kill(userId);
 }