public Config() { Maximized = false; CustomButtons = false; UseVideo = true; //currently disabled AutodetectPort by default on MACOSX if (UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX) { AutodetectPort = AutodetectPortEnum.INACTIVE; } else { AutodetectPort = AutodetectPortEnum.ACTIVE; } OnlyEncoderGravitatory = false; OnlyEncoderInertial = false; EncoderCaptureShowOnlyBars = false; EncoderUpdateTreeViewWhileCapturing = true; PersonWinHide = false; EncoderAnalyzeHide = false; Econf = null; SessionMode = SessionModeEnum.STANDARD; RunScriptOnExit = ""; }
/// <summary> /// Prepare a new output, with the given configuration. /// </summary> public OutputRouter(EncoderConfiguration.Configuration Configuration) { SyncLock = new object(); Config = Configuration; string handler = Configuration.Upload.UploadHandlerName ?? "empty"; ChunksCompleted = new Queue<ChunkDetail>(); FilesCompleted = new Queue<FileInfo>(); ShouldCleanup = true; EnableOutput = true; switch (handler.ToLower()) { case "iis smooth": Prepare_IIS(); break; case "http live": Prepare_HCS(); break; case "test": Prepare_Test(); break; default: throw new ArgumentException("Upload handler name not recognised", "Configuration"); } if (SelectedHandler == null) throw new Exception("Failed to start output handler"); SelectedHandler.FileConsumed += new EventHandler<FileEventArgs>(SelectedHandler_FileConsumed); }
private void updateGUIFromEncoderConfiguration(EncoderConfiguration ec) { //activate default radiobutton if (ec.type == Constants.EncoderType.ROTARYFRICTION) { radio_rotary_friction.Active = true; } else if (ec.type == Constants.EncoderType.ROTARYAXIS) { radio_rotary_axis.Active = true; } else //linear { radio_linear.Active = true; } check_rotary_friction_inertia_on_axis.Active = ec.rotaryFrictionOnAxis; initializeList(ec.type, ec.has_inertia, ec.rotaryFrictionOnAxis, ec.position); create_list_d_spinbutton(); putValuesStoredPreviously( ec.d, ec.list_d, ec.D, ec.anglePush, ec.angleWeight, ec.inertiaMachine, ec.extraWeightGrams, ec.extraWeightLength, ec.has_gearedDown, ec.GearedUpDisplay()); }
public FFMPEGEncoderService(ILogger <FFMPEGEncoderService> logger, EncoderConfiguration configuration, SoFakingConfiguration sofakingConfiguration) { _logger = logger; _configuration = configuration; _sofakingConfiguration = sofakingConfiguration; SetCancellationToken(); }
/// <summary> /// Create a new chunk transformer. /// Will try to create a new IIS Live Smooth Streaming publishing point matching /// the configuration settings. /// Will try both WebDAV and FTP. If neither are not correctly enabled on the destination /// server, the point must already exist. /// </summary> public ChunkTransformer(EncoderConfiguration.Configuration Configuration, bool pubPointCreationIsOptional) { SyncRoot = new object(); WaitingChunks = new Queue<ChunkDetail>(); Config = Configuration; try { PreparePublishingPoint(Config); } catch { if (!pubPointCreationIsOptional) throw; } }
/* * Use this to retrieve values after accept * do not use to know current encoder configuration * because that is stored in gui/encoder as * encoderConfigurationCurrent */ public EncoderConfiguration GetAcceptedValues() { EncoderConfiguration ec = (EncoderConfiguration)list[listCurrent]; ec.d = -1; ec.list_d = new List <double>(); ec.D = -1; ec.anglePush = -1; ec.angleWeight = -1; ec.inertiaMachine = -1; if (ec.has_d) { if (ec.has_inertia) { ec.list_d = get_list_d(); ec.d = ec.list_d[0]; //selected value is the first } else { ec.d = (double)spin_d.Value; } } if (ec.has_D) { ec.D = (double)spin_D.Value; } if (ec.has_angle_push) { ec.anglePush = (int)spin_angle_push.Value; } if (ec.has_angle_weight) { ec.angleWeight = (int)spin_angle_weight.Value; } if (ec.has_inertia) { ec.inertiaMachine = (int)spin_inertia_machine.Value; ec.inertiaTotal = (int)spin_inertia_machine.Value; ec.extraWeightGrams = (int)spin_inertia_mass.Value; ec.extraWeightLength = (double)spin_inertia_length.Value; } if (ec.has_gearedDown) { ec.SetGearedDownFromDisplay(UtilGtk.ComboGetActive(combo_gearedUp)); } return(ec); }
public static int CalculeInertiaTotal(EncoderConfiguration econf) { //LogB.Debug(econf.ToString(":",false,false)); int n = econf.extraWeightN; double weightInKg = econf.extraWeightGrams / 1000.0; double length = econf.extraWeightLength; //IM of all the weights = n * (weight * length^2) Kg*cm^2 int im_weights = Convert.ToInt32(n * (weightInKg * Math.Pow(length, 2))); return(econf.inertiaMachine + im_weights); }
public static int CalculeInertiaTotal(EncoderConfiguration econf) { //LogB.Debug(econf.ToString(":",false,false)); int n = econf.extraWeightN; double weightInKg = econf.extraWeightGrams / 1000.0; double length = econf.extraWeightLength; //IM of all the weights = n * (weight * length^2) Kg*cm^2 int im_weights = Convert.ToInt32(n * ( weightInKg * Math.Pow(length,2) )); return econf.inertiaMachine + im_weights; }
/* * <-------------------------- IfNameExistsAddSuffix ends */ //called on capture, recalculate, load public static void UpdateActive(bool dbconOpened, Constants.EncoderGI encoderGI, EncoderConfiguration econf) { openIfNeeded(dbconOpened); dbcmd.CommandText = "UPDATE " + Constants.EncoderConfigurationTable + " SET encoderConfiguration = \"" + econf.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "\"" + " WHERE encoderGI = \"" + encoderGI.ToString() + "\"" + " AND active = \"True\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); closeIfNeeded(dbconOpened); }
private void on_file_export_accepted() { TextWriter writer = File.CreateText(exportFileName); EncoderConfiguration econfOnGUI = GetAcceptedValues(); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(-1, encoderGI, true, entry_save_name.Text.ToString(), econfOnGUI, entry_save_description.Text.ToString()); writer.Write(econfSO.ToFile()); writer.Close(); ((IDisposable)writer).Dispose(); }
//if by any bug there's no active, then create default public static EncoderConfigurationSQLObject SelectActive(Constants.EncoderGI encoderGI) { Sqlite.Open(); dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderConfigurationTable + " WHERE encoderGI = \"" + encoderGI.ToString() + "\" AND active = \"True\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(); bool success = false; if (reader.Read()) { string [] strFull = reader[4].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); econf.ReadParamsFromSQL(strFull); econfSO = new EncoderConfigurationSQLObject( Convert.ToInt32(reader[0].ToString()), //uniqueID encoderGI, //encoderGI true, //active reader[3].ToString(), //name econf, //encoderConfiguration reader[5].ToString() //description ); success = true; } reader.Close(); //if by any bug there's no active, then create default and call himself again to select if (!success) { insertDefault(encoderGI); Sqlite.Close(); return(SelectActive(encoderGI)); } Sqlite.Close(); return(econfSO); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSystemd() // Linux service lifetime management .ConfigureAppConfiguration((context, builder) => { builder .SetBasePath(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)) // Required for Linux service .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json") .AddJsonFile("dbsettings.json") .AddJsonFile($"dbsettings.{context.HostingEnvironment.EnvironmentName}.json") .AddEnvironmentVariables() .Build(); }) .ConfigureServices((hostContext, services) => { var proxies = new List <string>(); hostContext.Configuration.GetSection("TPBProxies").Bind(proxies); if (proxies.Count == 0) { throw new Exception("TPB Proxies configuration missing"); } TPBProxies.SetProxies(proxies.ToArray()); var downloadFinishedWorkerConfiguration = new DownloadFinishedWorkerConfiguration(); hostContext.Configuration.GetSection("DownloadFinishedWorker").Bind(downloadFinishedWorkerConfiguration); var transmissionConfiguration = new TransmissionConfiguration(); hostContext.Configuration.GetSection("Transmission").Bind(transmissionConfiguration); var encoderConfiguration = new EncoderConfiguration(); hostContext.Configuration.GetSection("Encoder").Bind(encoderConfiguration); var sofakingConfiguration = new SoFakingConfiguration(); hostContext.Configuration.GetSection("Sofaking").Bind(sofakingConfiguration); services .AddHttpClient() .AddSingleton(transmissionConfiguration) .AddSingleton(sofakingConfiguration) .AddSingleton <TransmissionHttpClientFactory>() .AddSingleton(downloadFinishedWorkerConfiguration) .AddSingleton(encoderConfiguration) .AddSingleton(new SoFakingContextFactory()) .AddSingleton <MovieService>() .AddSingleton <TPBParserService>() .AddSingleton <ITorrentClientService, TransmissionService>() .AddSingleton <IVerifiedMovieSearchService, ImdbService>() //.AddSingleton<IEncoderService, FFMPEGEncoderService>() .AddHostedService <SoFakingWorker>(); });
//pass customName = "" to select all public static List <EncoderConfigurationSQLObject> Select(bool dbconOpened, Constants.EncoderGI encoderGI, string name) { openIfNeeded(dbconOpened); string nameStr = ""; if (name != "") { nameStr = " AND name = \"" + name + "\""; } dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderConfigurationTable + " WHERE encoderGI = \"" + encoderGI.ToString() + "\"" + nameStr; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); List <EncoderConfigurationSQLObject> list = new List <EncoderConfigurationSQLObject>(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); while (reader.Read()) { string [] strFull = reader[4].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); econf.ReadParamsFromSQL(strFull); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject( Convert.ToInt32(reader[0].ToString()), //uniqueID encoderGI, //encoderGI reader[2].ToString() == "True", //active reader[3].ToString(), //name econf, //encoderConfiguration reader[5].ToString() //description ); list.Add(econfSO); } reader.Close(); closeIfNeeded(dbconOpened); return(list); }
private void apply(bool updateGUI) { //useful fo update SQL string selectedOldName = getSelectedName(); if (selectedOldName == "") { return; } string newName = entry_save_name.Text; if (newName != selectedOldName) { /* * if name has changed, then check if newname already exists on database * if exists add _copy recursively */ newName = SqliteEncoderConfiguration.IfNameExistsAddSuffix(newName, Catalog.GetString("copy")); } //update entry_save_name if needed if (newName != entry_save_name.Text) { entry_save_name.Text = newName; } //update SQL EncoderConfiguration econfOnGUI = GetAcceptedValues(); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(-1, encoderGI, true, newName, econfOnGUI, entry_save_description.Text.ToString()); SqliteEncoderConfiguration.Update(false, encoderGI, selectedOldName, econfSO); if (updateGUI) { TreeModel model; TreeIter iter = new TreeIter(); treeview_select.Selection.GetSelected(out model, out iter); store.SetValue(iter, colName, newName); store.SetValue(iter, colDescription, entry_save_description.Text); } }
public SoFakingWorker(ILogger <SoFakingWorker> logger, ILogger <FFMPEGEncoderService> loggerEnc, IHttpClientFactory clientFactory, DownloadFinishedWorkerConfiguration configuration, MovieService movieService, ITorrentClientService torrentClient, /* IEncoderService encoderService,*/ SoFakingConfiguration sofakingConfiguration, EncoderConfiguration encoderConfiguration) { if (clientFactory == null) { throw new ArgumentNullException(nameof(clientFactory)); } if (movieService == null) { throw new ArgumentNullException(nameof(movieService)); } if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (loggerEnc == null) { throw new ArgumentNullException(nameof(loggerEnc)); } if (torrentClient == null) { throw new ArgumentNullException(nameof(torrentClient)); } if (encoderConfiguration == null) { throw new ArgumentNullException(nameof(encoderConfiguration)); } if (sofakingConfiguration == null) { throw new ArgumentNullException(nameof(sofakingConfiguration)); } _sofakingConfiguration = sofakingConfiguration; _clientFactory = clientFactory; _movieService = movieService; _configuration = configuration; _logger = logger; _loggerEnc = loggerEnc; _torrentClient = torrentClient; _encoderConfiguration = encoderConfiguration; }
/* * EncoderConfiguration */ //called on startup to load last encoderConfiguration public static EncoderConfiguration LoadEncoderConfiguration() { string ecStr = SqlitePreferences.Select("encoderConfiguration", false); //1.5.1 and previous don't store encoderConfiguration on SqlitePreferences if (ecStr == null || ecStr.Length == 0 || ecStr == "0" || ecStr == "") { return(new EncoderConfiguration()); } string [] ecStrFull = ecStr.Split(new char[] { ':' }); //create object EncoderConfiguration ec = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), ecStrFull[0])); //assign the rest of params ec.ReadParamsFromSQL(ecStrFull); return(ec); }
public Config() { Maximized = false; CustomButtons = false; UseVideo = true; //currently disabled AutodetectPort by default on MACOSX if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX) AutodetectPort = AutodetectPortEnum.INACTIVE; else AutodetectPort = AutodetectPortEnum.ACTIVE; OnlyEncoderGravitatory = false; OnlyEncoderInertial = false; EncoderCaptureShowOnlyBars = false; EncoderUpdateTreeViewWhileCapturing = true; PersonWinHide = false; EncoderAnalyzeHide = false; Econf = null; SessionMode = SessionModeEnum.STANDARD; RunScriptOnExit = ""; }
/// <summary> /// Create a new upload manager to transport HCS fragments and write a playlist in the configured location. /// The playlist will be re-written every time a fragment is successfully uploaded. /// </summary> /// <param name="Config">Job configuration.</param> public UploadManager(EncoderConfiguration.Configuration Config) { // Setup some some common strings and the upload queue pre = Config.EncoderSettings.LocalSystemFilePrefix; src = "file://" + Path.Combine(Config.EncoderSettings.LocalSystemOutputFolder, Config.EncoderSettings.LocalSystemFilePrefix); dest = Config.Upload.VideoDestinationRoot; if (String.IsNullOrEmpty(pre)) throw new Exception("Configuration is invalid. Check 'LocalSystemPrefix'"); if (String.IsNullOrEmpty(src)) throw new Exception("Configuration is invalid. Check output paths"); if (String.IsNullOrEmpty(dest)) throw new Exception("Configuration is invalid. Check 'VideoDestinationRoot'"); waitingChunks = new Queue<ChunkDetail>(); // Setup and connect the playlist writer plw = new PlaylistWriter(); plw.ServerRoot = Config.Upload.ServerLookupRoot; plw.PlaylistDestination = Config.Upload.IndexFtpRoot + Config.Upload.IndexName; plw.PlaylistFilename = Config.Upload.IndexName; plw.BaseDirectory = Config.EncoderSettings.LocalSystemOutputFolder; plw.IsClosed = false; SyncRoot = new object(); }
private void selectedModeChanged() { EncoderConfiguration ec = (EncoderConfiguration)list[listCurrent]; pixbuf = new Pixbuf(null, Util.GetImagePath(false) + ec.image); image_encoder_configuration.Pixbuf = pixbuf; TextBuffer tb1 = new TextBuffer(new TextTagTable()); tb1.Text = "[" + ec.code + "]\n" + ec.text; textview.Buffer = tb1; hbox_d.Visible = (ec.has_d && !ec.has_inertia); vbox_d.Visible = (ec.has_d && ec.has_inertia); hbox_D.Visible = ec.has_D; hbox_angle_push.Visible = ec.has_angle_push; hbox_angle_weight.Visible = ec.has_angle_weight; hbox_inertia.Visible = ec.has_inertia; hbox_inertia_mass.Visible = ec.has_inertia; hbox_inertia_length.Visible = ec.has_inertia; vbox_inertia_calcule.Visible = (ec.has_inertia && !definedInConfig); hbox_gearedUp.Visible = ec.has_gearedDown; if (ec.has_gearedDown) { combo_gearedUp.Active = UtilGtk.ComboMakeActive(combo_gearedUp, "2"); } label_count.Text = (listCurrent + 1).ToString() + " / " + list.Count.ToString(); //hide inertia moment calculation options when change mode if (show_calcule_im) { on_button_encoder_capture_inertial_show_clicked(new object(), new EventArgs()); } }
private void selectedModeChanged() { EncoderConfiguration ec = (EncoderConfiguration)list[listCurrent]; pixbuf = new Pixbuf(null, Util.GetImagePath(false) + ec.image); image_encoder_configuration.Pixbuf = pixbuf; TextBuffer tb1 = new TextBuffer(new TextTagTable()); tb1.Text = "[" + ec.code + "]\n" + ec.text; textview.Buffer = tb1; hbox_d.Visible = (ec.has_d && !ec.has_inertia); vbox_d.Visible = (ec.has_d && ec.has_inertia); hbox_D.Visible = ec.has_D; hbox_angle_push.Visible = ec.has_angle_push; hbox_angle_weight.Visible = ec.has_angle_weight; hbox_inertia.Visible = ec.has_inertia; hbox_inertia_mass.Visible = ec.has_inertia; hbox_inertia_length.Visible = ec.has_inertia; vbox_inertia_calcule.Visible = ec.has_inertia; hbox_gearedUp.Visible = ec.has_gearedDown; if (ec.has_gearedDown) { combo_gearedUp.Active = UtilGtk.ComboMakeActive(combo_gearedUp, "2"); } label_count.Text = (listCurrent + 1).ToString() + " / " + list.Count.ToString(); //hide inertia moment calculation options when change mode if (sideMode == sideModes.CAPTUREINERTIAL) { showHideSide(sideModes.HIDDEN); } }
protected internal static void insertDefault(Constants.EncoderGI encoderGI) { //note DefaultString will not be translated because gettext is changed after this inserts if (encoderGI == Constants.EncoderGI.GRAVITATORY) { Insert(true, new EncoderConfigurationSQLObject( -1, encoderGI, true, Constants.DefaultString, new EncoderConfiguration(), "") //LINEAR, not inertial ); } else if (encoderGI == Constants.EncoderGI.INERTIAL) { EncoderConfiguration ec = new EncoderConfiguration(Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL); ec.SetInertialDefaultOptions(); Insert(true, new EncoderConfigurationSQLObject( -1, encoderGI, true, Constants.DefaultString, ec, "") ); } else { LogB.Error("SqliteEncoderConfiguration.insertDefault with an ALL erroneous value"); } }
static public EncoderConfigurationWindow View(bool gravitatory, EncoderConfiguration ec, bool definedInConfig) { /* * if we are on gravitatory but ec is inertial, then put definedInConfig as false * and create a new ec that suits */ if (ec.has_inertia == gravitatory) { definedInConfig = false; if (gravitatory) { ec = new EncoderConfiguration(); //LINEAR, not inertial } else { ec = new EncoderConfiguration(Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL); ec.SetInertialDefaultOptions(); } } if (EncoderConfigurationWindowBox == null) { EncoderConfigurationWindowBox = new EncoderConfigurationWindow(definedInConfig); } //activate default radiobutton if (ec.type == Constants.EncoderType.ROTARYFRICTION) { EncoderConfigurationWindowBox.radio_rotary_friction.Active = true; } else if (ec.type == Constants.EncoderType.ROTARYAXIS) { EncoderConfigurationWindowBox.radio_rotary_axis.Active = true; } else //linear { EncoderConfigurationWindowBox.radio_linear.Active = true; } if (!ec.has_inertia) { EncoderConfigurationWindowBox.radio_gravity.Active = true; } else { EncoderConfigurationWindowBox.radio_inertia.Active = true; } EncoderConfigurationWindowBox.check_rotary_friction_inertia_on_axis.Active = ec.rotaryFrictionOnAxis; EncoderConfigurationWindowBox.initializeList(ec.type, ec.has_inertia, ec.rotaryFrictionOnAxis, ec.position); EncoderConfigurationWindowBox.create_list_d_spinbutton(); EncoderConfigurationWindowBox.putValuesStoredPreviously( ec.d, ec.list_d, ec.D, ec.anglePush, ec.angleWeight, ec.inertiaMachine, ec.extraWeightGrams, ec.extraWeightLength, ec.has_gearedDown, ec.GearedUpDisplay()); //id definedInConfig then only few things can change if (definedInConfig) { EncoderConfigurationWindowBox.hbox_encoder_types.Visible = false; EncoderConfigurationWindowBox.check_rotary_friction_inertia_on_axis.Visible = false; EncoderConfigurationWindowBox.alignment_options.Visible = false; EncoderConfigurationWindowBox.vbox_inertia_calcule.Visible = false; } EncoderConfigurationWindowBox.encoder_configuration.Show(); return(EncoderConfigurationWindowBox); }
public static ArrayList SelectSessionOverviewSets(bool dbconOpened, Constants.EncoderGI encoderGI, int sessionID) { if(! dbconOpened) Sqlite.Open(); dbcmd.CommandText = "SELECT person77.name, person77.sex, encoder.encoderConfiguration, encoderExercise.name, (personSession77.weight * encoderExercise.percentBodyWeight/100) + encoder.extraWeight, COUNT(*)" + " FROM person77, personSession77, encoderExercise, encoder" + " WHERE person77.uniqueID == encoder.personID AND personSession77.personID == encoder.personID AND personSession77.sessionID == encoder.sessionID AND encoderExercise.uniqueID==encoder.exerciseID AND signalOrCurve == \"signal\" AND encoder.sessionID == " + sessionID + " GROUP BY encoder.personID, exerciseID, extraWeight" + " ORDER BY person77.name"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(); while(reader.Read()) { //discard if != encoderGI string [] strFull = reader[2].ToString().Split(new char[] {':'}); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) ); //if encoderGI != ALL discard non wanted repetitions if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) continue; else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia) continue; if(encoderGI == Constants.EncoderGI.GRAVITATORY) { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[4].ToString(), //displaced mass (includes percentBodyeight) reader[5].ToString() //sets count }; array.Add (s); } else { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[4].ToString() //sets count }; array.Add (s); } } reader.Close(); if(! dbconOpened) Sqlite.Close(); return array; }
public static ArrayList SelectSessionOverviewSets(bool dbconOpened, Constants.EncoderGI encoderGI, int sessionID) { if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT person77.name, person77.sex, encoder.encoderConfiguration, encoderExercise.name, (personSession77.weight * encoderExercise.percentBodyWeight/100) + encoder.extraWeight, COUNT(*)" + " FROM person77, personSession77, encoderExercise, encoder" + " WHERE person77.uniqueID == encoder.personID AND personSession77.personID == encoder.personID AND personSession77.sessionID == encoder.sessionID AND encoderExercise.uniqueID==encoder.exerciseID AND signalOrCurve == \"signal\" AND encoder.sessionID == " + sessionID + " GROUP BY encoder.personID, exerciseID, extraWeight" + " ORDER BY person77.name"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(); while (reader.Read()) { //discard if != encoderGI string [] strFull = reader[2].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); //if encoderGI != ALL discard non wanted repetitions if (encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) { continue; } else if (encoderGI == Constants.EncoderGI.INERTIAL && !econf.has_inertia) { continue; } if (encoderGI == Constants.EncoderGI.GRAVITATORY) { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[4].ToString(), //displaced mass (includes percentBodyeight) reader[5].ToString() //sets count }; array.Add(s); } else { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[4].ToString() //sets count }; array.Add(s); } } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(array); }
protected void on_encoder_load_signal_accepted(object o, EventArgs args) { LogB.Information("on load signal accepted"); genericWin.Button_accept.Clicked -= new EventHandler(on_encoder_load_signal_accepted); int uniqueID = genericWin.TreeviewSelectedRowID(); genericWin.HideAndNull(); ArrayList data = SqliteEncoder.Select( false, uniqueID, currentPerson.UniqueID, currentSession.UniqueID, Constants.EncoderGI.ALL, -1, "signal", EncoderSQL.Eccons.ALL, false, true); bool success = false; foreach(EncoderSQL eSQL in data) { //it will run only one time success = UtilEncoder.CopyEncoderDataToTemp(eSQL.url, eSQL.filename); if(success) { string exerciseNameTranslated =Util.FindOnArray(':', 1, 2, eSQL.exerciseName, encoderExercisesTranslationAndBodyPWeight); combo_encoder_exercise_capture.Active = UtilGtk.ComboMakeActive(combo_encoder_exercise_capture, exerciseNameTranslated); combo_encoder_eccon.Active = UtilGtk.ComboMakeActive(combo_encoder_eccon, eSQL.ecconLong); combo_encoder_laterality.Active = UtilGtk.ComboMakeActive(combo_encoder_laterality, eSQL.laterality); spin_encoder_extra_weight.Value = Convert.ToInt32(eSQL.extraWeight); preferences.EncoderChangeMinHeight(eSQL.encoderConfiguration.has_inertia, eSQL.minHeight); //TODO: show info to user in a dialog, //but check if more info have to be shown on this process textview_encoder_signal_comment.Buffer.Text = eSQL.description; encoderTimeStamp = eSQL.GetDate(false); encoderSignalUniqueID = eSQL.uniqueID; //has to be done here, because if done in encoderThreadStart or in finishPulsebar it crashes //notebook_video_encoder.CurrentPage = 1; radiobutton_video_encoder_play.Active = true; encoderConfigurationCurrent = eSQL.encoderConfiguration; encoderConfigurationGUIUpdate(); } } //test: try to compress signal in order to send if. //obviously this is not going to be done here //LogB.Information("Trying compress function"); //LogB.Information(UtilEncoder.CompressSignal(UtilEncoder.GetEncoderDataTempFileName())); if(success) { encoderConfigurationCurrent.SQLUpdate(); //record this encoderConfiguration to SQL for next Chronojump open //force a recalculate but not save the curve (we are loading) encoderCalculeCurves(encoderActions.LOAD); radio_encoder_analyze_individual_current_set.Active = true; encoderButtonsSensitive(encoderSensEnumStored); } }
private static string[] selectAllSessionsDo(string filterName, SqliteConnection dbcon) { // This method should NOT use Sqlite.open() / Sqlite.close(): it should only use dbcon // to connect to the database. This methos is used by the importer after opening an arbitrary // ChronoJump sqlite database. It needs to be refactored to the new database system. dbcmd = dbcon.CreateCommand(); string filterNameString = ""; if (filterName != "") { filterNameString = " AND LOWER(session.name) LIKE LOWER (\"%" + filterName + "%\") "; } dbcmd.CommandText = "SELECT session.*, sport.name, speciallity.name" + " FROM session, sport, speciallity " + " WHERE session.personsSportID == sport.uniqueID " + " AND session.personsSpeciallityID == speciallity.UniqueID " + filterNameString + " ORDER BY session.uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList myArray = new ArrayList(2); int count = new int(); count = 0; while (reader.Read()) { string sportName = Catalog.GetString(reader[9].ToString()); string speciallityName = ""; //to solve a gettext bug (probably because speciallity undefined name is "") if (reader[10].ToString() != "") { speciallityName = Catalog.GetString(reader[10].ToString()); } string levelName = Catalog.GetString(Util.FindLevelName(Convert.ToInt32(reader[6]))); myArray.Add(reader[0].ToString() + ":" + reader[1].ToString() + ":" + reader[2].ToString() + ":" + UtilDate.FromSql(reader[3].ToString()).ToShortDateString() + ":" + sportName + ":" + speciallityName + ":" + levelName + ":" + reader[7].ToString()); //desc count++; } reader.Close(); /* FIXME: * all this thing it's because if someone has createds sessions without jumps or jumpers, * and we make a GROUP BY selection, this sessions doesn't appear as results * in the near future, learn better sqlite for solving this in a nicer way * */ /* another solution is not show nothing about jumpers and jumps, but show a button of "details" * this will open a new window showing this values. * this solution it's more "lighter" for people who have abig DB * */ //select persons of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.PersonSessionTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_persons; reader_persons = dbcmd.ExecuteReader(); ArrayList myArray_persons = new ArrayList(2); while (reader_persons.Read()) { myArray_persons.Add(reader_persons[0].ToString() + ":" + reader_persons[1].ToString() + ":"); } reader_persons.Close(); //select jumps of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.JumpTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_jumps; reader_jumps = dbcmd.ExecuteReader(); ArrayList myArray_jumps = new ArrayList(2); while (reader_jumps.Read()) { myArray_jumps.Add(reader_jumps[0].ToString() + ":" + reader_jumps[1].ToString() + ":"); } reader_jumps.Close(); //select jumpsRj of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.JumpRjTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_jumpsRj; reader_jumpsRj = dbcmd.ExecuteReader(); ArrayList myArray_jumpsRj = new ArrayList(2); while (reader_jumpsRj.Read()) { myArray_jumpsRj.Add(reader_jumpsRj[0].ToString() + ":" + reader_jumpsRj[1].ToString() + ":"); } reader_jumpsRj.Close(); //select runs of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.RunTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_runs; reader_runs = dbcmd.ExecuteReader(); ArrayList myArray_runs = new ArrayList(2); while (reader_runs.Read()) { myArray_runs.Add(reader_runs[0].ToString() + ":" + reader_runs[1].ToString() + ":"); } reader_runs.Close(); //select runsInterval of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.RunIntervalTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_runs_interval; reader_runs_interval = dbcmd.ExecuteReader(); ArrayList myArray_runs_interval = new ArrayList(2); while (reader_runs_interval.Read()) { myArray_runs_interval.Add(reader_runs_interval[0].ToString() + ":" + reader_runs_interval[1].ToString() + ":"); } reader_runs_interval.Close(); //select reaction time of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.ReactionTimeTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_rt; reader_rt = dbcmd.ExecuteReader(); ArrayList myArray_rt = new ArrayList(2); while (reader_rt.Read()) { myArray_rt.Add(reader_rt[0].ToString() + ":" + reader_rt[1].ToString() + ":"); } reader_rt.Close(); //select pulses of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.PulseTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_pulses; reader_pulses = dbcmd.ExecuteReader(); ArrayList myArray_pulses = new ArrayList(2); while (reader_pulses.Read()) { myArray_pulses.Add(reader_pulses[0].ToString() + ":" + reader_pulses[1].ToString() + ":"); } reader_pulses.Close(); //select multichronopic of each session dbcmd.CommandText = "SELECT sessionID, count(*) FROM " + Constants.MultiChronopicTable + " GROUP BY sessionID ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_mcs; reader_mcs = dbcmd.ExecuteReader(); ArrayList myArray_mcs = new ArrayList(2); while (reader_mcs.Read()) { myArray_mcs.Add(reader_mcs[0].ToString() + ":" + reader_mcs[1].ToString() + ":"); } reader_mcs.Close(); //select encoder stuff of each session dbcmd.CommandText = "SELECT sessionID, encoderConfiguration, signalOrCurve FROM " + Constants.EncoderTable + " ORDER BY sessionID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader_enc = dbcmd.ExecuteReader(); ArrayList myArray_enc_g_s = new ArrayList(2); //gravitatory sets ArrayList myArray_enc_g_r = new ArrayList(2); //gravitatory repetitions ArrayList myArray_enc_i_s = new ArrayList(2); //inertial sets ArrayList myArray_enc_i_r = new ArrayList(2); //inertial repetitions int count_g_s = 0; int count_g_r = 0; int count_i_s = 0; int count_i_r = 0; int sessionBefore = -1; int sessionNow = -1; while (reader_enc.Read()) { //get econf to separate gravitatory and inertial string [] strFull = reader_enc[1].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); sessionNow = Convert.ToInt32(reader_enc[0].ToString()); if (sessionNow != sessionBefore && sessionBefore != -1) { myArray_enc_g_s.Add(sessionBefore.ToString() + ":" + count_g_s.ToString() + ":"); myArray_enc_g_r.Add(sessionBefore.ToString() + ":" + count_g_r.ToString() + ":"); myArray_enc_i_s.Add(sessionBefore.ToString() + ":" + count_i_s.ToString() + ":"); myArray_enc_i_r.Add(sessionBefore.ToString() + ":" + count_i_r.ToString() + ":"); count_g_s = 0; count_g_r = 0; count_i_s = 0; count_i_r = 0; } sessionBefore = sessionNow; if (!econf.has_inertia) { if (reader_enc[2].ToString() == "signal") { count_g_s++; } else { count_g_r++; } } else { if (reader_enc[2].ToString() == "signal") { count_i_s++; } else { count_i_r++; } } } myArray_enc_g_s.Add(sessionBefore.ToString() + ":" + count_g_s.ToString() + ":"); myArray_enc_g_r.Add(sessionBefore.ToString() + ":" + count_g_r.ToString() + ":"); myArray_enc_i_s.Add(sessionBefore.ToString() + ":" + count_i_s.ToString() + ":"); myArray_enc_i_r.Add(sessionBefore.ToString() + ":" + count_i_r.ToString() + ":"); reader_enc.Close(); //mix nine arrayLists string [] mySessions = new string[count]; count = 0; bool found; string result_enc_s; //sets string result_enc_r; //repetitions foreach (string line in myArray) { string lineNotReadOnly = line; //if some sessions are deleted, do not use count=0 to mix arrays, use sessionID of line string [] mixingSessionFull = line.Split(new char[] { ':' }); string mixingSessionID = mixingSessionFull[0]; //add persons for each session found = false; foreach (string line_persons in myArray_persons) { string [] myStringFull = line_persons.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add jumps for each session found = false; foreach (string line_jumps in myArray_jumps) { string [] myStringFull = line_jumps.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add jumpsRj for each session found = false; foreach (string line_jumpsRj in myArray_jumpsRj) { string [] myStringFull = line_jumpsRj.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add runs for each session found = false; foreach (string line_runs in myArray_runs) { string [] myStringFull = line_runs.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add runsInterval for each session found = false; foreach (string line_runs_interval in myArray_runs_interval) { string [] myStringFull = line_runs_interval.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add reaction time for each session found = false; foreach (string line_rt in myArray_rt) { string [] myStringFull = line_rt.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add pulses for each session found = false; foreach (string line_pulses in myArray_pulses) { string [] myStringFull = line_pulses.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add multiChronopic for each session found = false; foreach (string line_mcs in myArray_mcs) { string [] myStringFull = line_mcs.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { lineNotReadOnly = lineNotReadOnly + ":" + myStringFull[1]; found = true; } } if (!found) { lineNotReadOnly = lineNotReadOnly + ":0"; } //add encoder gravitatory for each session (sets ; repetitions) result_enc_s = "0"; result_enc_r = "0"; foreach (string line_enc_g_s in myArray_enc_g_s) { string [] myStringFull = line_enc_g_s.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { result_enc_s = myStringFull[1]; } } foreach (string line_enc_g_r in myArray_enc_g_r) { string [] myStringFull = line_enc_g_r.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { result_enc_r = myStringFull[1]; } } lineNotReadOnly = lineNotReadOnly + ":" + result_enc_s + " ; " + result_enc_r; //add encoder inertial for each session (sets ; repetitions) result_enc_s = "0"; result_enc_r = "0"; foreach (string line_enc_i_s in myArray_enc_i_s) { string [] myStringFull = line_enc_i_s.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { result_enc_s = myStringFull[1]; } } foreach (string line_enc_i_r in myArray_enc_i_r) { string [] myStringFull = line_enc_i_r.Split(new char[] { ':' }); if (myStringFull[0] == mixingSessionID) { result_enc_r = myStringFull[1]; } } lineNotReadOnly = lineNotReadOnly + ":" + result_enc_s + " ; " + result_enc_r; mySessions [count++] = lineNotReadOnly; } if (mySessions.Length > 0) { LogB.SQL(mySessions [0]); } else { LogB.Debug("SelectAllSessions with filter: " + filterName + " is empty"); } return(mySessions); }
//pass uniqueID value and then will return one record. do like this: //EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, myUniqueID, 0, 0, 0, "", EncoderSQL.Eccons.ALL, false, true)[0]; //WARNING because SqliteEncoder.Select may not return nothing, and then cannot be assigned to eSQL //see: delete_encoder_curve(bool dbconOpened, int uniqueID) //don't care for the 0, 0, 0 because selection will be based on the myUniqueID and only one row will be returned //or //pass uniqueID==-1 and personID, sessionID, signalOrCurve values, and will return some records //personID can be -1 to get all on that session //sessionID can be -1 to get all sessions //exerciseID can be -1 to get all exercises //signalOrCurve can be "all" //orderIDascendent is good for all the situations except when we want to convert from 1.05 to 1.06 //in that conversion, we want first the last ones, and later the previous // (to delete them if they are old copies) public static ArrayList Select( bool dbconOpened, int uniqueID, int personID, int sessionID, Constants.EncoderGI encoderGI, int exerciseID, string signalOrCurve, EncoderSQL.Eccons ecconSelect, bool onlyActive, bool orderIDascendent) { if (!dbconOpened) { Sqlite.Open(); } string personIDStr = ""; if (personID != -1) { personIDStr = " personID = " + personID + " AND "; } string sessionIDStr = ""; if (sessionID != -1) { sessionIDStr = " sessionID = " + sessionID + " AND "; } string exerciseIDStr = ""; if (exerciseID != -1) { exerciseIDStr = " exerciseID = " + exerciseID + " AND "; } string selectStr = ""; if (uniqueID != -1) { selectStr = Constants.EncoderTable + ".uniqueID = " + uniqueID; } else { if (signalOrCurve == "all") { selectStr = personIDStr + sessionIDStr + exerciseIDStr; } else { selectStr = personIDStr + sessionIDStr + exerciseIDStr + " signalOrCurve = \"" + signalOrCurve + "\""; } if (ecconSelect != EncoderSQL.Eccons.ALL) { selectStr += " AND " + Constants.EncoderTable + ".eccon = \"" + EncoderSQL.Eccons.ecS.ToString() + "\""; } } string andString = ""; if (selectStr != "") { andString = " AND "; } string onlyActiveString = ""; if (onlyActive) { onlyActiveString = " AND " + Constants.EncoderTable + ".status = \"active\" "; } string orderIDstr = ""; if (!orderIDascendent) { orderIDstr = " DESC"; } dbcmd.CommandText = "SELECT " + Constants.EncoderTable + ".*, " + Constants.EncoderExerciseTable + ".name FROM " + Constants.EncoderTable + ", " + Constants.EncoderExerciseTable + " WHERE " + selectStr + andString + Constants.EncoderTable + ".exerciseID = " + Constants.EncoderExerciseTable + ".uniqueID " + onlyActiveString + " ORDER BY substr(filename,-23,19), " + //'filename,-23,19' has the date of capture signal "uniqueID " + orderIDstr; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(1); EncoderSQL es = new EncoderSQL(); while (reader.Read()) { string [] strFull = reader[15].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); econf.ReadParamsFromSQL(strFull); //if encoderGI != ALL discard non wanted repetitions if (encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) { continue; } else if (encoderGI == Constants.EncoderGI.INERTIAL && !econf.has_inertia) { continue; } LogB.Debug("EncoderConfiguration = " + econf.ToStringOutput(EncoderConfiguration.Outputs.SQL)); //if there's no video, will be "". //if there's video, will be with full path string videoURL = ""; if (reader[14].ToString() != "") { videoURL = addURLpath(fixOSpath(reader[14].ToString())); } //LogB.SQL(econf.ToString(":", true)); es = new EncoderSQL( reader[0].ToString(), //uniqueID Convert.ToInt32(reader[1].ToString()), //personID Convert.ToInt32(reader[2].ToString()), //sessionID Convert.ToInt32(reader[3].ToString()), //exerciseID reader[4].ToString(), //eccon Catalog.GetString(reader[5].ToString()), //laterality reader[6].ToString(), //extraWeight reader[7].ToString(), //signalOrCurve reader[8].ToString(), //filename addURLpath(fixOSpath(reader[9].ToString())), //url Convert.ToInt32(reader[10].ToString()), //time Convert.ToInt32(reader[11].ToString()), //minHeight reader[12].ToString(), //description reader[13].ToString(), //status videoURL, //videoURL econf, //encoderConfiguration Util.ChangeDecimalSeparator(reader[16].ToString()), //future1 (meanPower on curves) reader[17].ToString(), //future2 reader[18].ToString(), //future3 reader[19].ToString() //EncoderExercise.name ); array.Add(es); } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(array); }
//called on load signal //if does not found any encoderConfiguration then return one with -1 as uniqueID public static EncoderConfigurationSQLObject SelectByEconf(bool dbconOpened, Constants.EncoderGI encoderGI, EncoderConfiguration econf) { openIfNeeded(dbconOpened); dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderConfigurationTable + " WHERE encoderGI = \"" + encoderGI.ToString() + "\"" + " AND encoderConfiguration LIKE \"" + econf.ToStringOutput(EncoderConfiguration.Outputs.SQLECWINCOMPARE) + "\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(); if (reader.Read()) { econfSO = new EncoderConfigurationSQLObject( Convert.ToInt32(reader[0].ToString()), //uniqueID encoderGI, //encoderGI true, //active reader[3].ToString(), //name econf, //encoderConfiguration reader[5].ToString() //description ); } reader.Close(); Sqlite.Close(); return(econfSO); }
public static bool ConvertToLastChronojumpDBVersion() { LogB.SQL("SelectChronojumpProfile ()"); //if(checkIfIsSqlite2()) // convertSqlite2To3(); addChronopicPortNameIfNotExists(); currentVersion = SqlitePreferences.Select("databaseVersion"); //LogB.SQL("lastDB: {0}", Convert.ToDouble(lastChronojumpDatabaseVersion)); //LogB.SQL("currentVersion: {0}", Convert.ToDouble(currentVersion)); bool returnSoftwareIsNew = true; //-1 if software is too old for database (moved db to other computer) if( Convert.ToDouble(Util.ChangeDecimalSeparator(lastChronojumpDatabaseVersion)) == Convert.ToDouble(Util.ChangeDecimalSeparator(currentVersion))) LogB.SQL("Database is already latest version"); else if( Convert.ToDouble(Util.ChangeDecimalSeparator(lastChronojumpDatabaseVersion)) < Convert.ToDouble(Util.ChangeDecimalSeparator(currentVersion))) { LogB.SQL("User database newer than program, need to update software"); returnSoftwareIsNew = false; } else { LogB.Warning("Old database, need to convert"); LogB.Warning("db version: " + currentVersion); bool needToConvertPersonToSport = false; bool jumpFallAsDouble = false; bool runAndRunIntervalInitialSpeedAdded = false; bool addedRSA = false; SqliteJumpRj sqliteJumpRjObject = new SqliteJumpRj(); SqliteRunInterval sqliteRunIntervalObject = new SqliteRunInterval(); SqliteReactionTime sqliteReactionTimeObject = new SqliteReactionTime(); SqlitePulse sqlitePulseObject = new SqlitePulse(); SqliteMultiChronopic sqliteMultiChronopicObject = new SqliteMultiChronopic(); SqlitePersonSessionOld sqlitePersonSessionOldObject = new SqlitePersonSessionOld(); if(currentVersion == "0.41") { Sqlite.Open(); //SqlitePulse.createTable(Constants.PulseTable); sqlitePulseObject.createTable(Constants.PulseTable); SqlitePulseType.createTablePulseType(); SqlitePulseType.initializeTablePulseType(); SqlitePreferences.Update ("databaseVersion", "0.42", true); LogB.SQL("Converted DB to 0.42 (added pulse and pulseType tables)"); Sqlite.Close(); currentVersion = "0.42"; } if(currentVersion == "0.42") { Sqlite.Open(); SqlitePulseType.Insert ("Free:-1:-1:free PulseStep mode", true); SqlitePreferences.Insert ("language", "es-ES"); SqlitePreferences.Update ("databaseVersion", "0.43", true); LogB.SQL("Converted DB to 0.43 (added 'free' pulseType & language peference)"); Sqlite.Close(); currentVersion = "0.43"; } if(currentVersion == "0.43") { Sqlite.Open(); SqlitePreferences.Insert ("showQIndex", "False"); SqlitePreferences.Insert ("showDjIndex", "False"); SqlitePreferences.Update ("databaseVersion", "0.44", true); LogB.SQL("Converted DB to 0.44 (added showQIndex, showDjIndex)"); Sqlite.Close(); currentVersion = "0.44"; } if(currentVersion == "0.44") { Sqlite.Open(); SqlitePreferences.Insert ("allowFinishRjAfterTime", "True"); SqlitePreferences.Update ("databaseVersion", "0.45", true); LogB.SQL("Converted DB to 0.45 (added allowFinishRjAfterTime)"); Sqlite.Close(); currentVersion = "0.45"; } if(currentVersion == "0.45") { Sqlite.Open(); SqliteJumpType.JumpTypeInsert ("Free:1:0:Free jump", true); SqlitePreferences.Update ("databaseVersion", "0.46", true); LogB.SQL("Added Free jump type"); Sqlite.Close(); currentVersion = "0.46"; } if(currentVersion == "0.46") { Sqlite.Open(); //SqliteReactionTime.createTable(Constants.ReactionTimeTable); sqliteReactionTimeObject.createTable(Constants.ReactionTimeTable); SqlitePreferences.Update ("databaseVersion", "0.47", true); LogB.SQL("Added reaction time table"); Sqlite.Close(); currentVersion = "0.47"; } if(currentVersion == "0.47") { Sqlite.Open(); //SqliteJumpRj.createTable(Constants.TempJumpRjTable); sqliteJumpRjObject.createTable(Constants.TempJumpRjTable); //SqliteRun.intervalCreateTable(Constants.TempRunIntervalTable); sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable); SqlitePreferences.Update ("databaseVersion", "0.48", true); LogB.SQL("created tempJumpReactive and tempRunInterval tables"); Sqlite.Close(); currentVersion = "0.48"; } if(currentVersion == "0.48") { Sqlite.Open(); SqliteJumpType.JumpTypeInsert ("Rocket:1:0:Rocket jump", true); string [] iniRunTypes = { "Agility-20Yard:18.28:20Yard Agility test", "Agility-505:10:505 Agility test", "Agility-Illinois:60:Illinois Agility test", "Agility-Shuttle-Run:40:Shuttle Run Agility test", "Agility-ZigZag:17.6:ZigZag Agility test" }; foreach(string myString in iniRunTypes) { string [] s = myString.Split(new char[] {':'}); RunType type = new RunType(); type.Name = s[0]; type.Distance = Convert.ToDouble(s[1]); type.Description = s[2]; SqliteRunType.Insert(type, Constants.RunTypeTable, true); } SqliteEvent.createGraphLinkTable(); SqliteRunType.AddGraphLinksRunSimpleAgility(); SqlitePreferences.Update ("databaseVersion", "0.49", true); LogB.SQL("Added graphLinkTable, added Rocket jump and 5 agility tests: (20Yard, 505, Illinois, Shuttle-Run & ZigZag. Added graphs pof the 5 agility tests)"); Sqlite.Close(); currentVersion = "0.49"; } if(currentVersion == "0.49") { Sqlite.Open(); SqliteJumpType.Update ("SJ+", "SJl"); SqliteJumpType.Update ("CMJ+", "CJl"); SqliteJumpType.Update ("ABK+", "ABKl"); SqliteJump.ChangeWeightToL(); SqliteJumpType.AddGraphLinks(); SqliteJumpType.AddGraphLinksRj(); SqlitePreferences.Update ("databaseVersion", "0.50", true); LogB.SQL("changed SJ+ to SJl, same for CMJ+ and ABK+, added jump and jumpRj graph links"); Sqlite.Close(); currentVersion = "0.50"; } if(currentVersion == "0.50") { Sqlite.Open(); SqliteRunType.AddGraphLinksRunSimple(); SqliteRunIntervalType.AddGraphLinksRunInterval(); SqlitePreferences.Update ("databaseVersion", "0.51", true); LogB.SQL("added graphLinks for run simple and interval"); Sqlite.Close(); currentVersion = "0.51"; } if(currentVersion == "0.51") { Sqlite.Open(); SqliteJumpType.Update ("CJl", "CMJl"); SqliteEvent.GraphLinkInsert (Constants.JumpTable, "CMJl", "jump_cmj_l.png", true); SqliteEvent.GraphLinkInsert (Constants.JumpTable, "ABKl", "jump_abk_l.png", true); SqlitePreferences.Update ("databaseVersion", "0.52", true); LogB.SQL("added graphLinks for cmj_l and abk_l, fixed CMJl name"); Sqlite.Close(); currentVersion = "0.52"; } if(currentVersion == "0.52") { Sqlite.Open(); sqlitePersonSessionOldObject.createTable (); Sqlite.Close(); //this needs the dbCon closed SqlitePersonSessionOld.moveOldTableToNewTable (); Sqlite.Open(); SqlitePreferences.Update ("databaseVersion", "0.53", true); Sqlite.Close(); LogB.SQL("created weightSession table. Moved person weight data to weightSession table for each session that has performed"); currentVersion = "0.53"; } if(currentVersion == "0.53") { Sqlite.Open(); SqliteSport.createTable(); SqliteSport.initialize(); SqliteSpeciallity.createTable(); SqliteSpeciallity.initialize(); //SqlitePersonOld.convertTableToSportRelated (); needToConvertPersonToSport = true; SqlitePreferences.Update ("databaseVersion", "0.54", true); Sqlite.Close(); LogB.SQL("Created sport tables. Added sport data, speciallity and level of practice to person table"); currentVersion = "0.54"; } if(currentVersion == "0.54") { Sqlite.Open(); SqliteSpeciallity.InsertUndefined(true); SqlitePreferences.Update ("databaseVersion", "0.55", true); Sqlite.Close(); LogB.SQL("Added undefined to speciallity table"); currentVersion = "0.55"; } if(currentVersion == "0.55") { Sqlite.Open(); SqliteSessionOld.convertTableAddingSportStuff(); SqlitePreferences.Update ("databaseVersion", "0.56", true); Sqlite.Close(); LogB.SQL("Added session default sport stuff into session table"); currentVersion = "0.56"; } if(currentVersion == "0.56") { Sqlite.Open(); //jump and jumpRj ArrayList arrayAngleAndSimulated = new ArrayList(1); arrayAngleAndSimulated.Add("-1"); //angle arrayAngleAndSimulated.Add("-1"); //simulated //run and runInterval ArrayList arraySimulatedAndInitialSpeed = new ArrayList(1); arraySimulatedAndInitialSpeed.Add("-1"); //simulated arraySimulatedAndInitialSpeed.Add("0"); //initial speed //others ArrayList arraySimulated = new ArrayList(1); arraySimulated.Add("-1"); //simulated conversionRateTotal = 9; conversionRate = 1; convertTables(new SqliteJump(), Constants.JumpTable, 9, arrayAngleAndSimulated, false); conversionRate ++; convertTables(new SqliteJumpRj(), Constants.JumpRjTable, 16, arrayAngleAndSimulated, false); conversionRate ++; convertTables(new SqliteRun(), Constants.RunTable, 7, arraySimulated, false); conversionRate ++; convertTables(new SqliteRunInterval(), Constants.RunIntervalTable, 11, arraySimulated, false); runAndRunIntervalInitialSpeedAdded = true; conversionRate ++; convertTables(new SqliteReactionTime(), Constants.ReactionTimeTable, 6, arraySimulated, false); conversionRate ++; convertTables(new SqlitePulse(), Constants.PulseTable, 8, arraySimulated, false); //reacreate temp tables for have also the simulated column conversionRate ++; Sqlite.dropTable(Constants.TempJumpRjTable); sqliteJumpRjObject.createTable(Constants.TempJumpRjTable); Sqlite.dropTable(Constants.TempRunIntervalTable); sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable); conversionRate ++; SqliteCountry.createTable(); SqliteCountry.initialize(); conversionRate ++; int columnsBefore = 10; bool putDescriptionInMiddle = false; ArrayList arrayPersonRaceCountryServerID = new ArrayList(1); if(needToConvertPersonToSport) { columnsBefore = 7; arrayPersonRaceCountryServerID.Add(Constants.SportUndefinedID.ToString()); arrayPersonRaceCountryServerID.Add(Constants.SpeciallityUndefinedID.ToString()); arrayPersonRaceCountryServerID.Add(Constants.LevelUndefinedID.ToString()); putDescriptionInMiddle = true; } arrayPersonRaceCountryServerID.Add(Constants.RaceUndefinedID.ToString()); arrayPersonRaceCountryServerID.Add(Constants.CountryUndefinedID.ToString()); arrayPersonRaceCountryServerID.Add(Constants.ServerUndefinedID.ToString()); convertTables(new SqlitePersonOld(), Constants.PersonOldTable, columnsBefore, arrayPersonRaceCountryServerID, putDescriptionInMiddle); SqlitePreferences.Update ("databaseVersion", "0.57", true); Sqlite.Close(); LogB.SQL("Added simulated column to each event table on client. Added to person: race, country, serverUniqueID. Convert to sport related done here if needed. Added also run and runInterval initial speed"); currentVersion = "0.57"; } if(currentVersion == "0.57") { Sqlite.Open(); //check if "republic" is in country table if(SqliteCountry.TableHasOldRepublicStuff()){ conversionRateTotal = 4; conversionRate = 1; Sqlite.dropTable(Constants.CountryTable); conversionRate ++; SqliteCountry.createTable(); conversionRate ++; SqliteCountry.initialize(); conversionRate ++; LogB.SQL("Countries without kingdom or republic (except when needed)"); } SqlitePreferences.Update ("databaseVersion", "0.58", true); Sqlite.Close(); currentVersion = "0.58"; } if(currentVersion == "0.58") { Sqlite.Open(); conversionRateTotal = 2; conversionRate = 1; SqlitePreferences.Insert ("showAngle", "False"); alterTableColumn(new SqliteJump(), Constants.JumpTable, 11); //jump fall is also converted to double (don't need to do at conversion to 0.76) jumpFallAsDouble = true; SqlitePreferences.Update ("databaseVersion", "0.59", true); LogB.SQL("Converted DB to 0.59 (added 'showAngle' to preferences, changed angle on jump to double)"); conversionRate = 2; Sqlite.Close(); currentVersion = "0.59"; } if(currentVersion == "0.59") { Sqlite.Open(); conversionRateTotal = 4; conversionRate = 1; SqlitePreferences.Insert ("volumeOn", "True"); SqlitePreferences.Insert ("evaluatorServerID", "-1"); conversionRate = 2; int columnsBefore = 8; ArrayList arrayServerID = new ArrayList(1); arrayServerID.Add(Constants.ServerUndefinedID.ToString()); convertTables(new SqliteSession(), Constants.SessionTable, columnsBefore, arrayServerID, false); conversionRate = 3; SqliteEvent.SimulatedConvertToNegative(); SqlitePreferences.Update ("databaseVersion", "0.60", true); LogB.SQL("Converted DB to 0.60 (added volumeOn and evaluatorServerID to preferences. session has now serverUniqueID. Simulated now are -1, because 0 is real and positive is serverUniqueID)"); conversionRate = 4; Sqlite.Close(); currentVersion = "0.60"; } if(currentVersion == "0.60") { Sqlite.Open(); conversionRateTotal = 3; conversionRate = 1; ArrayList arrayDS = new ArrayList(1); arrayDS.Add("-1"); //distancesString convertTables(new SqliteRunIntervalType(), Constants.RunIntervalTypeTable, 7, arrayDS, false); conversionRate = 2; //SqliteRunType.RunIntervalTypeInsert ("MTGUG:-1:true:3:false:Modified time Getup and Go test:1-7-19", true); RunType type = new RunType(); type.Name = "MTGUG"; type.Distance = -1; type.TracksLimited = true; type.FixedValue = 3; type.Unlimited = false; type.Description = "Modified time Getup and Go test"; type.DistancesString = "1-7-19"; SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true); SqlitePreferences.Update ("databaseVersion", "0.61", true); LogB.SQL("Converted DB to 0.61 added RunIntervalType distancesString (now we van have interval tests with different distances of tracks). Added MTGUG"); conversionRate = 3; Sqlite.Close(); currentVersion = "0.61"; } if(currentVersion == "0.61") { Sqlite.Open(); SqliteJumpType.JumpRjTypeInsert ("RJ(hexagon):1:0:1:18:Reactive Jump on a hexagon until three full revolutions are done", true); SqlitePreferences.Update ("databaseVersion", "0.62", true); LogB.SQL("Converted DB to 0.62 added hexagon"); Sqlite.Close(); currentVersion = "0.62"; } if(currentVersion == "0.62") { Sqlite.Open(); SqlitePreferences.Insert ("versionAvailable", ""); SqlitePreferences.Update ("databaseVersion", "0.63", true); LogB.SQL("Converted DB to 0.63 (added 'versionAvailable' to preferences)"); Sqlite.Close(); currentVersion = "0.63"; } if(currentVersion == "0.63") { Sqlite.Open(); RunType type = new RunType(); type.Name = "Margaria"; type.Distance = 0; type.Description = "Margaria-Kalamen test"; SqliteRunType.Insert(type, Constants.RunTypeTable, true); SqliteEvent.GraphLinkInsert (Constants.RunTable, "Margaria", "margaria.png", true); SqlitePreferences.Update ("databaseVersion", "0.64", true); LogB.SQL("Converted DB to 0.64 (added margaria test)"); Sqlite.Close(); currentVersion = "0.64"; } if(currentVersion == "0.64") { Sqlite.Open(); SqliteServer sqliteServerObject = new SqliteServer(); //user has also an evaluator table with a row (it's row) sqliteServerObject.CreateEvaluatorTable(); SqlitePreferences.Update ("databaseVersion", "0.65", true); LogB.SQL("Converted DB to 0.65 (added Sevaluator on client)"); Sqlite.Close(); currentVersion = "0.65"; } if(currentVersion == "0.65") { Sqlite.Open(); //now runAnalysis is a multiChronopic event //SqliteJumpType.JumpRjTypeInsert ("RunAnalysis:0:0:1:-1:Run between two photocells recording contact and flight times in contact platform/s. Until finish button is clicked.", true); SqlitePreferences.Update ("databaseVersion", "0.66", true); //LogB.SQL("Converted DB to 0.66 (added RunAnalysis Reactive jump)"); LogB.SQL("Converted DB to 0.66 (done nothing)"); Sqlite.Close(); currentVersion = "0.66"; } if(currentVersion == "0.66") { Sqlite.Open(); SqliteJumpType.JumpTypeInsert ("TakeOff:0:0:Take off", true); SqliteJumpType.JumpTypeInsert ("TakeOffWeight:0:0:Take off with weight", true); SqlitePreferences.Update ("databaseVersion", "0.67", true); LogB.SQL("Converted DB to 0.67 (added TakeOff jumps)"); Sqlite.Close(); currentVersion = "0.67"; } if(currentVersion == "0.67") { Sqlite.Open(); sqliteMultiChronopicObject.createTable(Constants.MultiChronopicTable); SqlitePreferences.Update ("databaseVersion", "0.68", true); LogB.SQL("Converted DB to 0.68 (added multiChronopic tests table)"); Sqlite.Close(); currentVersion = "0.68"; } if(currentVersion == "0.68") { Sqlite.Open(); RunType type = new RunType(); type.Name = "Gesell-DBT"; type.Distance = 2.5; type.Description = "Gesell Dynamic Balance Test"; SqliteRunType.Insert(type, Constants.RunTypeTable, true); SqliteEvent.GraphLinkInsert (Constants.RunTable, "Gesell-DBT", "gesell_dbt.png", true); SqlitePreferences.Update ("databaseVersion", "0.69", true); LogB.SQL("Converted DB to 0.69 (added Gesell-DBT test)"); Sqlite.Close(); currentVersion = "0.69"; } if(currentVersion == "0.69") { Sqlite.Open(); SqlitePreferences.Insert ("showPower", "True"); SqlitePreferences.Update ("databaseVersion", "0.70", true); LogB.SQL("Converted DB to 0.70 (added showPower)"); Sqlite.Close(); currentVersion = "0.70"; } if(currentVersion == "0.70") { Sqlite.Open(); SqlitePersonSessionNotUpload.CreateTable(); SqlitePreferences.Update ("databaseVersion", "0.71", true); LogB.SQL("Converted DB to 0.71 (created personNotUploadTable on client)"); Sqlite.Close(); currentVersion = "0.71"; } if(currentVersion == "0.71") { Sqlite.Open(); datesToYYYYMMDD(); SqlitePreferences.Update ("databaseVersion", "0.72", true); LogB.SQL("Converted DB to 0.72 (dates to YYYY-MM-DD)"); Sqlite.Close(); currentVersion = "0.72"; } if(currentVersion == "0.72") { Sqlite.Open(); deleteOrphanedPersonsOld(); SqlitePreferences.Update ("databaseVersion", "0.73", true); LogB.SQL("Converted DB to 0.73 (deleted orphaned persons (in person table but not in personSessionWeight table)"); Sqlite.Close(); currentVersion = "0.73"; } if(currentVersion == "0.73") { //dbcon open laters on mid convertDJinDJna() convertDJInDJna(); SqlitePreferences.Update ("databaseVersion", "0.74", true); LogB.SQL("Converted DB to 0.74 (All DJ converted to DJna)"); Sqlite.Close(); currentVersion = "0.74"; } if(currentVersion == "0.74") { conversionRateTotal = 3; conversionRate = 1; Sqlite.Open(); convertTables(new SqlitePersonOld(), Constants.PersonOldTable, 13, new ArrayList(), false); conversionRate++; convertTables(new SqlitePersonSessionOld(), Constants.PersonSessionOldWeightTable, 4, new ArrayList(), false); SqlitePreferences.Update ("databaseVersion", "0.75", true); conversionRate++; LogB.SQL("Converted DB to 0.75 (person, and personSessionWeight have height and weight as double)"); Sqlite.Close(); currentVersion = "0.75"; } if(currentVersion == "0.75") { conversionRateTotal = 3; conversionRate = 1; Sqlite.Open(); if(!jumpFallAsDouble) alterTableColumn(new SqliteJump(), Constants.JumpTable, 11); conversionRate++; alterTableColumn(new SqliteJumpRj(), Constants.JumpRjTable, 18); SqlitePreferences.Update ("databaseVersion", "0.76", true); conversionRate++; LogB.SQL("Converted DB to 0.76 (jump & jumpRj falls as double)"); Sqlite.Close(); currentVersion = "0.76"; } if(currentVersion == "0.76") { Sqlite.Open(); convertPersonAndPersonSessionTo77(); SqlitePreferences.Update ("databaseVersion", "0.77", true); LogB.SQL("Converted DB to 0.77 (person77, personSession77)"); Sqlite.Close(); currentVersion = "0.77"; } if(currentVersion == "0.77") { Sqlite.Open(); SqliteJumpType.UpdateOther ("weight", Constants.TakeOffWeightName, "1"); Random rnd = new Random(); string machineID = rnd.Next().ToString(); SqlitePreferences.Insert ("machineID", machineID); SqlitePreferences.Update ("databaseVersion", "0.78", true); LogB.SQL("Converted DB to 0.78 (Added machineID to preferences, takeOffWeight has no weight in db conversions since 0.66)"); Sqlite.Close(); currentVersion = "0.78"; } if(currentVersion == "0.78") { Sqlite.Open(); SqlitePreferences.Insert ("multimediaStorage", Constants.MultimediaStorage.BYSESSION.ToString()); SqlitePreferences.Update ("databaseVersion", "0.79", true); LogB.SQL("Converted DB to 0.79 (Added multimediaStorage structure id)"); Sqlite.Close(); currentVersion = "0.79"; } if(currentVersion == "0.79") { Sqlite.Open(); if(! runAndRunIntervalInitialSpeedAdded) { ArrayList myArray = new ArrayList(1); myArray.Add("0"); //initial speed conversionRateTotal = 3; conversionRate = 1; convertTables(new SqliteRun(), Constants.RunTable, 8, myArray, false); conversionRate ++; convertTables(new SqliteRunInterval(), Constants.RunIntervalTable, 12, myArray, false); conversionRate ++; LogB.SQL("Converted DB to 0.80 Added run and runInterval initial speed (if not done in 0.56 conversion)"); } SqlitePreferences.Update ("databaseVersion", "0.80", true); Sqlite.Close(); currentVersion = "0.80"; } if(currentVersion == "0.80") { Sqlite.Open(); ArrayList myArray = new ArrayList(1); myArray.Add("0"); //initial speed conversionRateTotal = 2; conversionRate = 1; Sqlite.dropTable(Constants.TempRunIntervalTable); sqliteRunIntervalObject.createTable(Constants.TempRunIntervalTable); conversionRate ++; LogB.SQL("Converted DB to 0.81 Added tempRunInterval initial speed"); SqlitePreferences.Update ("databaseVersion", "0.81", true); Sqlite.Close(); currentVersion = "0.81"; } if(currentVersion == "0.81") { Sqlite.Open(); conversionRateTotal = 2; conversionRate = 1; SqlitePreferences.Insert ("videoOn", "False"); conversionRate = 2; LogB.SQL("Converted DB to 0.82 Added videoOn"); SqlitePreferences.Update ("databaseVersion", "0.82", true); Sqlite.Close(); currentVersion = "0.82"; } if(currentVersion == "0.82") { Sqlite.Open(); conversionRateTotal = 2; conversionRate = 1; SqliteEncoder.createTableEncoder(); SqliteEncoder.createTableEncoderExercise(); SqliteEncoder.initializeTableEncoderExercise(); conversionRate = 2; LogB.SQL("Created encoder tables."); SqlitePreferences.Update ("databaseVersion", "0.83", true); Sqlite.Close(); currentVersion = "0.83"; } if(currentVersion == "0.83") { Sqlite.Open(); RunType type = new RunType(); type.Name = "RSA 8-4-R3-5"; type.Distance = -1; type.TracksLimited = true; type.FixedValue = 4; type.Unlimited = false; type.Description = "RSA testing"; type.DistancesString = "8-4-R3-5"; SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true); LogB.SQL("Added 1st RSA test."); SqlitePreferences.Update ("databaseVersion", "0.84", true); Sqlite.Close(); currentVersion = "0.84"; } if(currentVersion == "0.84") { Sqlite.Open(); SqliteJumpType.JumpTypeInsert ("slCMJ:1:0:Single-leg CMJ jump", true); SqlitePreferences.Update ("databaseVersion", "0.85", true); LogB.SQL("Converted DB to 0.85 (added slCMJ jump)"); Sqlite.Close(); currentVersion = "0.85"; } if(currentVersion == "0.85") { Sqlite.Open(); LogB.SQL("Converted DB to 0.86 videoOn: TRUE"); SqlitePreferences.Update("videoOn", "True", true); SqlitePreferences.Update ("databaseVersion", "0.86", true); Sqlite.Close(); currentVersion = "0.86"; } if(currentVersion == "0.86") { Sqlite.Open(); LogB.SQL("Added run speed start preferences on sqlite"); SqlitePreferences.Insert ("runSpeedStartArrival", "True"); SqlitePreferences.Insert ("runISpeedStartArrival", "True"); SqlitePreferences.Update ("databaseVersion", "0.87", true); Sqlite.Close(); currentVersion = "0.87"; } if(currentVersion == "0.87") { //delete runInterval type SqliteRunIntervalType.Delete("RSA 8-4-R3-5"); //delete all it's runs Sqlite.Open(); dbcmd.CommandText = "DELETE FROM " + Constants.RunIntervalTable + " WHERE type == \"RSA 8-4-R3-5\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); //add know RSAs SqliteRunIntervalType.addRSA(); addedRSA = true; LogB.SQL("Deleted fake RSA test and added known RSA tests."); SqlitePreferences.Update ("databaseVersion", "0.88", true); Sqlite.Close(); currentVersion = "0.88"; } if(currentVersion == "0.88") { Sqlite.Open(); SqliteEncoder.addEncoderFreeExercise(); LogB.SQL("Added encoder exercise: Free"); SqlitePreferences.Update ("databaseVersion", "0.89", true); Sqlite.Close(); currentVersion = "0.89"; } if(currentVersion == "0.89") { Sqlite.Open(); SqlitePreferences.Insert("encoderPropulsive", "True"); SqlitePreferences.Insert("encoderSmoothEccCon", "0.6"); SqlitePreferences.Insert("encoderSmoothCon", "0.7"); LogB.SQL("Preferences added propulsive and encoder smooth"); SqlitePreferences.Update ("databaseVersion", "0.90", true); Sqlite.Close(); currentVersion = "0.90"; } if(currentVersion == "0.90") { Sqlite.Open(); SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", "", ""); LogB.SQL("Encoder Squat 75% -> 100%"); SqlitePreferences.Update ("databaseVersion", "0.91", true); Sqlite.Close(); currentVersion = "0.91"; } if(currentVersion == "0.91") { Sqlite.Open(); SqlitePreferences.Insert("videoDevice", "0"); LogB.SQL("Added videoDevice to preferences"); SqlitePreferences.Update ("databaseVersion", "0.92", true); Sqlite.Close(); currentVersion = "0.92"; } if(currentVersion == "0.92") { Sqlite.Open(); SqliteEncoder.UpdateExercise(true, "Bench press", "Bench press", 0, "weight bar", "","0.185"); SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", "","0.31"); LogB.SQL("Added speed1RM on encoder exercise"); SqlitePreferences.Update ("databaseVersion", "0.93", true); Sqlite.Close(); currentVersion = "0.93"; } if(currentVersion == "0.93") { Sqlite.Open(); SqliteEncoder.createTable1RM(); LogB.SQL("Added encoder1RM table"); SqlitePreferences.Update ("databaseVersion", "0.94", true); Sqlite.Close(); currentVersion = "0.94"; } if(currentVersion == "0.94") { Sqlite.Open(); SqlitePreferences.Insert ("encoder1RMMethod", Constants.Encoder1RMMethod.WEIGHTED2.ToString()); LogB.SQL("Added encoder1RMMethod"); SqlitePreferences.Update ("databaseVersion", "0.95", true); Sqlite.Close(); currentVersion = "0.95"; } if(currentVersion == "0.95") { Sqlite.Open(); Update(true, Constants.EncoderTable, "future3", "", Constants.EncoderConfigurationNames.LINEAR.ToString(), "signalOrCurve", "signal"); Update(true, Constants.EncoderTable, "future3", "0", Constants.EncoderConfigurationNames.LINEAR.ToString(), "signalOrCurve", "signal"); Update(true, Constants.EncoderTable, "future3", "1", Constants.EncoderConfigurationNames.LINEARINVERTED.ToString(), "signalOrCurve", "signal"); LogB.SQL("Encoder signal future3 three modes"); SqlitePreferences.Update ("databaseVersion", "0.96", true); Sqlite.Close(); currentVersion = "0.96"; } if(currentVersion == "0.96") { Sqlite.Open(); SqlitePreferences.Insert ("inertialmomentum", "0.01"); LogB.SQL("Added inertialmomentum in preferences"); SqlitePreferences.Update ("databaseVersion", "0.97", true); Sqlite.Close(); currentVersion = "0.97"; } if(currentVersion == "0.97") { Sqlite.Open(); Update(true, Constants.EncoderTable, "laterality", "both", "RL", "", ""); Update(true, Constants.EncoderTable, "laterality", "Both", "RL", "", ""); Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("Both"), "RL", "", ""); Update(true, Constants.EncoderTable, "laterality", "right", "R", "", ""); Update(true, Constants.EncoderTable, "laterality", "Right", "R", "", ""); Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("Right"), "R", "", ""); Update(true, Constants.EncoderTable, "laterality", "left", "L", "", ""); Update(true, Constants.EncoderTable, "laterality", "Left", "L", "", ""); Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("Left"), "L", "", ""); LogB.SQL("Fixed encoder laterality"); SqlitePreferences.Update ("databaseVersion", "0.98", true); Sqlite.Close(); currentVersion = "0.98"; } if(currentVersion == "0.98") { Sqlite.Open(); ArrayList array = SqliteOldConvert.EncoderSelect098(true,-1,-1,-1,"all",false); conversionRateTotal = array.Count; dropTable(Constants.EncoderTable); //CAUTION: do like this and never do createTableEncoder, //because method will change in the future and will break updates SqliteOldConvert.createTableEncoder99(); int count = 1; foreach( EncoderSQL098 es in array) { conversionRate = count; //do not use SqliteEncoder.Insert because that method maybe changes in the future, //and here we need to do a conversion that works from 0.98 to 0.99 dbcmd.CommandText = "INSERT INTO " + Constants.EncoderTable + " (uniqueID, personID, sessionID, exerciseID, eccon, laterality, extraWeight, " + "signalOrCurve, filename, url, time, minHeight, smooth, description, status, " + "videoURL, mode, inertiaMomentum, diameter, future1, future2, future3)" + " VALUES (" + es.uniqueID + ", " + es.personID + ", " + es.sessionID + ", " + es.exerciseID + ", \"" + es.eccon + "\", \"" + es.laterality + "\", \"" + es.extraWeight + "\", \"" + es.signalOrCurve + "\", \"" + es.filename + "\", \"" + es.url + "\", " + es.time + ", " + es.minHeight + ", " + Util.ConvertToPoint(es.smooth) + ", \"" + es.description + "\", \"" + es.future1 + "\", \"" + es.future2 + "\", \"LINEAR\", " + //status, videoURL, mode "0, 0, \"\", \"\", \"\")"; //inertiaMomentum, diameter, future1, 2, 3 LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); count ++; } conversionRate = count; LogB.SQL("Encoder table improved"); SqlitePreferences.Update ("databaseVersion", "0.99", true); Sqlite.Close(); currentVersion = "0.99"; } if(currentVersion == "0.99") { Sqlite.Open(); SqliteEncoder.putEncoderExerciseAnglesAt90(); SqliteEncoder.addEncoderJumpExercise(); SqliteEncoder.addEncoderInclinedExercises(); LogB.SQL("Added Free and inclinedExercises"); SqlitePreferences.Update ("databaseVersion", "1.00", true); Sqlite.Close(); currentVersion = "1.00"; } if(currentVersion == "1.00") { Sqlite.Open(); SqlitePreferences.Insert ("CSVExportDecimalSeparator", Util.GetDecimalSeparatorFromLocale()); LogB.SQL("Added export to CSV configuration on preferences"); SqlitePreferences.Update ("databaseVersion", "1.01", true); Sqlite.Close(); currentVersion = "1.01"; } if(currentVersion == "1.01") { Sqlite.Open(); RunType type = new RunType("Agility-T-Test"); SqliteRunType.Insert(type, Constants.RunTypeTable, true); type = new RunType("Agility-3L3R"); SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true); LogB.SQL("Added Agility Tests: Agility-T-Test, Agility-3l3R"); SqlitePreferences.Update ("databaseVersion", "1.02", true); Sqlite.Close(); currentVersion = "1.02"; } if(currentVersion == "1.02") { Sqlite.Open(); DeleteFromName(true, Constants.EncoderExerciseTable, "Inclinated plane Custom"); SqliteEncoder.removeEncoderExerciseAngles(); LogB.SQL("Updated encoder exercise, angle is now on encoder configuration"); SqlitePreferences.Update ("databaseVersion", "1.03", true); Sqlite.Close(); currentVersion = "1.03"; } if(currentVersion == "1.03") { Sqlite.Open(); ArrayList array = SqliteOldConvert.EncoderSelect103(true,-1,-1,-1,"all",false); conversionRateTotal = array.Count; dropTable(Constants.EncoderTable); //CAUTION: do like this and never do createTableEncoder, //because method will change in the future and will break updates SqliteOldConvert.createTableEncoder104(); //in this conversion put this as default for all SQL rows EncoderConfiguration econf = new EncoderConfiguration(); int count = 1; foreach(EncoderSQL103 es in array) { conversionRate = count; //do not use SqliteEncoder.Insert because that method maybe changes in the future, //and here we need to do a conversion that works from 1.03 to 1.04 dbcmd.CommandText = "INSERT INTO " + Constants.EncoderTable + " (uniqueID, personID, sessionID, exerciseID, eccon, laterality, extraWeight, " + "signalOrCurve, filename, url, time, minHeight, description, status, " + "videoURL, encoderConfiguration, future1, future2, future3)" + " VALUES (" + es.uniqueID + ", " + es.personID + ", " + es.sessionID + ", " + es.exerciseID + ", \"" + es.eccon + "\", \"" + es.laterality + "\", \"" + es.extraWeight + "\", \"" + es.signalOrCurve + "\", \"" + es.filename + "\", \"" + es.url + "\", " + es.time + ", " + es.minHeight + ", \"" + es.description + "\", \"" + es.status + "\", \"" + es.videoURL + "\", \"" + econf.ToStringOutput(EncoderConfiguration.Outputs.SQL) + "\", \"" + //in this conversion put this as default for all SQL rows. es.future1 + "\", \"" + es.future2 + "\", \"" + es.future3 + "\")"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); count ++; } conversionRate = count; LogB.SQL("Encoder table improved"); SqlitePreferences.Update ("databaseVersion", "1.04", true); Sqlite.Close(); currentVersion = "1.04"; } if(currentVersion == "1.04") { Sqlite.Open(); dbcmd.CommandText = "DELETE FROM " + Constants.EncoderTable + " WHERE encoderConfiguration LIKE \"%INERTIAL%\" AND " + " signalOrCurve == \"curve\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); LogB.SQL("Removed inertial curves, because sign was not checked on 1.04 when saving curves"); SqlitePreferences.Update ("databaseVersion", "1.05", true); Sqlite.Close(); currentVersion = "1.05"; } if(currentVersion == "1.05") { Sqlite.Open(); SqliteEncoder.createTableEncoderSignalCurve(); ArrayList signals = SqliteEncoder.Select(true, -1, -1, -1, Constants.EncoderGI.ALL, -1, "signal", EncoderSQL.Eccons.ALL, false, false); ArrayList curves = SqliteEncoder.Select(true, -1, -1, -1, Constants.EncoderGI.ALL, -1, "curve", EncoderSQL.Eccons.ALL, false, false); int signalID; conversionRateTotal = signals.Count; conversionRate = 1; //in 1.05 curves can be related to signals only by date foreach(EncoderSQL s in signals) { conversionRate ++; conversionSubRateTotal = curves.Count; conversionSubRate = 1; //needed to know if there are duplicates ArrayList curvesStored = new ArrayList(); foreach(EncoderSQL c in curves) { conversionSubRate ++; if(s.GetDate(false) == c.GetDate(false) && s.eccon == c.eccon) { int msCentral = SqliteEncoder.FindCurveInSignal( s.GetFullURL(false), c.GetFullURL(false)); signalID = Convert.ToInt32(s.uniqueID); if(msCentral == -1) signalID = -1; //mark as an orphaned curve (without signal) /* * about duplicated curves from 1.05 and before: * There are two kind of duplicates, in both, eccon is the same, and they overlap. * * Overlapings situations: * - they are saved two times (same msCentral), or * - they are saved two times with different smoothing (different msCentral) * * from now on (1.06) there will be no more duplicates * about the old duplicated curves, is the user problem, * except the curves of the first kind, that we know exactly that they are duplicated */ //curves come sorted by UniqueID DESC (selected with orderIDascendent = false) //if does not exist: insert in encoderSignalCurve bool exists = false; foreach(int ms in curvesStored) if(ms == msCentral) exists = true; if(exists) { //delete this (newer will not be deleted) Sqlite.Delete(true, Constants.EncoderTable, Convert.ToInt32(c.uniqueID)); } else { curvesStored.Add(msCentral); SqliteEncoder.SignalCurveInsert(true, signalID, Convert.ToInt32(c.uniqueID), msCentral); } } } } conversionSubRate ++; conversionRate ++; LogB.SQL("Curves are now linked to signals"); SqlitePreferences.Update ("databaseVersion", "1.06", true); Sqlite.Close(); currentVersion = "1.06"; } if(currentVersion == "1.06") { Sqlite.Open(); Update(true, Constants.GraphLinkTable, "graphFileName", "jump_dj.png", "jump_dj_a.png", "eventName", "DJa"); LogB.SQL("Added jump_dj_a.png"); SqlitePreferences.Update ("databaseVersion", "1.07", true); Sqlite.Close(); currentVersion = "1.07"; } if(currentVersion == "1.07") { Sqlite.Open(); LogB.SQL("Added translate statistics graph option to preferences"); SqlitePreferences.Insert ("RGraphsTranslate", "True"); SqlitePreferences.Update ("databaseVersion", "1.08", true); Sqlite.Close(); currentVersion = "1.08"; } if(currentVersion == "1.08") { Sqlite.Open(); LogB.SQL("Added option on preferences to useHeightsOnJumpIndexes (default) or not"); SqlitePreferences.Insert ("useHeightsOnJumpIndexes", "True"); SqlitePreferences.Update ("databaseVersion", "1.09", true); Sqlite.Close(); currentVersion = "1.09"; } if(currentVersion == "1.09") { Sqlite.Open(); LogB.SQL("Added RSA RAST on runType"); /* * addRSA() contains RAST since 1.10 * database started at 1.10 or more contains RAST * database started before 0.87 adds RAST on the addRSA() method * satabase started after 0.87 adds RAST now */ if(! addedRSA) { RunType type = new RunType(); type.Name = "RSA RAST 35, R10 x 6"; type.Distance = -1; type.TracksLimited = true; type.FixedValue = 12; type.Unlimited = false; type.Description = "RSA RAST Test"; type.DistancesString = "35-R10"; SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, true); addedRSA = true; } SqlitePreferences.Update ("databaseVersion", "1.10", true); Sqlite.Close(); currentVersion = "1.10"; } if(currentVersion == "1.10") { Sqlite.Open(); LogB.SQL("Added option on autosave curves on capture (all/bestmeanpower/none)"); SqlitePreferences.Insert ("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.BEST.ToString()); SqlitePreferences.Update ("databaseVersion", "1.11", true); Sqlite.Close(); currentVersion = "1.11"; } if(currentVersion == "1.11") { Sqlite.Open(); LogB.SQL("URLs from absolute to relative)"); SqliteOldConvert.ConvertAbsolutePathsToRelative(); SqlitePreferences.Update ("databaseVersion", "1.12", true); Sqlite.Close(); currentVersion = "1.12"; } if(currentVersion == "1.12") { Sqlite.Open(); LogB.SQL("Added ExecuteAuto table"); SqliteExecuteAuto.createTableExecuteAuto(); SqlitePreferences.Update ("databaseVersion", "1.13", true); Sqlite.Close(); currentVersion = "1.13"; } if(currentVersion == "1.13") { Sqlite.Open(); LogB.SQL("slCMJ -> slCMJleft, slCMJright"); SqliteOldConvert.slCMJDivide(); SqlitePreferences.Update ("databaseVersion", "1.14", true); Sqlite.Close(); currentVersion = "1.14"; } if(currentVersion == "1.14") { Sqlite.Open(); LogB.SQL("added Chronojump profile and bilateral profile"); SqliteExecuteAuto.addChronojumpProfileAndBilateral(); SqlitePreferences.Update ("databaseVersion", "1.15", true); Sqlite.Close(); currentVersion = "1.15"; } if(currentVersion == "1.15") { Sqlite.Open(); LogB.SQL("Cyprus moved to Europe"); Update(true, Constants.CountryTable, "continent", "Asia", "Europe", "code", "CYP"); SqlitePreferences.Update ("databaseVersion", "1.16", true); Sqlite.Close(); currentVersion = "1.16"; } if(currentVersion == "1.16") { Sqlite.Open(); LogB.SQL("Deleting Max jump"); Update(true, Constants.JumpTable, "type", "Max", "Free", "", ""); DeleteFromName(true, Constants.JumpTypeTable, "Max"); SqlitePreferences.Update ("databaseVersion", "1.17", true); Sqlite.Close(); currentVersion = "1.17"; } if(currentVersion == "1.17") { Sqlite.Open(); LogB.SQL("Deleted Negative runInterval runs (bug from last version)"); SqliteOldConvert.deleteNegativeRuns(); SqlitePreferences.Update ("databaseVersion", "1.18", true); Sqlite.Close(); currentVersion = "1.18"; } if(currentVersion == "1.18") { LogB.SQL("Preferences deleted showHeight, added showStiffness"); Sqlite.Open(); DeleteFromName(true, Constants.PreferencesTable, "showHeight"); SqlitePreferences.Insert ("showStiffness", "True"); SqlitePreferences.Update ("databaseVersion", "1.19", true); Sqlite.Close(); currentVersion = "1.19"; } if(currentVersion == "1.19") { LogB.SQL("Preferences: added user email"); Sqlite.Open(); SqlitePreferences.Insert ("email", ""); SqlitePreferences.Update ("databaseVersion", "1.20", true); Sqlite.Close(); currentVersion = "1.20"; } if(currentVersion == "1.20") { LogB.SQL("Fixing loosing of encoder videoURL after recalculate"); Sqlite.Open(); SqliteOldConvert.ConvertAbsolutePathsToRelative(); //videoURLs got absolute again SqliteOldConvert.FixLostVideoURLAfterEncoderRecalculate(); SqlitePreferences.Update ("databaseVersion", "1.21", true); Sqlite.Close(); currentVersion = "1.21"; } if(currentVersion == "1.21") { LogB.SQL("Encoder laterality in english again"); Sqlite.Open(); if(Catalog.GetString("RL") != "RL") Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("RL"), "RL", "", ""); if(Catalog.GetString("R") != "R") Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("R"), "R", "", ""); if(Catalog.GetString("L") != "L") Update(true, Constants.EncoderTable, "laterality", Catalog.GetString("L"), "L", "", ""); SqlitePreferences.Update ("databaseVersion", "1.22", true); Sqlite.Close(); currentVersion = "1.22"; } if(currentVersion == "1.22") { LogB.SQL("Added encoder configuration"); Sqlite.Open(); SqlitePreferences.Insert ("encoderConfiguration", new EncoderConfiguration().ToStringOutput(EncoderConfiguration.Outputs.SQL)); SqlitePreferences.Update ("databaseVersion", "1.23", true); Sqlite.Close(); currentVersion = "1.23"; } // ---------------------------------------------- // IMPORTANT HERE IS DEFINED sqliteOpened == true // this is useful to not do more than 50 SQL open close // that crashes mac (Linux 100) // ---------------------------------------------- LogB.SQL("Leaving Sqlite opened before DB updates"); Sqlite.Open(); //------------------------------------------------ if(currentVersion == "1.23") { LogB.SQL("Delete runISpeedStartArrival and add 4 double contacts configs"); DeleteFromName(true, Constants.PreferencesTable, "runISpeedStartArrival"); SqlitePreferences.Insert ("runDoubleContactsMode", Constants.DoubleContact.LAST.ToString()); SqlitePreferences.Insert ("runDoubleContactsMS", "1000"); SqlitePreferences.Insert ("runIDoubleContactsMode", Constants.DoubleContact.AVERAGE.ToString()); SqlitePreferences.Insert ("runIDoubleContactsMS", "1000"); currentVersion = updateVersion("1.24"); } if(currentVersion == "1.24") { LogB.SQL("Language defaults to (empty string), means detected"); SqlitePreferences.Update("language", "", true); currentVersion = updateVersion("1.25"); } if(currentVersion == "1.25") { LogB.SQL("Changed Inclinated to Inclined"); Update(true, Constants.EncoderExerciseTable, "name", "Inclinated plane", "Inclined plane", "", ""); Update(true, Constants.EncoderExerciseTable, "name", "Inclinated plane BW", "Inclined plane BW", "", ""); currentVersion = updateVersion("1.26"); } if(currentVersion == "1.26") { LogB.SQL("Changing runDoubleContactsMS and runIDoubleContactsMS from 1000ms to 300ms"); SqlitePreferences.Update("runDoubleContactsMS", "300", true); SqlitePreferences.Update("runIDoubleContactsMS", "300", true); currentVersion = updateVersion("1.27"); } if(currentVersion == "1.27") { LogB.SQL("Changed encoderAutoSaveCurve BESTMEANPOWER to BEST"); Update(true, Constants.PreferencesTable, "value", "BESTMEANPOWER", "BEST", "name", "encoderAutoSaveCurve"); currentVersion = updateVersion("1.28"); } if(currentVersion == "1.28") { LogB.SQL("Changed reaction time rows have reactionTime as default value"); Update(true, Constants.ReactionTimeTable, "type", "", "reactionTime", "", ""); currentVersion = updateVersion("1.29"); } if(currentVersion == "1.29") { LogB.SQL("Added SIMULATED session"); //add SIMULATED session if doesn't exists. Unique session where tests can be simulated. SqliteSession.insertSimulatedSession(); currentVersion = updateVersion("1.30"); } if(currentVersion == "1.30") { LogB.SQL("Insert encoderCaptureCheckFullyExtended and ...Value at preferences"); SqlitePreferences.Insert ("encoderCaptureCheckFullyExtended", "True"); SqlitePreferences.Insert ("encoderCaptureCheckFullyExtendedValue", "4"); currentVersion = updateVersion("1.31"); } if(currentVersion == "1.31") { LogB.SQL("encoderCaptureOptionsWin -> preferences"); SqlitePreferences.Insert ("encoderCaptureTime", "60"); SqlitePreferences.Insert ("encoderCaptureInactivityEndTime", "3"); SqlitePreferences.Insert ("encoderCaptureMainVariable", Constants.EncoderVariablesCapture.MeanPower.ToString()); SqlitePreferences.Insert ("encoderCaptureMinHeightGravitatory", "20"); SqlitePreferences.Insert ("encoderCaptureMinHeightInertial", "5"); SqlitePreferences.Insert ("encoderShowStartAndDuration", "False"); currentVersion = updateVersion("1.32"); } if(currentVersion == "1.32") { LogB.SQL("Added chronopicRegister table"); SqliteChronopicRegister.createTableChronopicRegister(); currentVersion = updateVersion("1.33"); } if(currentVersion == "1.33") { LogB.SQL("Added thresholdJumps, thresholdRuns, thresholdOther to preferences"); SqlitePreferences.Insert ("thresholdJumps", "50"); SqlitePreferences.Insert ("thresholdRuns", "10"); SqlitePreferences.Insert ("thresholdOther", "50"); currentVersion = updateVersion("1.34"); } // --- add more updates here // --- end of update, close DB LogB.SQL("Closing Sqlite after DB updates"); Sqlite.Close(); //------------------------------------------------ } //if changes are made here, remember to change also in CreateTables() //remember to change also the databaseVersion below return returnSoftwareIsNew; }
private void select_menuitem_mode_toggled(Constants.Menuitem_modes m) { menuitem_mode_selected_jumps_simple.Visible = false; menuitem_mode_selected_jumps_reactive.Visible = false; menuitem_mode_selected_runs_simple.Visible = false; menuitem_mode_selected_runs_intervallic.Visible = false; menuitem_mode_selected_power_gravitatory.Visible = false; menuitem_mode_selected_power_inertial.Visible = false; menuitem_mode_selected_other.Visible = false; LogB.Information("MODE", m.ToString()); //default for everythong except encoder menuitem_encoder_session_overview.Visible = false; menuitem_export_encoder_signal.Visible = false; menuitem_export_csv.Visible = true; hbox_other.Visible = false; vbox_last_test_buttons.Sensitive = false; if(m == Constants.Menuitem_modes.JUMPSSIMPLE || m == Constants.Menuitem_modes.JUMPSREACTIVE) { notebook_sup.CurrentPage = 0; notebook_capture_analyze.ShowTabs = true; if(m == Constants.Menuitem_modes.JUMPSSIMPLE) { menuitem_mode_selected_jumps_simple.Visible = true; notebooks_change(0); on_extra_window_jumps_test_changed(new object(), new EventArgs()); hbox_results_legend.Visible = true; notebook_capture_analyze.GetNthPage(2).Show(); //show jumpsProfile on jumps simple } else { menuitem_mode_selected_jumps_reactive.Visible = true; notebooks_change(1); on_extra_window_jumps_rj_test_changed(new object(), new EventArgs()); hbox_results_legend.Visible = false; notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on jumps reactive } } else if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == Constants.Menuitem_modes.RUNSINTERVALLIC) { notebook_sup.CurrentPage = 0; notebook_capture_analyze.ShowTabs = true; if(m == Constants.Menuitem_modes.RUNSSIMPLE) { menuitem_mode_selected_runs_simple.Visible = true; notebooks_change(2); on_extra_window_runs_test_changed(new object(), new EventArgs()); hbox_results_legend.Visible = true; } else { menuitem_mode_selected_runs_intervallic.Visible = true; notebooks_change(3); on_extra_window_runs_interval_test_changed(new object(), new EventArgs()); hbox_results_legend.Visible = false; } notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on runs } else if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m == Constants.Menuitem_modes.POWERINERTIAL) { menuitem_encoder_session_overview.Visible = true; menuitem_export_encoder_signal.Visible = true; menuitem_export_csv.Visible = false; //on OSX R is not installed by default. Check if it's installed. Needed for encoder if( UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX && ! Util.FileExists(Constants.ROSX) ) { new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, R software is not installed.") + "\n" + Catalog.GetString("Please, install it from here:") + "\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg"); return; } notebook_sup.CurrentPage = 1; /* * If there's a signal on gravitatory and we move to inertial, * interface has to change to YESPERSON (meaning no_signal). * But, if there's no person shoud continue on NOPERSON */ if(selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0)) encoderButtonsSensitive(encoderSensEnum.YESPERSON); blankEncoderInterface(); bool changed = false; if(m == Constants.Menuitem_modes.POWERGRAVITATORY) { menuitem_mode_selected_power_gravitatory.Visible = true; //change encoderConfigurationCurrent if needed if(encoderConfigurationCurrent.has_inertia) { encoderConfigurationCurrent = new EncoderConfiguration(); //LINEAR, not INERTIAL changed = true; } currentEncoderGI = Constants.EncoderGI.GRAVITATORY; hbox_capture_1RM.Visible = true; notebook_encoder_capture_extra_mass.CurrentPage = 0; if(radio_encoder_analyze_individual_current_set.Active || radio_encoder_analyze_individual_current_session.Active) { radiobutton_encoder_analyze_1RM.Visible = true; if(radiobutton_encoder_analyze_1RM.Active) hbox_combo_encoder_analyze_1RM.Visible=true; radiobutton_encoder_analyze_neuromuscular_profile.Visible = true; } hbox_encoder_capture_1_or_cont.Visible = true; } else { menuitem_mode_selected_power_inertial.Visible = true; //change encoderConfigurationCurrent if needed if(! encoderConfigurationCurrent.has_inertia) { encoderConfigurationCurrent = new EncoderConfiguration( Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL); encoderConfigurationCurrent.SetInertialDefaultOptions(); changed = true; } currentEncoderGI = Constants.EncoderGI.INERTIAL; hbox_capture_1RM.Visible = false; notebook_encoder_capture_extra_mass.CurrentPage = 1; radiobutton_encoder_analyze_1RM.Visible = false; hbox_combo_encoder_analyze_1RM.Visible=false; radiobutton_encoder_analyze_neuromuscular_profile.Visible = false; radio_encoder_capture_1set.Active = true; hbox_encoder_capture_1_or_cont.Visible = false; } encoderGuiChangesAfterEncoderConfigurationWin(true); if(changed) { prepareAnalyzeRepetitions (); } } else { //m == Constants.Menuitem_modes.OTHER (contacts / other) notebook_sup.CurrentPage = 0; hbox_other.Visible = true; menuitem_mode_selected_other.Visible = true; notebooks_change(4); on_extra_window_reaction_times_test_changed(new object(), new EventArgs()); radio_mode_reaction_times_small.Active = true; notebook_capture_analyze.CurrentPage = 0; notebook_capture_analyze.ShowTabs = false; //only capture tab is shown (only valid for "OTHER" tests) //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests } //show the program notebook_start.CurrentPage = 1; //it's not visible at startup main_menu.Visible = true; if(m != Constants.Menuitem_modes.POWERGRAVITATORY && m != Constants.Menuitem_modes.POWERINERTIAL) { //don't change threshold if changing from jumpssimple to jumpsreactive ... if(last_menuitem_mode == null || ( m == Constants.Menuitem_modes.JUMPSSIMPLE && last_menuitem_mode != Constants.Menuitem_modes.JUMPSREACTIVE ) || ( m == Constants.Menuitem_modes.JUMPSREACTIVE && last_menuitem_mode != Constants.Menuitem_modes.JUMPSSIMPLE ) || ( m == Constants.Menuitem_modes.RUNSSIMPLE && last_menuitem_mode != Constants.Menuitem_modes.RUNSINTERVALLIC ) || ( m == Constants.Menuitem_modes.RUNSINTERVALLIC && last_menuitem_mode != Constants.Menuitem_modes.RUNSSIMPLE ) || m == Constants.Menuitem_modes.OTHER ) { if(threshold.SelectTresholdForThisMode(m)) { hscale_threshold.Value = threshold.SetHScaleValue(); last_menuitem_mode = m; } } } chronopicRegisterUpdate(false); chronojumpWindowTestsNext(); }
static async Task Main(string[] args) { if (args.Length == 0) { throw new Exception("No file to convert provided"); } Console.WriteLine("Encoding: " + args[0]); var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true) // TODO: Change the Production with Enviroment .AddEnvironmentVariables(); IConfigurationRoot configuration = builder.Build(); var encoderConfiguration = new EncoderConfiguration(); configuration.GetSection("Encoder").Bind(encoderConfiguration); var sofakingConfiguration = new SoFakingConfiguration(); configuration.GetSection("Sofaking").Bind(sofakingConfiguration); var dc = new DConf(); configuration.GetSection("DownloadFinishedWorker").Bind(dc); var builder1 = new HostBuilder() .ConfigureServices((hostContext, services) => { services .AddSingleton(sofakingConfiguration) .AddSingleton(encoderConfiguration) .AddSingleton(new SoFakingContextFactory()); }).UseConsoleLifetime(); var host = builder1.Build(); using (var serviceScope = host.Services.CreateScope()) { var done = false; var serviceProvider = serviceScope.ServiceProvider; var logger = new NullLogger <FFMPEGEncoderService>(); var flags = EncodingTargetFlags.None; var videoFile = args[0]; IMediaInfo mediaInfo = null; var useCuda = true; Console.Clear(); Console.WriteLine($"Is this a film (vs. cartoon)? [y/n]"); if (Console.ReadKey().KeyChar == 'n') { flags |= EncodingTargetFlags.VideoIsAnimation; } var encoderTranscodingInstance = new FFMPEGEncoderService(logger, encoderConfiguration, sofakingConfiguration); try { mediaInfo = await encoderTranscodingInstance.GetMediaInfo(videoFile); } catch (Exception ex) { Console.Clear(); Console.WriteLine("Can not read media info: " + ex.Message); Console.ReadKey(); return; } // Find subtitles var filenameBase = Path.GetFileNameWithoutExtension(videoFile); var path = Path.GetDirectoryName(videoFile); var subtitles = new Dictionary <string, string>(); foreach (var sl in sofakingConfiguration.SubtitleLanguages) { var subPath = Path.Combine(path, filenameBase + $".{sl}.srt"); if (File.Exists(subPath)) { subtitles.Add(sl, subPath); } } if (subtitles.Count > 0) { Console.Clear(); Console.WriteLine($"Found {subtitles.Count} subtitles to embed."); Thread.Sleep(3 * 1000); flags |= EncodingTargetFlags.ExternalSubtitles; } try { var videoAudit = HasAcceptableVideo(dc, sofakingConfiguration, mediaInfo); if (videoAudit != VideoCompatibilityFlags.Compatible) { Console.Clear(); Console.WriteLine("Video details:"); if (videoAudit.HasFlag(VideoCompatibilityFlags.IncompatibleCodec)) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine($" Codec: {mediaInfo.VideoCodec}, (Accepted: {string.Join(", ", dc.AcceptedVideoCodecs)})"); Console.ResetColor(); if (videoAudit.HasFlag(VideoCompatibilityFlags.IncompatibleResolution)) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine($" H. Resolution: {mediaInfo.HorizontalVideoResolution}px, (Max: {sofakingConfiguration.MaxHorizontalVideoResolution}px)"); Console.ResetColor(); if (videoAudit.HasFlag(VideoCompatibilityFlags.IncompatibleBitrate)) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine($" Avg bitrate: {(mediaInfo.AVBitrateKbs.HasValue ? ByteSize.FromKiloBytes(mediaInfo.AVBitrateKbs.Value).ToString() : "?")}/s, (Max: {ByteSize.FromKiloBytes(TargetVideoBitrateKbs)}/s"); Console.ResetColor(); if (videoAudit.HasFlag(VideoCompatibilityFlags.IncompatibleSize)) { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine($" Size: {ByteSize.FromBytes(mediaInfo.FileInfo.Length)} (Max: {ByteSize.FromGigaBytes(sofakingConfiguration.MaxSizeGb)})"); Console.ResetColor(); Console.WriteLine(); Console.WriteLine($"Video needs converting. Continue? [y/n]"); if (Console.ReadKey().KeyChar == 'n') { return; } if (encoderConfiguration.CanUseCuda) { Console.Clear(); Console.WriteLine($"Use CUDA? [y/n]"); if (Console.ReadKey().KeyChar == 'n') { useCuda = false;; } } flags |= EncodingTargetFlags.NeedsNewVideo; } } catch (ArgumentException ex) { Console.Clear(); Console.WriteLine("Incompatible video: " + ex.Message); Console.ReadKey(); return; } try { if (!HasAcceptableAudio(dc, mediaInfo)) { Console.Clear(); Console.WriteLine($"Audio ({mediaInfo.AudioCodec}, (Accepted: {string.Join(", ", dc.AcceptedAudioCodecs)})) needs converting. Continue? [y/n]"); if (Console.ReadKey().KeyChar == 'n') { return; } flags |= EncodingTargetFlags.NeedsNewAudio; } } catch (ArgumentException ex) { Console.Clear(); Console.WriteLine("Incompatible audio: " + ex.Message); Console.ReadKey(); return; } if (flags == EncodingTargetFlags.None) { Console.Clear(); Console.WriteLine($"Video file {videoFile} doesn't need transcoding, adding to files to move."); Console.ReadKey(); return; } Console.Clear(); Console.WriteLine("Converting..."); encoderTranscodingInstance.OnSuccess += (object sender, EncodingSuccessEventArgs e) => { done = true; }; encoderTranscodingInstance.OnProgress += (object sender, EncodingProgressEventArgs e) => { Console.Clear(); Console.WriteLine($"Transcoding progress: {e.ProgressPercent:0.##}%"); }; // non-blocking, only starts the external engine await encoderTranscodingInstance.StartTranscodingAsync(new TranscodingJob { SourceFile = videoFile, Action = flags, Duration = mediaInfo.Duration, Subtitles = subtitles, UseCuda = useCuda }); while (!done) { // wait until encoding finished } Console.Clear(); Console.WriteLine("Done!"); Thread.Sleep(3 * 1000); } }
void on_encoder_configuration_win_accepted(object o, EventArgs args) { encoder_configuration_win.Button_accept.Clicked -= new EventHandler(on_encoder_configuration_win_accepted); EncoderConfiguration eConfNew = encoder_configuration_win.GetAcceptedValues(); if(encoderConfigurationCurrent == eConfNew) return; bool combo_encoder_anchorage_should_update = (encoderConfigurationCurrent.list_d != eConfNew.list_d); encoderConfigurationCurrent = eConfNew; LogB.Information("EncoderConfigurationCurrent = " + encoderConfigurationCurrent.ToStringOutput(EncoderConfiguration.Outputs.SQL)); encoderGuiChangesAfterEncoderConfigurationWin(combo_encoder_anchorage_should_update); }
//TODO:put zoom,unzoom (at side of delete curve) in capture curves (for every curve) // //TODO: capture also with webcam an attach it to signal or curve // //TODO: peak power in eccentric in absolute values // //TODO: on cross, spline and force speed and power speed should have a spar value higher, like 0.7. On the other hand, the other cross graphs, haveload(mass) in the X lot more discrete, there is good to put 0.5 private void encoderInitializeStuff() { encoder_pulsebar_capture.Fraction = 1; encoder_pulsebar_capture.Text = ""; encoder_pulsebar_analyze.Fraction = 1; encoder_pulsebar_analyze.Text = ""; //read from SQL encoderConfigurationCurrent = SqliteEncoder.LoadEncoderConfiguration(); encoderCaptureListStore = new Gtk.ListStore (typeof (EncoderCurve)); encSelReps = new EncoderSelectRepetitions(); //the glade cursor_changed does not work on mono 1.2.5 windows //treeview_encoder_capture_curves.CursorChanged += on_treeview_encoder_capture_curves_cursor_changed; //changed, now unselectable because there are the checkboxes createEncoderCombos(); encoderConfigurationGUIUpdate(); //on start it's concentric and powerbars. Eccon-together should be unsensitive check_encoder_analyze_eccon_together.Sensitive = false; //spin_encoder_capture_inertial.Value = Convert.ToDouble(Util.ChangeDecimalSeparator( // SqlitePreferences.Select("inertialmomentum"))); //initialize capture and analyze classes encoderRProcCapture = new EncoderRProcCapture(); encoderRProcAnalyze = new EncoderRProcAnalyze(); captureCurvesBarsData = new ArrayList(0); try { playVideoEncoderInitialSetup(); } catch { //it crashes on Raspberry, Banana } capturingCsharp = encoderCaptureProcess.STOPPED; //done here because in Glade we cannot use the TextBuffer.Changed textview_encoder_signal_comment.Buffer.Changed += new EventHandler(on_textview_encoder_signal_comment_key_press_event); configInit(); array1RM = new ArrayList(); }
public void Read() { string contents = Util.ReadFile(UtilAll.GetConfigFileName(), false); if (contents != null && contents != "") { string line; using (StringReader reader = new StringReader(contents)) { do { line = reader.ReadLine(); if (line == null) { break; } if (line == "" || line[0] == '#') { continue; } string [] parts = line.Split(new char[] { '=' }); if (parts.Length != 2) { continue; } if (parts[0] == "Maximized" && Util.StringToBool(parts[1])) { Maximized = true; } else if (parts[0] == "CustomButtons" && Util.StringToBool(parts[1])) { CustomButtons = true; } else if (parts[0] == "UseVideo" && !Util.StringToBool(parts[1])) { UseVideo = false; } else if (parts[0] == "AutodetectPort" && Enum.IsDefined(typeof(AutodetectPortEnum), parts[1])) { AutodetectPort = (AutodetectPortEnum) Enum.Parse(typeof(AutodetectPortEnum), parts[1]); } else if (parts[0] == "OnlyEncoderGravitatory" && Util.StringToBool(parts[1])) { OnlyEncoderGravitatory = true; } else if (parts[0] == "OnlyEncoderInertial" && Util.StringToBool(parts[1])) { OnlyEncoderInertial = true; } else if (parts[0] == "EncoderCaptureShowOnlyBars" && Util.StringToBool(parts[1])) { EncoderCaptureShowOnlyBars = true; } else if (parts[0] == "EncoderUpdateTreeViewWhileCapturing" && !Util.StringToBool(parts[1])) { EncoderUpdateTreeViewWhileCapturing = false; } else if (parts[0] == "PersonWinHide" && Util.StringToBool(parts[1])) { PersonWinHide = true; } else if (parts[0] == "EncoderAnalyzeHide" && Util.StringToBool(parts[1])) { EncoderAnalyzeHide = true; } else if (parts[0] == "EncoderConfiguration") { string [] ecFull = parts[1].Split(new char[] { ':' }); if (Enum.IsDefined(typeof(Constants.EncoderConfigurationNames), ecFull[0])) { //create object Econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), ecFull[0])); //assign the rest of params Econf.ReadParamsFromSQL(ecFull); } } else if (parts[0] == "SessionMode" && Enum.IsDefined(typeof(SessionModeEnum), parts[1])) { SessionMode = (SessionModeEnum) Enum.Parse(typeof(SessionModeEnum), parts[1]); } else if (parts[0] == "RunScriptOnExit" && parts[1] != "") { RunScriptOnExit = parts[1]; } } while(true); } } }
public static ArrayList SelectSessionOverviewReps(bool dbconOpened, Constants.EncoderGI encoderGI, int sessionID) { if(! dbconOpened) Sqlite.Open(); dbcmd.CommandText = "SELECT person77.name, person77.sex, encoder.encoderConfiguration, encoderExercise.name, encoder.extraWeight, encoder.future1 " + "FROM person77, encoderExercise, encoder " + "WHERE sessionID = " + sessionID.ToString() + " AND signalOrCurve = \"curve\" " + " AND person77.uniqueID = encoder.personID " + " AND encoderExercise.uniqueID = encoder.exerciseID " + " ORDER BY person77.name"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(); while(reader.Read()) { //discard if != encoderGI string [] strFull = reader[2].ToString().Split(new char[] {':'}); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) ); //if encoderGI != ALL discard non wanted repetitions if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) continue; else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia) continue; if(encoderGI == Constants.EncoderGI.GRAVITATORY) { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[4].ToString(), //extra mass reader[5].ToString() //power }; array.Add (s); } else { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[5].ToString() //power }; array.Add (s); } } reader.Close(); if(! dbconOpened) Sqlite.Close(); return array; }
public void Read() { string contents = Util.ReadFile(UtilAll.GetConfigFileName(), false); if (contents != null && contents != "") { string line; using (StringReader reader = new StringReader (contents)) { do { line = reader.ReadLine (); if (line == null) break; if (line == "" || line[0] == '#') continue; string [] parts = line.Split(new char[] {'='}); if(parts.Length != 2) continue; if(parts[0] == "Maximized" && Util.StringToBool(parts[1])) Maximized = true; else if(parts[0] == "CustomButtons" && Util.StringToBool(parts[1])) CustomButtons = true; else if(parts[0] == "UseVideo" && ! Util.StringToBool(parts[1])) UseVideo = false; else if(parts[0] == "AutodetectPort" && Enum.IsDefined(typeof(AutodetectPortEnum), parts[1])) AutodetectPort = (AutodetectPortEnum) Enum.Parse(typeof(AutodetectPortEnum), parts[1]); else if(parts[0] == "OnlyEncoderGravitatory" && Util.StringToBool(parts[1])) OnlyEncoderGravitatory = true; else if(parts[0] == "OnlyEncoderInertial" && Util.StringToBool(parts[1])) OnlyEncoderInertial = true; else if(parts[0] == "EncoderCaptureShowOnlyBars" && Util.StringToBool(parts[1])) EncoderCaptureShowOnlyBars = true; else if(parts[0] == "EncoderUpdateTreeViewWhileCapturing" && ! Util.StringToBool(parts[1])) EncoderUpdateTreeViewWhileCapturing = false; else if(parts[0] == "PersonWinHide" && Util.StringToBool(parts[1])) PersonWinHide = true; else if(parts[0] == "EncoderAnalyzeHide" && Util.StringToBool(parts[1])) EncoderAnalyzeHide = true; else if(parts[0] == "EncoderConfiguration") { string [] ecFull = parts[1].Split(new char[] {':'}); if(Enum.IsDefined(typeof(Constants.EncoderConfigurationNames), ecFull[0])) { //create object Econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), ecFull[0]) ); //assign the rest of params Econf.ReadParamsFromSQL(ecFull); } } else if(parts[0] == "SessionMode" && Enum.IsDefined(typeof(SessionModeEnum), parts[1])) SessionMode = (SessionModeEnum) Enum.Parse(typeof(SessionModeEnum), parts[1]); else if(parts[0] == "RunScriptOnExit" && parts[1] != "") RunScriptOnExit = parts[1]; } while(true); } } }
//exerciseID can be -1 to get all exercises public static ArrayList SelectCompareIntersession(bool dbconOpened, Constants.EncoderGI encoderGI, int exerciseID, int personID) { if (!dbconOpened) { Sqlite.Open(); } string exerciseIDStr = ""; if (exerciseID != -1) { exerciseIDStr = "encoder.exerciseID = " + exerciseID + " AND "; } //returns a row for each session where there are active or inactive dbcmd.CommandText = "SELECT encoder.sessionID, session.name, session.date, encoder.extraWeight, " + " SUM(CASE WHEN encoder.status = \"active\" THEN 1 END) as active, " + " SUM(CASE WHEN encoder.status = \"inactive\" THEN 1 END) as inactive," + " encoder.encoderConfiguration " + " FROM encoder, session, person77 " + " WHERE " + exerciseIDStr + " encoder.personID = " + personID + " AND signalOrCurve = \"curve\" AND " + " encoder.personID = person77.uniqueID AND encoder.sessionID = session.uniqueID " + " GROUP BY encoder.sessionID, encoder.extraWeight ORDER BY encoder.sessionID, encoder.extraWeight, encoder.status"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(); EncoderPersonCurvesInDB encPS = new EncoderPersonCurvesInDB(); /* * eg. * sessID|sess name|date|extraWe|a|i (a: active, i: inactive) * 20|Encoder tests|2012-12-10|7|3| * 20|Encoder tests|2012-12-10|0||9 * 20|Encoder tests|2012-12-10|10||34 * 20|Encoder tests|2012-12-10|58||1 * 20|Encoder tests|2012-12-10|61||1 * 26|sessio-proves|2013-07-08|10|5|36 * 30|proves encoder|2013-11-08|0|2| * 30|proves encoder|2013-11-08|100|5| * * convert to: * * sessID|sess name|date|a|i|reps*weights (a: active, i: inactive) * 20|Encoder tests|2012-12-10|3|45|3*7 9*0 34*10 1*58 1*61 (but sorted) * */ int sessIDDoing = -1; //of this sessionID int sessIDThisRow = -1; //of this SQL row List <EncoderPersonCurvesInDBDeep> lDeep = new List <EncoderPersonCurvesInDBDeep>(); bool firstSession = true; int activeThisRow; int inactiveThisRow; int activeThisSession = 0; int inactiveThisSession = 0; while (reader.Read()) { //discard if != encoderGI string [] strFull = reader[6].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); //if encoderGI != ALL discard non wanted repetitions if (encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) { continue; } else if (encoderGI == Constants.EncoderGI.INERTIAL && !econf.has_inertia) { continue; } //1 get sessionID of this row sessIDThisRow = Convert.ToInt32(reader[0].ToString()); //2 get active an inactive curves of this row activeThisRow = 0; string activeStr = reader[4].ToString(); if (Util.IsNumber(activeStr, false)) { activeThisRow = Convert.ToInt32(activeStr); } inactiveThisRow = 0; string inactiveStr = reader[5].ToString(); if (Util.IsNumber(inactiveStr, false)) { inactiveThisRow = Convert.ToInt32(inactiveStr); } //3 if session of this row is different than previous row if (sessIDThisRow != sessIDDoing) { sessIDDoing = sessIDThisRow; if (!firstSession) { //if is not first session (means we have processed a session before) //update encPS with the lDeep and then add to array encPS.lDeep = lDeep; encPS.countActive = activeThisSession; encPS.countAll = activeThisSession + inactiveThisSession; array.Add(encPS); } firstSession = false; //create new EncoderPersonCurvesInDB encPS = new EncoderPersonCurvesInDB( personID, Convert.ToInt32(reader[0].ToString()), //sessionID reader[1].ToString(), //sessionName reader[2].ToString()); //sessionDate activeThisSession = 0; inactiveThisSession = 0; //empty lDeep lDeep = new List <EncoderPersonCurvesInDBDeep>(); } //4 add deep info: (weight, all reps) EncoderPersonCurvesInDBDeep deep = new EncoderPersonCurvesInDBDeep( Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), activeThisRow + inactiveThisRow); //add to lDeep lDeep.Add(deep); activeThisSession += activeThisRow; inactiveThisSession += inactiveThisRow; } //store last row in array (once we are out the while) if (!firstSession) { //if is not first session (means we have processed a session before) //update encPS with the lDeep and then add to array encPS.lDeep = lDeep; encPS.countActive = activeThisSession; encPS.countAll = activeThisSession + inactiveThisSession; array.Add(encPS); } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(array); }
//exerciseID can be -1 to get all exercises public static ArrayList SelectCompareIntersession(bool dbconOpened, Constants.EncoderGI encoderGI, int exerciseID, int personID) { if(! dbconOpened) Sqlite.Open(); string exerciseIDStr = ""; if(exerciseID != -1) exerciseIDStr = "encoder.exerciseID = " + exerciseID + " AND "; //returns a row for each session where there are active or inactive dbcmd.CommandText = "SELECT encoder.sessionID, session.name, session.date, encoder.extraWeight, " + " SUM(CASE WHEN encoder.status = \"active\" THEN 1 END) as active, " + " SUM(CASE WHEN encoder.status = \"inactive\" THEN 1 END) as inactive," + " encoder.encoderConfiguration " + " FROM encoder, session, person77 " + " WHERE " + exerciseIDStr + " encoder.personID = " + personID + " AND signalOrCurve = \"curve\" AND " + " encoder.personID = person77.uniqueID AND encoder.sessionID = session.uniqueID " + " GROUP BY encoder.sessionID, encoder.extraWeight ORDER BY encoder.sessionID, encoder.extraWeight, encoder.status"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(); EncoderPersonCurvesInDB encPS = new EncoderPersonCurvesInDB(); /* * eg. * sessID|sess name|date|extraWe|a|i (a: active, i: inactive) * 20|Encoder tests|2012-12-10|7|3| * 20|Encoder tests|2012-12-10|0||9 * 20|Encoder tests|2012-12-10|10||34 * 20|Encoder tests|2012-12-10|58||1 * 20|Encoder tests|2012-12-10|61||1 * 26|sessio-proves|2013-07-08|10|5|36 * 30|proves encoder|2013-11-08|0|2| * 30|proves encoder|2013-11-08|100|5| * * convert to: * * sessID|sess name|date|a|i|reps*weights (a: active, i: inactive) * 20|Encoder tests|2012-12-10|3|45|3*7 9*0 34*10 1*58 1*61 (but sorted) * */ int sessIDDoing = -1; //of this sessionID int sessIDThisRow = -1; //of this SQL row List<EncoderPersonCurvesInDBDeep> lDeep = new List<EncoderPersonCurvesInDBDeep>(); bool firstSession = true; int activeThisRow; int inactiveThisRow; int activeThisSession = 0; int inactiveThisSession = 0; while(reader.Read()) { //discard if != encoderGI string [] strFull = reader[6].ToString().Split(new char[] {':'}); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) ); //if encoderGI != ALL discard non wanted repetitions if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) continue; else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia) continue; //1 get sessionID of this row sessIDThisRow = Convert.ToInt32(reader[0].ToString()); //2 get active an inactive curves of this row activeThisRow = 0; string activeStr = reader[4].ToString(); if(Util.IsNumber(activeStr, false)) activeThisRow = Convert.ToInt32(activeStr); inactiveThisRow = 0; string inactiveStr = reader[5].ToString(); if(Util.IsNumber(inactiveStr, false)) inactiveThisRow = Convert.ToInt32(inactiveStr); //3 if session of this row is different than previous row if(sessIDThisRow != sessIDDoing) { sessIDDoing = sessIDThisRow; if(! firstSession) { //if is not first session (means we have processed a session before) //update encPS with the lDeep and then add to array encPS.lDeep = lDeep; encPS.countActive = activeThisSession; encPS.countAll = activeThisSession + inactiveThisSession; array.Add(encPS); } firstSession = false; //create new EncoderPersonCurvesInDB encPS = new EncoderPersonCurvesInDB ( personID, Convert.ToInt32(reader[0].ToString()), //sessionID reader[1].ToString(), //sessionName reader[2].ToString()); //sessionDate activeThisSession = 0; inactiveThisSession = 0; //empty lDeep lDeep = new List<EncoderPersonCurvesInDBDeep>(); } //4 add deep info: (weight, all reps) EncoderPersonCurvesInDBDeep deep = new EncoderPersonCurvesInDBDeep( Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), activeThisRow + inactiveThisRow); //add to lDeep lDeep.Add(deep); activeThisSession += activeThisRow; inactiveThisSession += inactiveThisRow; } //store last row in array (once we are out the while) if(! firstSession) { //if is not first session (means we have processed a session before) //update encPS with the lDeep and then add to array encPS.lDeep = lDeep; encPS.countActive = activeThisSession; encPS.countAll = activeThisSession + inactiveThisSession; array.Add(encPS); } reader.Close(); if(! dbconOpened) Sqlite.Close(); return array; }
private static void PreparePublishingPoint(EncoderConfiguration.Configuration Configuration) { string dest_root = null; IisPointCreator pc; try { dest_root = Configuration.Upload.IndexFtpRoot; if (!String.IsNullOrEmpty(dest_root)) { pc = PreparePointCreator(dest_root); pc.CreatePoint(); } else { dest_root = Configuration.Upload.VideoDestinationRoot; pc = PreparePointCreator(dest_root); pc.CreatePoint(); } } catch (Exception ex) { throw new Exception("Could not establish a publishing point at " + dest_root, ex); } }
/* * EncoderConfiguration */ //called on startup to load last encoderConfiguration public static EncoderConfiguration LoadEncoderConfiguration() { string ecStr = SqlitePreferences.Select("encoderConfiguration", false); //1.5.1 and previous don't store encoderConfiguration on SqlitePreferences if(ecStr == null || ecStr.Length == 0 || ecStr == "0" || ecStr == "") return new EncoderConfiguration(); string [] ecStrFull = ecStr.Split(new char[] {':'}); //create object EncoderConfiguration ec = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), ecStrFull[0]) ); //assign the rest of params ec.ReadParamsFromSQL(ecStrFull); return ec; }
/* * Use this to retrieve values after accept * do not use to know current encoder configuration * because that is stored in gui/encoder as * encoderConfigurationCurrent */ public EncoderConfiguration GetAcceptedValues() { EncoderConfiguration ec = (EncoderConfiguration)list[listCurrent]; ec.d = -1; ec.list_d = new List <double>(); ec.D = -1; ec.anglePush = -1; ec.angleWeight = -1; ec.inertiaMachine = -1; if (ec.has_d) { if (ec.has_inertia) { ec.list_d = get_list_d(); bool found = false; if (Util.IsNumber(main_gui_anchorage_str, true)) { LogB.Information("main_gui_anchorage = " + main_gui_anchorage_str); double guiAnchorage = Convert.ToDouble(main_gui_anchorage_str); foreach (double d in ec.list_d) { LogB.Information("d = " + d.ToString()); if (d == guiAnchorage) { ec.d = guiAnchorage; found = true; break; } } } if (!found) { ec.d = ec.list_d[0]; } } else { ec.d = (double)spin_d.Value; } } if (ec.has_D) { ec.D = (double)spin_D.Value; } if (ec.has_angle_push) { ec.anglePush = (int)spin_angle_push.Value; } if (ec.has_angle_weight) { ec.angleWeight = (int)spin_angle_weight.Value; } if (ec.has_inertia) { ec.inertiaMachine = (int)spin_inertia_machine.Value; ec.inertiaTotal = (int)spin_inertia_machine.Value; ec.extraWeightN = main_gui_extraWeightN; ec.extraWeightGrams = (int)spin_inertia_mass.Value; ec.extraWeightLength = (double)spin_inertia_length.Value; } if (ec.has_gearedDown) { ec.SetGearedDownFromDisplay(UtilGtk.ComboGetActive(combo_gearedUp)); } return(ec); }
/// <summary> /// Read the supplied configuration and prepare the transformer for work. /// </summary> private void PrepareTransformer(EncoderConfiguration.Configuration Configuration, List<EncoderPackage> Packages) { Config = Configuration; TimeSpan TargetDuration = TimeSpan.FromSeconds(Config.EncoderSettings.FragmentSeconds); PublishPoint = Config.Upload.VideoDestinationRoot; if (String.IsNullOrEmpty(PublishPoint)) throw new ArgumentException("Publishing point must not be empty", "PublishUrl"); PushServer = new IisSmoothPush(new Uri(PublishPoint)); TrackDurations = new Dictionary<int, long>(); TrackOffsets = new Dictionary<int, long>(); targetDuration = (ulong)TargetDuration.Ticks; Streams = new MediaStream[Packages.Count]; foreach (var pkg in Packages) { if (pkg.Specification.HasVideo && pkg.Specification.HasAudio) { throw new NotSupportedException("IIS Smooth output doesn't support pre-muxed streams"); } if (pkg.Specification.HasAudio) { Streams[pkg.JobIndex] = new MediaStream(); // for now, stream 0 is audio, and all others are video. Streams[pkg.JobIndex].TrackId = pkg.JobIndex + 1; Streams[pkg.JobIndex].FourCC = "mp3a"; // MP3 //Streams[pkg.JobIndex].FourCC = "mp4a"; // AAC Streams[pkg.JobIndex].Height = 0; Streams[pkg.JobIndex].Width = 0; Streams[pkg.JobIndex].Bitrate = 96000; //pkg.Job.Bitrate; // later! } else if (pkg.Specification.HasVideo) { Streams[pkg.JobIndex] = new MediaStream(); // for now, stream 0 is audio, and all others are video. Streams[pkg.JobIndex].TrackId = pkg.JobIndex + 1; Streams[pkg.JobIndex].FourCC = "H264"; // this is the M$ format, not iso (which is 'avc1') Streams[pkg.JobIndex].Height = Config.EncoderSettings.OutputHeight; // the actual size may be different due to scaling factor. Streams[pkg.JobIndex].Width = Config.EncoderSettings.OutputWidth; Streams[pkg.JobIndex].Bitrate = pkg.Job.Bitrate; } } Mp4fFile = new FileRoot(Streams); Demuxer = new MpegTS_Demux[Packages.Count]; for (int di = 0; di < Demuxer.Length; di++) { Demuxer[di] = new MpegTS_Demux(); } }
public static ArrayList SelectSessionOverviewReps(bool dbconOpened, Constants.EncoderGI encoderGI, int sessionID) { if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT person77.name, person77.sex, encoder.encoderConfiguration, encoderExercise.name, encoder.extraWeight, encoder.future1 " + "FROM person77, encoderExercise, encoder " + "WHERE sessionID = " + sessionID.ToString() + " AND signalOrCurve = \"curve\" " + " AND person77.uniqueID = encoder.personID " + " AND encoderExercise.uniqueID = encoder.exerciseID " + " ORDER BY person77.name"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(); while (reader.Read()) { //discard if != encoderGI string [] strFull = reader[2].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); //if encoderGI != ALL discard non wanted repetitions if (encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) { continue; } else if (encoderGI == Constants.EncoderGI.INERTIAL && !econf.has_inertia) { continue; } if (encoderGI == Constants.EncoderGI.GRAVITATORY) { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[4].ToString(), //extra mass reader[5].ToString() //power }; array.Add(s); } else { string [] s = { reader[0].ToString(), //person name reader[1].ToString(), //person sex reader[3].ToString(), //encoder exercise name reader[5].ToString() //power }; array.Add(s); } } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(array); }
//pass uniqueID value and then will return one record. do like this: //EncoderSQL eSQL = (EncoderSQL) SqliteEncoder.Select(false, myUniqueID, 0, 0, 0, "", EncoderSQL.Eccons.ALL, false, true)[0]; //WARNING because SqliteEncoder.Select may not return nothing, and then cannot be assigned to eSQL //see: delete_encoder_curve(bool dbconOpened, int uniqueID) //don't care for the 0, 0, 0 because selection will be based on the myUniqueID and only one row will be returned //or //pass uniqueID==-1 and personID, sessionID, signalOrCurve values, and will return some records //personID can be -1 to get all on that session //sessionID can be -1 to get all sessions //exerciseID can be -1 to get all exercises //signalOrCurve can be "all" //orderIDascendent is good for all the situations except when we want to convert from 1.05 to 1.06 //in that conversion, we want first the last ones, and later the previous // (to delete them if they are old copies) public static ArrayList Select( bool dbconOpened, int uniqueID, int personID, int sessionID, Constants.EncoderGI encoderGI, int exerciseID, string signalOrCurve, EncoderSQL.Eccons ecconSelect, bool onlyActive, bool orderIDascendent) { if(! dbconOpened) Sqlite.Open(); string personIDStr = ""; if(personID != -1) personIDStr = " personID = " + personID + " AND "; string sessionIDStr = ""; if(sessionID != -1) sessionIDStr = " sessionID = " + sessionID + " AND "; string exerciseIDStr = ""; if(exerciseID != -1) exerciseIDStr = " exerciseID = " + exerciseID + " AND "; string selectStr = ""; if(uniqueID != -1) selectStr = Constants.EncoderTable + ".uniqueID = " + uniqueID; else { if(signalOrCurve == "all") selectStr = personIDStr + sessionIDStr + exerciseIDStr; else selectStr = personIDStr + sessionIDStr + exerciseIDStr + " signalOrCurve = \"" + signalOrCurve + "\""; if(ecconSelect != EncoderSQL.Eccons.ALL) selectStr += " AND " + Constants.EncoderTable + ".eccon = \"" + EncoderSQL.Eccons.ecS.ToString() + "\""; } string andString = ""; if(selectStr != "") andString = " AND "; string onlyActiveString = ""; if(onlyActive) onlyActiveString = " AND " + Constants.EncoderTable + ".status = \"active\" "; string orderIDstr = ""; if(! orderIDascendent) orderIDstr = " DESC"; dbcmd.CommandText = "SELECT " + Constants.EncoderTable + ".*, " + Constants.EncoderExerciseTable + ".name FROM " + Constants.EncoderTable + ", " + Constants.EncoderExerciseTable + " WHERE " + selectStr + andString + Constants.EncoderTable + ".exerciseID = " + Constants.EncoderExerciseTable + ".uniqueID " + onlyActiveString + " ORDER BY substr(filename,-23,19), " + //'filename,-23,19' has the date of capture signal "uniqueID " + orderIDstr; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); ArrayList array = new ArrayList(1); EncoderSQL es = new EncoderSQL(); while(reader.Read()) { string [] strFull = reader[15].ToString().Split(new char[] {':'}); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) ); econf.ReadParamsFromSQL(strFull); //if encoderGI != ALL discard non wanted repetitions if(encoderGI == Constants.EncoderGI.GRAVITATORY && econf.has_inertia) continue; else if(encoderGI == Constants.EncoderGI.INERTIAL && ! econf.has_inertia) continue; LogB.Debug("EncoderConfiguration = " + econf.ToStringOutput(EncoderConfiguration.Outputs.SQL)); //if there's no video, will be "". //if there's video, will be with full path string videoURL = ""; if(reader[14].ToString() != "") videoURL = addURLpath(fixOSpath(reader[14].ToString())); //LogB.SQL(econf.ToString(":", true)); es = new EncoderSQL ( reader[0].ToString(), //uniqueID Convert.ToInt32(reader[1].ToString()), //personID Convert.ToInt32(reader[2].ToString()), //sessionID Convert.ToInt32(reader[3].ToString()), //exerciseID reader[4].ToString(), //eccon Catalog.GetString(reader[5].ToString()),//laterality reader[6].ToString(), //extraWeight reader[7].ToString(), //signalOrCurve reader[8].ToString(), //filename addURLpath(fixOSpath(reader[9].ToString())), //url Convert.ToInt32(reader[10].ToString()), //time Convert.ToInt32(reader[11].ToString()), //minHeight reader[12].ToString(), //description reader[13].ToString(), //status videoURL, //videoURL econf, //encoderConfiguration Util.ChangeDecimalSeparator(reader[16].ToString()), //future1 (meanPower on curves) reader[17].ToString(), //future2 reader[18].ToString(), //future3 reader[19].ToString() //EncoderExercise.name ); array.Add (es); } reader.Close(); if(! dbconOpened) Sqlite.Close(); return array; }