Пример #1
0
 // Start is called before the first frame update
 void Awake()
 {
     m_Animator  = GetComponent <Animator>();
     m_Transform = GetComponent <Transform>();
     interaction = GetComponent <MyGame.Interaction>();
     cooldownBar = GameObject.FindWithTag("Cooldown").GetComponent <UpdateProgressBar>();
 }
        private void startBackWork(bool toAuthor)
        {
            System.Windows.Threading.Dispatcher dispatcher = this.upload.Dispatcher;
            BackgroundWorker worker = new BackgroundWorker();

            worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs ex)
            {
                this.upload.Visibility = System.Windows.Visibility.Hidden;
            };
            // 在单独的线程中上传数据
            worker.DoWork += delegate(object s, DoWorkEventArgs ex)
            {
                try
                {
                    UpdateProgressBar up = new UpdateProgressBar(update);
                    dispatcher.BeginInvoke(up);
                    initService();
                    if (toAuthor)
                    {
                        feedbackToAuthor();
                    }
                    else
                    {
                        feedbackToAdmin();
                    }
                }
                catch (Exception up)
                {
                    MessageBox.Show(up.ToString(), "上传错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            };
            worker.RunWorkerAsync();
        }
Пример #3
0
        // 同步数据到服务器
        private void btnSync_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Threading.Dispatcher dispatcher = this.upload.Dispatcher;
            BackgroundWorker worker = new BackgroundWorker();

            worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs ex)
            {
                this.upload.Visibility = System.Windows.Visibility.Hidden;
            };
            // 在单独的线程中上传数据
            worker.DoWork += delegate(object s, DoWorkEventArgs ex)
            {
                try
                {
                    UpdateProgressBar up = new UpdateProgressBar(update);
                    dispatcher.BeginInvoke(up);
                    initService();
                    uploadData();
                    // 更新本地数据库更改到服务器
                    submitChanges();
                    MessageBox.Show("已将所有数据上传到服务器!", "操作提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception up)
                {
                    MessageBox.Show(up.Message, "上传错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            };
            worker.RunWorkerAsync();
        }
Пример #4
0
        public override void Run(string name, UpdateProgressBar updateProgressBar)
        {
            bool isOrfFile = false;

            if (name != "Wholegenome")
            {
                isOrfFile = true;
            }
            if (File.Exists(_dataManager.DataFolder + name + ".fasta"))
            {
                return;
            }
            _dataManager.CreateOneSequenceFile(name, isOrfFile);

            string outfile = _dataManager.AnalysisFiles[name] + "_aligned.fasta";

            _commandlineRun.ProgramName = "mafft-win\\mafft";
            _commandlineRun.Arguments   = getArgs() + " --out " + outfile + " " + _dataManager.AnalysisFiles[name] + ".fasta";
            _commandlineRun.Run();

            if (!File.Exists(outfile))
            {
                StreamWriter writer = new StreamWriter(outfile);
                writer.Close();
            }

            _dataManager.Alignments.Add(name, new AlignmentData());
            _dataManager.Alignments[name].Contents     = _dataManager.FileToSequences(outfile);
            _dataManager.Alignments[name].FileLocation = outfile;

            if (_dataManager.AnalysisCount != 0)
            {
                updateProgressBar((int)(400 / (float)_dataManager.AnalysisCount));
            }
        }
Пример #5
0
        private void UpdateStatic(int Count, string Msg)
        {
            this.Statistic += Count;
            this.Message    = Msg;

            if (StopLoading)
            {
                this.Dispose();
            }
            else
            {
                Console.WriteLine(this.Statistic);
                this.Statistic = Convert.ToInt32((this.Statistic / (float)TotalData) * 100);

                if (this.Statistic > 100)
                {
                    this.Statistic = 100;
                }

                if (this.InvokeRequired)
                {
                    UpdateProgressBar UpdateBar = new UpdateProgressBar(UpdateStatic);

                    this.Invoke(UpdateBar, this.Statistic, Msg);
                }
                else
                {
                    this.FileProgress.Value = this.Statistic;
                    this.textBox_ShowDetails.AppendText(Msg + "\n");
                }

                this.label_ShowProgressState.Text = "Loading...";
                Application.DoEvents();
            }
        }
        public bool DetermineDocumentType(ValidDocumentType validDocumentType, UpdateProgressBar updateProgressBar)
        {
            DocumentTypeEnum currentDocumentType;

            try
            {
                currentDocumentType = thisApplication.ActiveDocument.DocumentType;

                if (DocumentInfo.IsAssemblyDocument(currentDocumentType))
                {
                    topLevel.TraverseAssembly((AssemblyDocument)thisApplication.ActiveDocument, 0);
                    validDocumentType(true);
                    return(true);
                }

                else if ((DocumentInfo.IsPartDocument(currentDocumentType)))
                {
                    validDocumentType(false);
                    return(false);
                }

                else
                {
                    validDocumentType(false);
                    return(false);
                }
            }
            catch (Exception e)
            {
                validDocumentType(false);
                updateProgressBar(true);
                EventLogger.CreateLogEntry(e.Message + " " + e.StackTrace);
                return(false);
            }
        }
 public ProgressBarDialog()
 {
     InitializeComponent();
     this.FormBorderStyle = FormBorderStyle.None;
     this.StartPosition   = FormStartPosition.CenterScreen;
     updateProgressBar   += InitProgressBar;
     this.Show();
     status.Show();
 }
Пример #8
0
        public void Run(UpdateProgressBar updateProgressBar)
        {
            _updateProgressBar = updateProgressBar;
            _dataManager.RemoveAllFiles(_dataManager.DataFolder);

            Thread thread = new Thread(new ThreadStart(ThreadProc));

            thread.Start();
        }
Пример #9
0
        void Awake()
        {
            _updateProgressBar  = UIComponent.FindObjectComponent <UpdateProgressBar>("UpdateProgressBar");
            _updateNoticeDialog = UIComponent.FindObjectComponent <UpdateNoticeDialog>("UpdateNoticeDialog");
            _updateNoticeDialog.Close();
            _logoDialog = UIComponent.FindObjectComponent <LogoDialog>("LogoDialog");

            GameConfig.VFS = true;
            GameConfig.Init();
            GameConfig.InitLogFile();

            ExtSDK.Init();
        }
Пример #10
0
        public override void Run(UpdateProgressBar updateProgressBar)
        {
            _commandlineRun.AplicationPath = _dataManager.RDPLocation + "\\";
            _commandlineRun.ProgramName    = "rdp4.exe";
            _commandlineRun.Arguments      = "-f" + new FileInfo(_dataManager.Alignments["Wholegenome"].FileLocation).FullName;
            _commandlineRun.Run();
            AddData();
            sortData();
            string fileDir = _dataManager.CreateOutputDirectory("Recombination");

            _dataManager.MoveFile(_dataManager.DataFolder + "Wholegenome_aligned.fasta.csv", fileDir);

            updateProgressBar(30);
        }
Пример #11
0
 private void SetProgressBar(int minValue, int maxValue, int currentValue)
 {
     if (this.progressBar.InvokeRequired)
     {
         UpdateProgressBar d = new UpdateProgressBar(SetProgressBar);
         this.Invoke(d, minValue, maxValue, currentValue);
     }
     else
     {
         this.progressBar.Minimum = (int)minValue;
         this.progressBar.Maximum = (int)maxValue;
         this.progressBar.Value   = (int)currentValue;
     }
 }
Пример #12
0
        public UserInterface(DataManager dataManager, RunDelegate run)
        {
            InitializeComponent();

            _dataManager       = dataManager;
            _runAnalysis       = run;
            _updateProgressBar = new UpdateProgressBar(updateProgressBar);

            uxRunToolbar.Enabled          = false;
            uxSequenceList.ItemCheck     += uxSequenceListItem_Click;
            uxOutputLocationTextBox.Text  = _dataManager.MainOutputFolder;
            uxVaccineLocationTextBox.Text = _dataManager.VaccineLocation;
            uxMinOrfLengthTextbox.Text    = _dataManager.MinimumOrfLength.ToString();
            uxAlignmentType.SelectedItem  = _dataManager.MafftSettings;
        }
Пример #13
0
        private async void UpdateFiles()
        {
            if (IsUpdating)
            {
                return;
            }
            arguments.TryGetValue("branch", out string branch);
            AsyncUpdate updater = new AsyncUpdate(branch);

            IsUpdating = true;
            updater.OnNewFileUpdate += (src, message) =>
            {
                FilesUpdated  = $"Files: {updater.FilesUpdatedCounter}/{updater.DifferentFilesCounter}";
                UpdateMessage = message;
            };
            updater.OnUpdateFail += (_, __) =>
            {
                UpdateMessage = "Failed to update HunterPie";
                LaunchHunterPie(__);
            };
            updater.OnUpdateSuccess += (_, __) =>
            {
                LaunchHunterPie(__);
            };
            updater.OnDownloadProgressChanged += (object _, DownloadProgressChangedEventArgs args) =>
            {
                long kBytesReceived  = args.BytesReceived / 1024;
                long kBytesToReceive = args.TotalBytesToReceive / 1024;

                UpdateProgressBar.Visibility = Visibility.Visible;
                ProgressBarText.Visibility   = Visibility.Visible;

                if (kBytesReceived > UpdateProgressBar.Value && kBytesToReceive == UpdateProgressBar.Maximum)
                {
                    DoubleAnimation anim = new DoubleAnimation(UpdateProgressBar.Value, kBytesReceived, new Duration(TimeSpan.FromMilliseconds(200)));
                    UpdateProgressBar.BeginAnimation(ProgressBar.ValueProperty, anim);
                }
                else if (kBytesToReceive != UpdateProgressBar.Maximum)
                {
                    UpdateProgressBar.Value   = 0;
                    UpdateProgressBar.Maximum = kBytesToReceive;
                    DoubleAnimation anim = new DoubleAnimation(0, kBytesReceived, new Duration(TimeSpan.FromMilliseconds(200)));
                    UpdateProgressBar.BeginAnimation(ProgressBar.ValueProperty, anim);
                }
            };

            await updater.Start();
        }
Пример #14
0
        internal void updateProgressBar(string msg)
        {
            ushort timeElapsedSeconds = (ushort)((Misc.getSystemMilliseconds() - startTime) / 1000);

            if (timeElapsedSeconds <= 20) //TODO:
            {
                if (progressBar1.InvokeRequired)
                {
                    UpdateProgressBar d = new UpdateProgressBar(updateProgressBar);
                    Invoke(d, new object[] { msg });
                }
                else
                {
                    progressBar1.Value = (int)timeElapsedSeconds % progressBar1.Maximum;
                }
            }
        }
        public override void Run(string analysisName, UpdateProgressBar updateProgressBar)
        {
            _dataManager.PercentIdentities[analysisName] = new PercentIdentityData();
            foreach (KeyValuePair <string, string> sequence1 in _dataManager.Alignments[analysisName].Contents)
            {
                _dataManager.PercentIdentities[analysisName].Dic[sequence1.Key]        = new Dictionary <string, float>();
                _dataManager.PercentIdentities[analysisName].DicInverse[sequence1.Key] = new Dictionary <string, float>();
                if (!_dataManager.SequencesUsed[sequence1.Key].Vaccine)
                {
                    _dataManager.PercentIdentities[analysisName].Sequences.Add(sequence1.Key);
                }
                List <float> dataList = new List <float>();
                List <float> vdata    = new List <float>();
                float        total    = 0;
                int          count    = 0;
                Dictionary <int, Dictionary <string, string> > siteChanges = new Dictionary <int, Dictionary <string, string> >();
                foreach (KeyValuePair <string, string> sequence2 in _dataManager.Alignments[analysisName].Contents)
                {
                    float percent = GlobalCalculations.CalculatePercentIdentity(sequence1.Value, sequence2.Value, sequence2.Key, siteChanges);
                    if (sequence1.Key != sequence2.Key)
                    {
                        total += percent;
                    }
                    count++;
                    if (!_dataManager.PercentIdentities[analysisName].Dic[sequence1.Key].ContainsKey(sequence2.Key))
                    {
                        _dataManager.PercentIdentities[analysisName].Dic[sequence1.Key][sequence2.Key]        = percent;
                        _dataManager.PercentIdentities[analysisName].DicInverse[sequence1.Key][sequence2.Key] = 100 - percent;
                    }
                    dataList.Add(percent);
                    if (!_dataManager.SequencesUsed[sequence2.Key].Vaccine)
                    {
                        vdata.Add(percent);
                    }
                }
                _dataManager.PercentIdentities[analysisName].SiteChanges[sequence1.Key] = siteChanges;
                if (!_dataManager.SequencesUsed[sequence1.Key].Vaccine)
                {
                    _dataManager.PercentIdentities[analysisName].Data.Add(vdata);
                }
            }

            updateProgressBar((int)(20 / (float)_dataManager.AnalysisCount));
        }
Пример #16
0
 public void SetProgressBar(int minValue, int maxValue, int currentValue, string text)
 {
     if (this.progressBar.InvokeRequired)
     {
         try
         {
             UpdateProgressBar d = new UpdateProgressBar(SetProgressBar);
             progressBar.Invoke(d, minValue, maxValue, currentValue, text);
         }
         catch (Exception) { }
     }
     else
     {
         this.progressBar.CustomText = text;
         this.progressBar.Minimum    = (int)minValue;
         this.progressBar.Maximum    = (int)maxValue;
         this.progressBar.Value      = (int)currentValue;
     }
 }
Пример #17
0
        public override void Run(string sequenceName, UpdateProgressBar updateProgressBar)
        {
            //if (sequenceName == "Wholegenome")
            // {
            Alignment alignment = new Alignment(_dataManager);

            alignment.Run("Wholegenome", updateProgressBar);
            //return;
            //}

            //_currentSeqs.Add(sequenceName);

            Dictionary <string, int[]> orfAlignedLocations = findOrfAlignmentLocations("P129_Partent_of_Fostera");

            foreach (string seqName in _dataManager.SequencesUsed.Keys)
            {
                string contents                    = _dataManager.SequencesUsed[seqName].Contents;
                string alignedContents             = _dataManager.Alignments["Wholegenome"].Contents[seqName];
                Dictionary <string, int[]> allOrfs = findAllOrfs(alignedContents, true);
                _dataManager.SequencesUsed[seqName].KnownOrfData = findKnownOrfs(seqName, orfAlignedLocations, alignedContents);
                _dataManager.SequencesUsed[seqName].OtherOrfData = findUnknownOrfs(allOrfs, contents);
                foreach (List <string> orfs in _dataManager.CombinedOrfs)
                {
                    try
                    {
                        createCombinedOrf(orfs, seqName);
                    }
                    catch { }
                }
            }

            //Dictionary<string, int[]> allOrfs = findAllOrfs(alignedContents);
            //addOrfToData(_dataManager.SequencesUsed[sequenceName].OtherOrfData, allOrfs, contents);
            //_dataManager.SequencesUsed[sequenceName].KnownOrfData = findKnownOrfs(_dataManager.SequencesUsed[sequenceName].OtherOrfData);
            //getRidOfRepeates(_dataManager.SequencesUsed[sequenceName].KnownOrfData);


            //matchOrfs(sequenceName);

            updateProgressBar((int)(70 / (float)_dataManager.SequenceCount));
        }
Пример #18
0
        public override void Run(string analysisItem, UpdateProgressBar updateProgressBar)
        {
            if (analysisItem.Split('_')[analysisItem.Split('_').Length - 1] != "aa")
            {
                _commandlineRun.ProgramName = "PhyML-3.1_win32.exe";
                string infile = _dataManager.FastaToPhyiFile(_dataManager.Alignments[analysisItem].FileLocation);
                if (new FileInfo(infile).Length != 0)
                {
                    _commandlineRun.Arguments = "-i " + infile;
                    _commandlineRun.Run();

                    if (!_dataManager.TreeData.ContainsKey(analysisItem))
                    {
                        _dataManager.TreeData.Add(analysisItem, new TreeData());
                    }
                    _dataManager.TreeData[analysisItem].NewickFile = Path.GetFullPath(infile + "_phyml_tree.txt");
                }
            }

            updateProgressBar((int)(350 / (float)_dataManager.AnalysisCount));
        }
Пример #19
0
        public DataChecksForm()
        {
            #region Init Deligate functions
            /**************************************************************************/

            _updateProgressBar = new UpdateProgressBar(updateProgressBarState);
            _updateResults     = new UpdateResults(updateResults);
            _updateLogBox      = new UpdateLogBox(writeLog);
            _clearBeforeRun    = new ClearBeforeRun(clearOnStart);
            _setButton         = new SetButtonVisibility(setButtonVisibility);
            _incCounter        = new IncCounter(IncreaseCounter);
            _setLabelText      = new SetLabelText(SetLabel);

            /**************************************************************************/
            #endregion



            DataChecksModelView = new DataChecksModelView();
            EventsHandlers      = new Dictionary <string, Object>();

            //Adding Service Events Handler functions
            #region Attaching Services Events
            EventsHandlers.Add(Const.EventsTypes.ParentOutcomeReportedEvent, new EventHandler(instance_OutcomeReported));
            //EventsHandlers.Add(Const.EventsTypes.ChildOutcomeReportedEvent, new EventHandler(instance_OutcomeReported));
            EventsHandlers.Add(Const.EventsTypes.ParentStateChangedEvent, new EventHandler <Edge.Core.Services.ServiceStateChangedEventArgs>(instance_StateChanged));
            EventsHandlers.Add(Const.EventsTypes.ChildStateChangedEvent, new EventHandler <ServiceStateChangedEventArgs>(child_instance_StateChanged));
            EventsHandlers.Add(Const.EventsTypes.ChildServiceRequested, new EventHandler <ServiceRequestedEventArgs>(instance_ChildServiceRequested));
            #endregion

            InitializeComponent();

            //Load Validation Types from configuration
            DataChecksModelView.LoadValidationTypesItems(this.ValidationTypes.Nodes);

            //Load Metrics Validations from configuration
            DataChecksModelView.LoadMetricsValidationsItems(this.MerticsValidations.Nodes);

            this.LogBox.Multiline = true;
        }
Пример #20
0
        public MainWindow()
        {
            InitializeComponent();
            GridPrincipal.Children.Clear();

            HideLeftPanel();
            LoadingControl loadingControl = new LoadingControl();

            GridPrincipal.Children.Add(loadingControl);
            updateProgressBar = loadingControl.UpdateProgress;

            new Thread(() =>
            {
                SaveCardsToTempDir();
                Dispatcher.Invoke(() =>
                {
                    GridPrincipal.Children.Clear();
                    StartControl startControl = new StartControl(ShowControl);
                    GridPrincipal.Children.Add(startControl);
                });
            }).Start();
        }
Пример #21
0
        public override void Run(UpdateProgressBar updateProgressBar)
        {
            // Remove Data
            _dataManager.RemoveAllFiles(_dataManager.OutputFolder);

            // Write Data
            moveAlignmentFiles();
            writeSiteChanges();
            string fileDir = _dataManager.CreateOutputDirectory("UnknownOrfs");

            foreach (KeyValuePair <string, SequenceData> sequenceOrfPair in _dataManager.SequencesUsed)
            {
                writeOrfsFound(fileDir + sequenceOrfPair.Key + ".csv", sequenceOrfPair.Value.OtherOrfData);
            }
            fileDir = _dataManager.CreateOutputDirectory("KnownOrfs");
            foreach (KeyValuePair <string, SequenceData> sequenceOrfPair in _dataManager.SequencesUsed)
            {
                writeOrfsFound(fileDir + sequenceOrfPair.Key + ".csv", sequenceOrfPair.Value.KnownOrfData);
            }
            fileDir = _dataManager.CreateOutputDirectory("NSPData");
            writeNSPS(fileDir + "nsplocations.csv");
            writeHeatMapCSV();


            // Graph Stuff
            _dataManager.WriteJsonFile(_dataManager.SequencesUsed, "Sequences");
            _dataManager.WriteJsonFile(_dataManager.PercentIdentities, "PercentIdentities");
            _dataManager.WriteJsonFile(_dataManager.RecombinationData, "Recombination");
            _dataManager.WriteJsonFile(_dataManager.AnalysisNames, "AnalysisNames");
            _dataManager.WriteJsonFile(_dataManager.TreeData, "Trees");
            _commandlineRun.ProgramName = "BuildGraphs.exe";
            _commandlineRun.Arguments   = ("--i \"" + Path.GetDirectoryName(_dataManager.DataFolder) + "\" --out \"" +
                                           Path.GetDirectoryName(_dataManager.OutputFolder) + "\"");
            Console.WriteLine(_commandlineRun.Arguments);
            _commandlineRun.Run();

            updateProgressBar(1000);
        }
Пример #22
0
 private void updateProgressBar(int val)
 {
     if (uxProgressBar.InvokeRequired)
     {
         UpdateProgressBar d = new UpdateProgressBar(updateProgressBar);
         Invoke(d, new object[] { val });
     }
     else
     {
         if (uxProgressBar.Value + val > uxProgressBar.Maximum)
         {
             uxProgressBar.Value = uxProgressBar.Maximum;
         }
         else
         {
             uxProgressBar.Value += val;
         }
     }
     if (uxProgressBar.Value >= uxProgressBar.Maximum)
     {
         uxFileToolbar.Enabled = true;
         uxRunToolbar.Enabled  = true;
     }
 }
Пример #23
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool   success   = false;

        bool ok;
        int  phase = 0;

        do
        {
            if (simulated)
            {
                ok = true;
            }
            else
            {
                ok = cp.Read_event(out timestamp, out platformState);
            }


            /*
             *           \()/            \()/
             *            \/              \/
             *   _()_     /\     _()_     /\     _()_
             *    \/              \/              \/
             * ___/\______________/\______________/\___
             *
             *  GraphA  graphB  graphC  graphD  graphE
             *  unused  jumps   lands   jumps   lands
             *
             *    ______start_______             end
             *
             *    DJ      DJ      SJ
             * hasFall  hasFall
             * fall -1
             *
             */

            //if (ok)
            if (ok && !cancel)
            {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //has landed
                    if (hasFall && tc == 0)
                    {
                        //**** graphC ****

                        if (fall == -1)
                        {
                            if (simulated)
                            {
                                timestamp = simulatedTimeLast * 1000;                                 //conversion to milliseconds
                            }
                            //calculate the fall height using flight time
                            double tvPreJump = timestamp / 1000.0;
                            fall = Convert.ToDouble(Util.GetHeightInCentimeters(tvPreJump.ToString()));
                        }

                        //jump with fall, landed first time
                        initializeTimer();

                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar(
                            true,                                     //isEvent
                            true,                                     //jumpsLimited: percentageMode
                            ++phase
                            );
                        needUpdateEventProgressBar = true;

                        feedbackMessage         = "";
                        needShowFeedbackMessage = true;
                    }
                    else
                    {
                        //**** graphE **** jump with fall: second landed; or without fall first landing

                        if (simulated)
                        {
                            timestamp = simulatedTimeLast * 1000;                             //conversion to milliseconds
                        }
                        LogB.Information(string.Format("t1:{0}", timestamp));

                        tv = timestamp / 1000.0;

                        jumpPhase = jumpPhases.PLATFORM_END;

                        write();

                        success = true;

                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar(
                            true,                                     //isEvent
                            true,                                     //percentageMode
                            ++phase
                            );
                        needUpdateEventProgressBar = true;
                    }
                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {
                    //it's out, was inside (= has jumped)

                    //fall != -1 because if it was == -1, it will change once touching floor for the first time
                    if (hasFall && fall != -1)
                    {
                        //**** graphD ****

                        if (simulated)
                        {
                            timestamp = simulatedTimeLast * 1000;                             //conversion to milliseconds
                        }
                        LogB.Information(string.Format("t2:{0}", timestamp));

                        //record the TC
                        tc = timestamp / 1000.0;

                        //takeOff jump (only one TC)
                        //if(fixedValue == 0.5)
                        if (type == Constants.TakeOffName || type == Constants.TakeOffWeightName)
                        {
                            tv = 0;

                            jumpPhase = jumpPhases.PLATFORM_END;

                            write();
                            success = true;
                        }

                        //update event progressbar
                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar(
                            true,                                     //isEvent
                            true,                                     //percentageMode
                            ++phase
                            );
                        needUpdateEventProgressBar = true;
                    }
                    else
                    {
                        //**** graphD (if normal jump) ****
                        //**** graphB (if hasFall and fall == -1) ****

                        initializeTimer();

                        //update event progressbar
                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar(
                            true,                                     //isEvent
                            true,                                     //percentageMode
                            ++phase
                            );
                        needUpdateEventProgressBar = true;

                        feedbackMessage         = "";
                        needShowFeedbackMessage = true;
                    }

                    //change the automata state
                    loggedState = States.OFF;
                }
            }
//Log.WriteLine("PREEXIT");
        } while (!success && !cancel);
//Log.WriteLine("EXIT");

        if (cancel)
        {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #24
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool success = false;
        string equal = "";

        //initialize variables
        intervalTimesString = "";
        tracks = 0;
        bool ok;
        timerCount = 0;
        //bool initialized = false;
        int countForSavingTempTable = 0;
        lastTc = 0;
        distanceIntervalFixed = distanceInterval;

        double timestampDCFlightTimes = -1; //sum of the flight times that happen in small time
        double timestampDCContactTimes = -1;//sum of the contact times that happen in small time
        double timestampDCn = 0; //number of flight times

        do {
            if(simulated)
                ok = true;
            else
                ok = cp.Read_event(out timestamp, out platformState);

            if (ok && !cancel && !finish) {
                if(distanceInterval == -1)
                    distanceIntervalFixed = Util.GetRunIVariableDistancesStringRow(distancesString, (int) tracks);

                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) {
                    //has arrived
                    loggedState = States.ON;

                    //show RSA count down only on air
                    needShowCountDown = false;

                    //if we start out, and we arrive to the platform for the first time,
                    //don't record nothing
                    if(runPhase == runPhases.PRE_RUNNING) {
                        if(speedStartArrival) {
                            runPhase = runPhases.PLATFORM_INI_YES_TIME;
                            //run starts
                            initializeTimer(); //timerCount = 0
                        } else
                            runPhase = runPhases.PLATFORM_INI_NO_TIME;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    }
                    else {
                        runPhase = runPhases.RUNNING;
                        //has arrived and not in the "running previous"

                        //if interval run is "unlimited" not limited by tracks, nor time,
                        //then play with the progress bar until finish button is pressed

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        if(checkDoubleContactMode != Constants.DoubleContact.NONE) {
                            if(timestamp <= checkDoubleContactTime) {
                                /*
                                   when checking double contact
                                   first time that timestamp < checkDoubleContactTime
                                   and we arrived (it's a flight time)
                                   record this time as timestampDCFlightTimes
                                 */
                                timestampDCn ++;
                                timestampDCFlightTimes += timestamp;
                                continue;
                            }
                            else {
                                if(timestampDCn > 0) {
                                    if(checkDoubleContactMode ==
                                            Constants.DoubleContact.FIRST) {
                                        /* user want first flight time,
                                           then add all DC times*/
                                        timestamp += timestampDCFlightTimes +
                                            timestampDCContactTimes;
                                    }
                                    else if(checkDoubleContactMode ==
                                            Constants.DoubleContact.LAST) {
                                        //user want last flight time, take that
                                        // so we don't need to change timestamp. Or we could do (it triggers a warning):
                                        // timestamp = timestamp;
                                    }
                                    else {	/* do the avg of all flights and contacts
                                           then add to last timestamp */
                                        timestamp +=
                                            (timestampDCFlightTimes +
                                             timestampDCContactTimes)
                                            / timestampDCn;
                                    }
                                }
                            }
                        }

                        double myRaceTime = lastTc + timestamp/1000.0;

                        if(intervalTimesString.Length > 0) { equal = "="; }
                        intervalTimesString = intervalTimesString + equal + myRaceTime.ToString();
                        updateTimerCountWithChronopicData(intervalTimesString);
                        tracks ++;

                        //save temp table if needed
                        countForSavingTempTable ++;
                        if(countForSavingTempTable == timesForSavingRepetitive) {
                                writeRunInterval(true); //tempTable
                                countForSavingTempTable = 0;
                        }

                        if(limitAsDouble == -1) {
                            //has arrived, unlimited
                            updateProgressBar= new UpdateProgressBar (
                                    true, //isEvent
                                    true, //unlimited: activity mode
                                    tracks
                                    );
                            needUpdateEventProgressBar = true;
                        }
                        else {
                            //has arrived, limited
                            if (tracksLimited) {
                                //has arrived, limited by tracks
                                if(tracks >= limitAsDouble)
                                {
                                    runPhase = runPhases.PLATFORM_END;

                                    //finished
                                    writeRunInterval(false); //tempTable = false
                                    success = true;
                                }
                                //progressBarEventOrTimePreExecution(
                                updateProgressBar= new UpdateProgressBar (
                                        true, //isEvent
                                        true, //tracksLimited: percentageMode
                                        tracks
                                        );
                                needUpdateEventProgressBar = true;
                            } else {
                                //has arrived, limited by time
                                updateProgressBar= new UpdateProgressBar (
                                        true, //isEvent
                                        false, //timeLimited: activity mode
                                        tracks
                                        );
                                needUpdateEventProgressBar = true;
                            }
                        }

                        distanceTotal = Util.GetRunITotalDistance(distanceInterval, distancesString, tracks);

                        //update graph
                        PrepareEventGraphRunIntervalObject = new PrepareEventGraphRunInterval(
                                distanceIntervalFixed, myRaceTime, intervalTimesString,
                                distanceTotal, distancesString, startIn);

                        needUpdateGraphType = eventType.RUNINTERVAL;
                        needUpdateGraph = true;

                        //put button_finish as sensitive when first jump is done (there's something recordable)
                        if(tracks == 1)
                            needSensitiveButtonFinish = true;
                    }
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
                    //it's out, was inside (= has abandoned platform)

                    if(runPhase == runPhases.PLATFORM_INI_NO_TIME) {
                        //run starts
                        initializeTimer();
                        lastTc = 0;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    } else if(runPhase == runPhases.PLATFORM_INI_YES_TIME) {
                        lastTc = timestamp/1000.0;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    } else {
                        if(checkDoubleContactMode != Constants.DoubleContact.NONE && timestampDCn > 0)
                            timestampDCContactTimes += timestamp;
                        else
                              lastTc = timestamp/1000.0;

                        //RSA
                        double RSAseconds = Util.GetRunIVariableDistancesThisRowIsRSA(
                                distancesString, Convert.ToInt32(tracks));
                        if(RSAseconds > 0) {
                            RSABellDone = false;
                            needShowCountDown = true;
                        } else {
                            needShowCountDown = false;
                            feedbackMessage = "";
                            needShowFeedbackMessage = true;
                        }

                    }

                    runPhase = runPhases.RUNNING;

                    //change the automata state
                    loggedState = States.OFF;
                }
            }
        } while ( ! success && ! cancel && ! finish );

        if (finish) {
            runPhase = runPhases.PLATFORM_END;

            //write();
            //write only if there's a run at minimum
            if(Util.GetNumberOfJumps(intervalTimesString, false) >= 1) {
                writeRunInterval(false); //tempTable = false

                totallyFinished = true;
            } else {
                //cancel a run if clicked finish before any events done, or ended by time without events
                cancel = true;
            }
        }
        if(cancel || finish) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #25
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        double timestampFirstContact = 0; //used when runPhase == runPhases.PLATFORM_INI_YES_TIME;

        double timestampDCFlightTimes = -1; //sum of the flight times that happen in small time
        double timestampDCContactTimes = -1;//sum of the contact times that happen in small time
        double timestampDCn = 0; //number of flight times

        bool success = false;
        bool ok;

        do {
            if(simulated)
                ok = true;
            else
                ok = cp.Read_event(out timestamp, out platformState);

            //if (ok) {
            if (ok && !cancel) {
                //LogB.Information("timestamp:" + timestamp);
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) {
                    //has arrived
                    loggedState = States.ON;

                    if(runPhase == runPhases.PRE_RUNNING) {
                        if(speedStartArrival) {
                            runPhase = runPhases.PLATFORM_INI_YES_TIME;
                            initializeTimer(); //timerCount = 0
                        } else
                            runPhase = runPhases.PLATFORM_INI_NO_TIME;

                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //tracksLimited: percentageMode
                                1 //just reached platform, phase 1/3
                                );
                        needUpdateEventProgressBar = true;
                    } else {
                        //run finished:
                        //if started outside (behind platform) it's the second arrive
                        //if started inside: it's the first arrive

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        //prevent double contact stuff
                        if(checkDoubleContactMode != Constants.DoubleContact.NONE) {
                            if(timestamp <= checkDoubleContactTime) {
                                /*
                                   when checking double contact
                                   first time that timestamp < checkDoubleContactTime
                                   and we arrived (it's a flight time)
                                   record this time as timestampDCFlightTimes
                                 */
                                timestampDCn ++;
                                timestampDCFlightTimes += timestamp;
                            }
                            else {
                                if(timestampDCn > 0) {
                                    if(checkDoubleContactMode ==
                                            Constants.DoubleContact.FIRST) {
                                        /* user want first flight time,
                                           then add all DC times*/
                                        timestamp += timestampDCFlightTimes +
                                            timestampDCContactTimes;
                                    }
                                    else if(checkDoubleContactMode ==
                                            Constants.DoubleContact.LAST) {
                                        //user want last flight time, take that
                                        // It doesn't change the timestamp so this is the same as:
                                        // timestamp = timestamp;
                                    }
                                    else {	/* do the avg of all flights and contacts
                                           then add to last timestamp */
                                        timestamp +=
                                            (timestampDCFlightTimes +
                                             timestampDCContactTimes)
                                            / timestampDCn;
                                    }
                                }
                                success = true;
                            }
                        }

                        if(checkDoubleContactMode == Constants.DoubleContact.NONE)
                            success = true;

                        if(success) {
                            runPhase = runPhases.PLATFORM_END;

                            //add the first contact time if PLATFORM_INI_YES_TIME
                            if(timestampFirstContact > 0)
                                timestamp += timestampFirstContact;

                            time = timestamp / 1000.0;
                            write();

                            //success = true;

                            updateProgressBar = new UpdateProgressBar (
                                    true, //isEvent
                                    true, //percentageMode
                                    //percentageToPass
                                    3
                                    );
                            needUpdateEventProgressBar = true;
                        }
                    }
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
                    //it's out, was inside (= has abandoned platform)
                    //don't record time

                    //change the automata state
                    loggedState = States.OFF;

                    if(checkDoubleContactMode != Constants.DoubleContact.NONE && timestampDCn > 0)
                        timestampDCContactTimes += timestamp;
                    else {
                        if(runPhase == runPhases.PLATFORM_INI_YES_TIME)
                            timestampFirstContact = timestamp;
                        else if(runPhase == runPhases.PLATFORM_INI_NO_TIME)
                            initializeTimer(); //timerCount = 0

                        //update event progressbar
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                2 //normal run, phase 2/3
                                );
                        needUpdateEventProgressBar = true;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;

                        runPhase = runPhases.RUNNING;
                    }
                }
            }
        } while ( ! success && ! cancel );

        if(cancel) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #26
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool success = false;

        bool ok;

        do {
            if(simulated)
                ok = true;
            else
                ok = cp.Read_event(out timestamp, out platformState);

            //if (ok) {
            if (ok && !cancel) {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //has landed
                    if(simulated)
                        timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                    Log.Write(string.Format("t1:{0}", timestamp));

                    time = timestamp / 1000.0;
                    write ();

                    success = true;

                    //update event progressbar
                    double percentageToPass = 2; //has two phases

                    //progressBarEventOrTimePreExecution(
                    //don't do it, put a boolean value and let the PulseGTK do it
                    updateProgressBar = new UpdateProgressBar (
                            true, //isEvent
                            true, //percentageMode
                            percentageToPass
                            );
                    needUpdateEventProgressBar = true;

                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {

                    //it's out, was inside (= has released)

                    initializeTimer();

                    feedbackMessage = "";
                    needShowFeedbackMessage = true;

                    //update event progressbar
                    //progressBarEventOrTimePreExecution(
                    //don't do it, put a boolean value and let the PulseGTK do it
                    updateProgressBar = new UpdateProgressBar (
                            true, //isEvent
                            true, //percentageMode
                            1 //normal jump, phase 1/2
                            );
                    needUpdateEventProgressBar = true;

                    //change the automata state
                    loggedState = States.OFF;

                }
            }
        //Log.WriteLine("PREEXIT");
        } while ( ! success && ! cancel );
        //Log.WriteLine("EXIT");

        if(cancel) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #27
0
 void Awake()
 {
     cooldownBar = GameObject.FindWithTag("Cooldown").GetComponent <UpdateProgressBar>();
 }
Пример #28
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool   success   = false;

        bool ok;

        LogB.Information("Inside waitEvent");
        do
        {
            if (simulated)
            {
                ok = true;
            }
            else
            {
                ok = cp.Read_event(out timestamp, out platformState);
            }

            LogB.Information("Inside do");
            LogB.Information("cancel == ");
            LogB.Information(cancel.ToString());
            LogB.Information("ok == ");
            LogB.Information(ok.ToString());

            //if (ok) {
            if (ok && !cancel)
            {
                LogB.Information("ok!");
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //LogB.Information("condition guai! hem entrat!");
                    //has landed
                    if (simulated)
                    {
                        timestamp = simulatedTimeLast * 1000;                         //conversion to milliseconds
                    }
                    LogB.Information(string.Format("t1:{0}", timestamp));

                    time = timestamp / 1000.0;
                    write();

                    success = true;

                    //update event progressbar
                    double percentageToPass = 2;                     //has two phases

                    //progressBarEventOrTimePreExecution(
                    //don't do it, put a boolean value and let the PulseGTK do it
                    updateProgressBar = new UpdateProgressBar(
                        true,                                 //isEvent
                        true,                                 //percentageMode
                        percentageToPass
                        );
                    needUpdateEventProgressBar = true;

                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {
                    //LogB.Information("condition hem sortit");

                    //it's out, was inside (= has released)

                    initializeTimer();

                    feedbackMessage         = "";
                    needShowFeedbackMessage = true;

                    //update event progressbar
                    //progressBarEventOrTimePreExecution(
                    //don't do it, put a boolean value and let the PulseGTK do it
                    updateProgressBar = new UpdateProgressBar(
                        true,                             //isEvent
                        true,                             //percentageMode
                        1                                 //normal jump, phase 1/2
                        );
                    needUpdateEventProgressBar = true;

                    //change the automata state
                    loggedState = States.OFF;
                }
            }
//Log.WriteLine("PREEXIT");
        } while (!success && !cancel);
//Log.WriteLine("EXIT");

        if (cancel)
        {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #29
0
    protected void waitEvent(Chronopic myCP, Chronopic.Plataforma myPS, States myLS, out string inStr, out string outStr, int cpNum)
    {
        double timestamp = 0;
        bool success = false;
        bool ok;
        string inEqual = "";
        string outEqual = "";

        inStr = ""; outStr = "";
        int runAnalysisTcCount = 0;
        int runAnalysisTfCount = 0;

        bool isFirstOut = true;
        bool isFirstIn = true;

        syncStates syncing = syncStates.DONE;
        if(syncFirst) {
            syncing = syncStates.NOTHING;
            feedbackMessage = Catalog.GetString("Press and mantain Test button in all Chronopics simultaneously.");
            needShowFeedbackMessage = true;
        }

        do {
            ok = myCP.Read_event(out timestamp, out myPS);

            //if chronopic signal is Ok and state has changed
            if (ok && (
                    (myPS == Chronopic.Plataforma.ON && myLS == States.OFF) ||
                    (myPS == Chronopic.Plataforma.OFF && myLS == States.ON) )
                        && !cancel && !finish) {

                //while no finished time or jumps, continue recording events
                if ( ! success) {
                    //don't record the time until the first event of the first Chronopic
                    //this is only executed on the first chronopic that receives a change
                    if (firstValue) {
                        firstValue = false;
                        initializeTimer(); //this is for first Chronopic and only for simulated

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    }

                    if(syncing == syncStates.NOTHING && myPS == Chronopic.Plataforma.ON && myLS == States.OFF) {
                        syncing = syncStates.CONTACTED;
                        feedbackMessage = Catalog.GetString("Release Test button in all Chronopics simultaneously.");
                        needShowFeedbackMessage = true;
                    }
                    else if (syncing == syncStates.CONTACTED && myPS == Chronopic.Plataforma.OFF && myLS == States.ON) {
                        syncing = syncStates.DONE;
                        feedbackMessage = Catalog.GetString("Synchronization done.") + "\n" +
                            Catalog.GetString("Test starts now.");
                        needShowFeedbackMessage = true;
                    }
                    else {
                        if(type != Constants.RunAnalysisName)
                            needSensitiveButtonFinish = true;

                        if(myPS == Chronopic.Plataforma.ON && myLS == States.OFF) {
                            //this is for runAnalysis, delete first tf on 2nd cp (jump cp)
                            if(cpNum == 2 && type == Constants.RunAnalysisName && runAnalysisTfCount == 0)
                                runAnalysisTfCount ++;
                            //this is for multiChronopic, not for runAnalysis
                            else if(deleteFirst && isFirstOut)
                                isFirstOut = false;
                            else {
                                double lastOut = timestamp/1000.0;
                                Log.WriteLine(cpNum.ToString() + " landed: " + lastOut.ToString());
                                outStr = outStr + outEqual + lastOut.ToString();
                                outEqual = "=";
                            }
                            /*
                               if it's a runAnalysis,
                               should end when arrive at 2n photocell (controlled by cp1)
                               */
                            if(cpNum == 1 && type == Constants.RunAnalysisName) {
                                runAnalysisTcCount ++;
                                if(runAnalysisTcCount >= 2) {
                                    success = true;
                                    //better call also finish
                                    //then all cps know about ending
                                    finish = true;
                                }
                            }
                        }
                        else if(myPS == Chronopic.Plataforma.OFF && myLS == States.ON) {
                            //this is for multiChronopic, not for runAnalysis
                            if(deleteFirst && isFirstIn)
                                isFirstIn = false;
                            else {
                                double lastIn = timestamp/1000.0;
                                Log.WriteLine(cpNum.ToString() + " jumped: " + lastIn.ToString());
                                inStr = inStr + inEqual + lastIn.ToString();
                                inEqual = "=";
                            }
                        }

                        PrepareEventGraphMultiChronopicObject = new PrepareEventGraphMultiChronopic(
                                //timestamp/1000.0,
                                cp1StartedIn, cp2StartedIn, cp3StartedIn, cp4StartedIn,
                                cp1InStr, cp1OutStr, cp2InStr, cp2OutStr,
                                cp3InStr, cp3OutStr, cp4InStr, cp4OutStr);
                        needUpdateGraphType = eventType.MULTICHRONOPIC;
                        needUpdateGraph = true;

                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                false, //means activity mode
                                -1 //don't show text
                                );
                        needUpdateEventProgressBar = true;
                    }
                }

                if(myPS == Chronopic.Plataforma.OFF)
                    myLS = States.OFF;
                else
                    myLS = States.ON;

            }
        } while ( ! success && ! cancel && ! finish );

        if (finish) {
            finishThisCp(cpNum);

            //call write on gui/chronojump.cs, because if done in execute/MultiChronopic,
            //will be called n times if n chronopics are working
            //write(false); //tempTable

            //event will be raised, and managed in chronojump.cs
            //only one call (that comes from first chronopic)
            if(cpNum == 1)
                fakeButtonFinished.Click();
        }
        if(cancel) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();
            cancelThisCp(cpNum);
        }
    }
Пример #30
0
    protected override void waitEvent()
    {
        double timestamp = 0;
            bool success = false;
            string equal = "";

            bool ok;

            do {
                if(simulated)
                    ok = true;
                else
                    ok = cp.Read_event(out timestamp, out platformState);

                if (ok && !cancel && !finish) {
                    if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) {
                        //has arrived

                        //if we arrive to the platform for the first time, don't record anything
                        if(pulsePhase == pulsePhases.WAIT_FIRST_EVENT) {
                            pulsePhase = pulsePhases.DOING;
                            //pulse starts
                            initializeTimer();

                            feedbackMessage = "";
                            needShowFeedbackMessage = true;
                        } else {
                            //is not the first pulse
                            if(totalPulsesNum == -1) {
                                //if is "unlimited",
                                //then play with the progress bar until finish button is pressed
                                if(simulated)
                                    timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
                                if(timesString.Length > 0) { equal = "="; }
                                timesString = timesString + equal + (contactTime/1000.0 + timestamp/1000.0).ToString();
                                tracks ++;

                                //update event progressbar
                                //progressBarEventOrTimePreExecution(
                                updateProgressBar= new UpdateProgressBar (
                                        true, //isEvent
                                        false, //activityMode
                                        tracks
                                        );

                                needUpdateEventProgressBar = true;

                                //update graph
                                //preparePulseGraph(timestamp/1000.0, timesString);
                                PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp/1000.0, timesString);
                                needUpdateGraphType = eventType.PULSE;
                                needUpdateGraph = true;

                                //put button_finish as sensitive when first jump is done (there's something recordable)
                                if(tracks == 1)
                                    needSensitiveButtonFinish = true;
                            }
                            else {
                                //is not the first pulse, and it's limited by tracks (ticks)
                                tracks ++;

                                if(simulated)
                                    timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
                                if(timesString.Length > 0) { equal = "="; }
                                timesString = timesString + equal + (contactTime/1000.0 + timestamp/1000.0).ToString();

                                if(tracks >= totalPulsesNum)
                                {
                                    //finished
                                    write();
                                    success = true;
                                    pulsePhase = pulsePhases.DONE;
                                }

                                //update event progressbar
                                //progressBarEventOrTimePreExecution(
                                updateProgressBar= new UpdateProgressBar (
                                        true, //isEvent
                                        true, //PercentageMode
                                        tracks
                                        );
                                needUpdateEventProgressBar = true;

                                //update graph
                                //preparePulseGraph(timestamp/1000.0, timesString);
                                PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp/1000.0, timesString);
                                needUpdateGraphType = eventType.PULSE;
                                needUpdateGraph = true;

                                //put button_finish as sensitive when first jump is done (there's something recordable)
                                if(tracks == 1)
                                    needSensitiveButtonFinish = true;
                            }
                        }

                        //change the automata state
                        loggedState = States.ON;
                    }
                    else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
                        //it's out, was inside (= has abandoned platform)

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds
                        contactTime = timestamp;

                        //change the automata state
                        loggedState = States.OFF;
                    }
                }
            } while ( ! success && ! cancel && ! finish );

            if (finish) {
                write();
                pulsePhase = pulsePhases.DONE;
                totallyFinished= true;
            }
            if(cancel || finish) {
                //event will be raised, and managed in chronojump.cs
                fakeButtonFinished.Click();

                totallyCancelled = true;
            }
    }
Пример #31
0
    protected void writeRj(bool tempTable)
    {
        LogB.Information("----------WRITING----------");
        int    jumps;
        string limitString = "";
        string description = "";

        //if user clicked in finish earlier
        //or toggled with shouldFinishAtNextTime
        if (finish)
        {
            //if user clicked finish and last event was tc, probably there are more TCs than TFs
            //if last event was tc, it has no sense, it should be deleted
            tcString = Util.DeleteLastTcIfNeeded(tcString, tvString);

            //when we mark that jump should finish by time, chronopic thread is probably capturing data
            //check if it captured more than date limit, and if it has done, delete last(s) jump(s)
            //also have in mind that allowFinishAfterTime exist
            bool deletedEvent = false;
            if (!jumpsLimited && limitAsDouble != -1)
            {
                bool eventPassed = Util.EventPassedFromMaxTime(tcString, tvString, limitAsDouble, allowFinishAfterTime);
                while (eventPassed)
                {
                    tcString = Util.DeleteLastSubEvent(tcString);
                    tvString = Util.DeleteLastSubEvent(tvString);
                    LogB.Information("Deleted one event out of time");
                    eventPassed  = Util.EventPassedFromMaxTime(tcString, tvString, limitAsDouble, allowFinishAfterTime);
                    deletedEvent = true;
                }
            }
            if (deletedEvent)
            {
                //update graph if a event was deleted
                PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(Util.GetLast(tvString), Util.GetLast(tcString), tvString, tcString);
                needUpdateGraphType = eventType.JUMPREACTIVE;
                needUpdateGraph     = true;



                //try to fix this:
                //http://mail.gnome.org/archives/chronojump-list/2007-June/msg00013.html
                updateProgressBar = new UpdateProgressBar(
                    true,                                                     //isEvent
                    jumpsLimited,                                             //if jumpsLimited: do fraction; if time limited: do pulse
                    Util.GetNumberOfJumps(tvString, false)
                    );
                needUpdateEventProgressBar = true;
                //and this:
                //http://mail.gnome.org/archives/chronojump-list/2007-June/msg00017.html
                updateTimerCountWithChronopicData(tcString, tvString);
            }

            jumps = Util.GetNumberOfJumps(tvString, false);


            if (jumpsLimited)
            {
                limitString = jumps.ToString() + "J";
            }
            else
            {
                limitString = Util.GetTotalTime(tcString, tvString) + "T";
                limited     = limitString;             //define limited because it's checked in treeviewJump, and possibly it's not the initial defined time (specially when allowFinishRjAfterTime is true)
                //leave the initial selected time into description/comments:
                description = string.Format(Catalog.GetString("Initially selected {0} seconds"), limitAsDouble.ToString());
            }
        }
        else
        {
            if (jumpsLimited)
            {
                limitString = limitAsDouble.ToString() + "J";
                jumps       = (int)limitAsDouble;
            }
            else
            {
                //if time finished and the last event was tc, probably there are more TCs than TFs
                //if last event was tc, it has no sense, it should be deleted
                //this is not aplicable in tempTable
                if (!tempTable)
                {
                    tcString = Util.DeleteLastTcIfNeeded(tcString, tvString);
                }

                //limitString = limitAsDouble.ToString() + "T";
                limitString = Util.GetTotalTime(tcString, tvString) + "T";
                limited     = limitString;             //define limited because it's checked in treeviewJump, and possibly it's not the initial defined time (specially when allowFinishRjAfterTime is true)

                //leave the initial selected time into description/comments:
                description = string.Format(Catalog.GetString("Initially selected {0} seconds"), limitAsDouble.ToString());

                string [] myStringFull = tcString.Split(new char[] { '=' });
                jumps = myStringFull.Length;
            }
        }

        if (type == Constants.RunAnalysisName)
        {
            //double speed = (fall /10) / Util.GetTotalTime(tcString, tvString);

            /*
             *		Josep Ma Padullés test
             *
             *              string tcStringWithoutFirst = Util.DeleteFirstSubEvent(tcString);
             *              string tvStringWithoutFirst = Util.DeleteFirstSubEvent(tvString);
             *
             *              double averagePlatformTimes = ( Util.GetAverage(tcStringWithoutFirst) + Util.GetAverage(tvStringWithoutFirst) ) / 2;
             *              double freq = 1 / averagePlatformTimes;
             *
             *              //amplitud
             *              double range = speed / freq;
             *
             *              //don't put "=" because can appear problems in different parts of the code
             *              description =
             *                      Catalog.GetString ("AVG speed") + "->" + Util.TrimDecimals(speed.ToString(), pDN) + "m/s, " +
             *                      Catalog.GetString ("AVG frequencies") + "->" + Util.TrimDecimals(freq.ToString(), pDN) + "Hz, " +
             *                      Catalog.GetString ("AVG range") + "->" + Util.TrimDecimals(range.ToString(), pDN) + "m.";
             */
        }


        if (tempTable)
        {
            SqliteJumpRj.Insert(false, Constants.TempJumpRjTable, "NULL", personID, sessionID,
                                type, Util.GetMax(tvString), Util.GetMax(tcString),
                                fall, weight, description,
                                Util.GetAverage(tvString), Util.GetAverage(tcString),
                                tvString, tcString,
                                jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated)
                                );
        }
        else
        {
            uniqueID = SqliteJumpRj.Insert(false, Constants.JumpRjTable, "NULL", personID, sessionID,
                                           type, Util.GetMax(tvString), Util.GetMax(tcString),
                                           fall, weight, description,
                                           Util.GetAverage(tvString), Util.GetAverage(tcString),
                                           tvString, tcString,
                                           jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated)
                                           );

            //define the created object
            eventDone = new JumpRj(uniqueID, personID, sessionID, type, tvString, tcString, fall, weight, description, jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated));


            //event will be raised, and managed in chronojump.cs

            /*
             * string myStringPush =
             *      //Catalog.GetString("Last jump: ") +
             *      personName + " " +
             *      type + " (" + limitString + ") " +
             *      " " + Catalog.GetString("AVG TF") + ": " + Util.TrimDecimals( Util.GetAverage (tvString).ToString(), pDN ) +
             *      " " + Catalog.GetString("AVG TC") + ": " + Util.TrimDecimals( Util.GetAverage (tcString).ToString(), pDN ) ;
             */
            if (simulated)
            {
                feedbackMessage = Catalog.GetString(Constants.SimulatedMessage);
            }
            else
            {
                feedbackMessage = "";
            }
            needShowFeedbackMessage = true;


            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            needEndEvent = true;             //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here
        }
    }
Пример #32
0
    protected void waitEvent(Chronopic myCP, Chronopic.Plataforma myPS, States myLS, out string inStr, out string outStr, int cpNum)
    {
        double timestamp = 0;
        bool   success   = false;
        bool   ok;
        string inEqual  = "";
        string outEqual = "";

        inStr = ""; outStr = "";
        int runAnalysisTcCount = 0;
        int runAnalysisTfCount = 0;

        bool isFirstOut = true;
        bool isFirstIn  = true;

        syncStates syncing = syncStates.DONE;

        if (syncFirst)
        {
            syncing                 = syncStates.NOTHING;
            feedbackMessage         = Catalog.GetString("Press and maintain Test button in all Chronopics simultaneously.");
            needShowFeedbackMessage = true;
        }

        do
        {
            ok = myCP.Read_event(out timestamp, out myPS);

            //if chronopic signal is Ok and state has changed
            if (ok && (
                    (myPS == Chronopic.Plataforma.ON && myLS == States.OFF) ||
                    (myPS == Chronopic.Plataforma.OFF && myLS == States.ON)) &&
                !cancel && !finish)
            {
                //while no finished time or jumps, continue recording events
                if (!success)
                {
                    //don't record the time until the first event of the first Chronopic
                    //this is only executed on the first chronopic that receives a change
                    if (firstValue)
                    {
                        firstValue = false;
                        initializeTimer();                         //this is for first Chronopic and only for simulated

                        feedbackMessage         = "";
                        needShowFeedbackMessage = true;
                    }

                    if (syncing == syncStates.NOTHING && myPS == Chronopic.Plataforma.ON && myLS == States.OFF)
                    {
                        syncing                 = syncStates.CONTACTED;
                        feedbackMessage         = Catalog.GetString("Release Test button in all Chronopics simultaneously.");
                        needShowFeedbackMessage = true;
                    }
                    else if (syncing == syncStates.CONTACTED && myPS == Chronopic.Plataforma.OFF && myLS == States.ON)
                    {
                        syncing         = syncStates.DONE;
                        feedbackMessage = Catalog.GetString("Synchronization done.") + "\n" +
                                          Catalog.GetString("Test starts now.");
                        needShowFeedbackMessage = true;
                    }
                    else
                    {
                        if (type != Constants.RunAnalysisName)
                        {
                            needSensitiveButtonFinish = true;
                        }

                        if (myPS == Chronopic.Plataforma.ON && myLS == States.OFF)
                        {
                            //this is for runAnalysis, delete first tf on 2nd cp (jump cp)
                            if (cpNum == 2 && type == Constants.RunAnalysisName && runAnalysisTfCount == 0)
                            {
                                runAnalysisTfCount++;
                            }
                            //this is for multiChronopic, not for runAnalysis
                            else if (deleteFirst && isFirstOut)
                            {
                                isFirstOut = false;
                            }
                            else
                            {
                                double lastOut = timestamp / 1000.0;
                                LogB.Information(cpNum.ToString() + " landed: " + lastOut.ToString());
                                outStr   = outStr + outEqual + lastOut.ToString();
                                outEqual = "=";
                            }

                            /*
                             * if it's a runAnalysis,
                             * should end when arrive at 2n photocell (controlled by cp1)
                             */
                            if (cpNum == 1 && type == Constants.RunAnalysisName)
                            {
                                runAnalysisTcCount++;
                                if (runAnalysisTcCount >= 2)
                                {
                                    success = true;
                                    //better call also finish
                                    //then all cps know about ending
                                    finish = true;
                                }
                            }
                        }
                        else if (myPS == Chronopic.Plataforma.OFF && myLS == States.ON)
                        {
                            //this is for multiChronopic, not for runAnalysis
                            if (deleteFirst && isFirstIn)
                            {
                                isFirstIn = false;
                            }
                            else
                            {
                                double lastIn = timestamp / 1000.0;
                                LogB.Information(cpNum.ToString() + " jumped: " + lastIn.ToString());
                                inStr   = inStr + inEqual + lastIn.ToString();
                                inEqual = "=";
                            }
                        }

                        PrepareEventGraphMultiChronopicObject = new PrepareEventGraphMultiChronopic(
                            //timestamp/1000.0,
                            cp1StartedIn, cp2StartedIn, cp3StartedIn, cp4StartedIn,
                            cp1InStr, cp1OutStr, cp2InStr, cp2OutStr,
                            cp3InStr, cp3OutStr, cp4InStr, cp4OutStr);
                        needUpdateGraphType = eventType.MULTICHRONOPIC;
                        needUpdateGraph     = true;


                        updateProgressBar = new UpdateProgressBar(
                            true,                                  //isEvent
                            false,                                 //means activity mode
                            -1                                     //don't show text
                            );
                        needUpdateEventProgressBar = true;
                    }
                }

                if (myPS == Chronopic.Plataforma.OFF)
                {
                    myLS = States.OFF;
                }
                else
                {
                    myLS = States.ON;
                }
            }
        } while (!success && !cancel && !finish);

        if (finish)
        {
            finishThisCp();

            //call write on gui/chronojump.cs, because if done in execute/MultiChronopic,
            //will be called n times if n chronopics are working
            //write(false); //tempTable
        }
    }
Пример #33
0
    protected void writeRj(bool tempTable)
    {
        Log.WriteLine("----------WRITING----------");
        int jumps;
        string limitString = "";
        string description = "";

        //if user clicked in finish earlier
        //or toggled with shouldFinishAtNextTime
        if(finish) {
            //if user clicked finish and last event was tc, probably there are more TCs than TFs
            //if last event was tc, it has no sense, it should be deleted
            tcString = Util.DeleteLastTcIfNeeded(tcString, tvString);

            //when we mark that jump should finish by time, chronopic thread is probably capturing data
            //check if it captured more than date limit, and if it has done, delete last(s) jump(s)
            //also have in mind that allowFinishAfterTime exist
            bool deletedEvent = false;
            if( ! jumpsLimited && limitAsDouble != -1) {
                bool eventPassed = Util.EventPassedFromMaxTime(tcString, tvString, limitAsDouble, allowFinishAfterTime);
                while(eventPassed) {
                    tcString = Util.DeleteLastSubEvent(tcString);
                    tvString = Util.DeleteLastSubEvent(tvString);
                    Log.WriteLine("Deleted one event out of time");
                    eventPassed = Util.EventPassedFromMaxTime(tcString, tvString, limitAsDouble, allowFinishAfterTime);
                    deletedEvent = true;
                }
            }
            if(deletedEvent) {
                //update graph if a event was deleted
                PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(Util.GetLast(tvString), Util.GetLast(tcString), tvString, tcString);
                needUpdateGraphType = eventType.JUMPREACTIVE;
                needUpdateGraph = true;

                //try to fix this:
                //http://mail.gnome.org/archives/chronojump-list/2007-June/msg00013.html
                            updateProgressBar= new UpdateProgressBar (
                                    true, //isEvent
                                    jumpsLimited, //if jumpsLimited: do fraction; if time limited: do pulse
                                     Util.GetNumberOfJumps(tvString, false)
                                    );
                            needUpdateEventProgressBar = true;
                //and this:
                //http://mail.gnome.org/archives/chronojump-list/2007-June/msg00017.html
                            updateTimerCountWithChronopicData(tcString, tvString);

            }

            jumps = Util.GetNumberOfJumps(tvString, false);

            if(jumpsLimited) {
                limitString = jumps.ToString() + "J";
            } else {
                limitString = Util.GetTotalTime(tcString, tvString) + "T";
                limited = limitString; //define limited because it's checked in treeviewJump, and possibly it's not the initial defined time (specially when allowFinishRjAfterTime is true)
                //leave the initial selected time into description/comments:
                description = string.Format(Catalog.GetString("Initially selected {0} seconds"), limitAsDouble.ToString());
            }
        } else {
            if(jumpsLimited) {
                limitString = limitAsDouble.ToString() + "J";
                jumps = (int) limitAsDouble;
            } else {
                //if time finished and the last event was tc, probably there are more TCs than TFs
                //if last event was tc, it has no sense, it should be deleted
                //this is not aplicable in tempTable
                if(! tempTable)
                    tcString = Util.DeleteLastTcIfNeeded(tcString, tvString);

                //limitString = limitAsDouble.ToString() + "T";
                limitString = Util.GetTotalTime(tcString, tvString) + "T";
                limited = limitString; //define limited because it's checked in treeviewJump, and possibly it's not the initial defined time (specially when allowFinishRjAfterTime is true)

                //leave the initial selected time into description/comments:
                description = string.Format(Catalog.GetString("Initially selected {0} seconds"), limitAsDouble.ToString());

                string [] myStringFull = tcString.Split(new char[] {'='});
                jumps = myStringFull.Length;
            }
        }

        if(type == Constants.RunAnalysisName) {
            //double speed = (fall /10) / Util.GetTotalTime(tcString, tvString);

        /*
         *		Josep Ma Padullés test
         *
            string tcStringWithoutFirst = Util.DeleteFirstSubEvent(tcString);
            string tvStringWithoutFirst = Util.DeleteFirstSubEvent(tvString);

            double averagePlatformTimes = ( Util.GetAverage(tcStringWithoutFirst) + Util.GetAverage(tvStringWithoutFirst) ) / 2;
            double freq = 1 / averagePlatformTimes;

            //amplitud
            double range = speed / freq;

            //don't put "=" because can appear problems in different parts of the code
            description =
                Catalog.GetString ("AVG speed") + "->" + Util.TrimDecimals(speed.ToString(), pDN) + "m/s, " +
                Catalog.GetString ("AVG frequencies") + "->" + Util.TrimDecimals(freq.ToString(), pDN) + "Hz, " +
                Catalog.GetString ("AVG range") + "->" + Util.TrimDecimals(range.ToString(), pDN) + "m.";
                */
        }

        if(tempTable)
            SqliteJumpRj.Insert(false, Constants.TempJumpRjTable, "NULL", personID, sessionID,
                    type, Util.GetMax(tvString), Util.GetMax(tcString),
                    fall, weight, description,
                    Util.GetAverage(tvString), Util.GetAverage(tcString),
                    tvString, tcString,
                    jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated)
                    );
        else {
            uniqueID = SqliteJumpRj.Insert(false, Constants.JumpRjTable, "NULL", personID, sessionID,
                    type, Util.GetMax(tvString), Util.GetMax(tcString),
                    fall, weight, description,
                    Util.GetAverage(tvString), Util.GetAverage(tcString),
                    tvString, tcString,
                    jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated)
                    );

            //define the created object
            eventDone = new JumpRj(uniqueID, personID, sessionID, type, tvString, tcString, fall, weight, description, jumps, Util.GetTotalTime(tcString, tvString), limitString, angleString, Util.BoolToNegativeInt(simulated));

            //event will be raised, and managed in chronojump.cs
            /*
            string myStringPush =
                //Catalog.GetString("Last jump: ") +
                personName + " " +
                type + " (" + limitString + ") " +
                " " + Catalog.GetString("AVG TF") + ": " + Util.TrimDecimals( Util.GetAverage (tvString).ToString(), pDN ) +
                " " + Catalog.GetString("AVG TC") + ": " + Util.TrimDecimals( Util.GetAverage (tcString).ToString(), pDN ) ;
            */
            if(simulated)
                feedbackMessage = Catalog.GetString(Constants.SimulatedMessage);
            else
                feedbackMessage = "";
            needShowFeedbackMessage = true;

            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            needEndEvent = true; //used for hiding some buttons on eventWindow, and also for updateTimeProgressBar here
        }
    }
Пример #34
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool success = false;

        shouldFinishAtNextFall = false;

        bool ok;

        int countForSavingTempTable = 0;

        do {
            if(simulated)
                ok = true;
            else
                ok = cp.Read_event(out timestamp, out platformState);

            //if chronopic signal is Ok and state has changed
            if (ok && (
                    (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) ||
                    (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) )
                        && !cancel && !finish) {

                if(simulated)
                    timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                Log.Write(Util.GetTotalTime(tcString, tvString).ToString());

                string equal = "";

                //while no finished time or jumps, continue recording events
                if ( ! success) {
                    //don't record the time until the first event
                    if (firstRjValue) {
                        firstRjValue = false;

                        //but start timer
                        initializeTimer();

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    } else {
                        //reactive jump has not finished... record the next jump
                        Log.WriteLine(string.Format("tcCount: {0}, tvCount: {1}", tcCount, tvCount));
                        if ( tcCount == tvCount )
                        {
                            lastTc = timestamp/1000.0;

                            if(tcCount > 0) { equal = "="; }
                            tcString = tcString + equal + lastTc.ToString();

                            updateTimerCountWithChronopicData(tcString, tvString);

                            tcCount = tcCount + 1;
                        } else {
                            //tcCount > tvCount
                            lastTv = timestamp/1000.0;

                            if(tvCount > 0) { equal = "="; }
                            tvString = tvString + equal + lastTv.ToString();

                            updateTimerCountWithChronopicData(tcString, tvString);
                            tvCount = tvCount + 1;

                            //update event progressbar
                            //app1.ProgressBarEventOrTimePreExecution(
                            updateProgressBar= new UpdateProgressBar (
                                    true, //isEvent
                                    jumpsLimited, //if jumpsLimited: do fraction; if time limited: do pulse
                                    tvCount
                                    );
                            needUpdateEventProgressBar = true;

                            //update graph
                            PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(lastTv, lastTc, tvString, tcString);
                            needUpdateGraphType = eventType.JUMPREACTIVE;
                            needUpdateGraph = true;

                            //put button_finish as sensitive when first jump is done (there's something recordable)
                            if(tvCount == 1)
                                needSensitiveButtonFinish = true;

                            //save temp table if needed
                            countForSavingTempTable ++;
                            if(countForSavingTempTable == timesForSavingRepetitive) {
                                writeRj(true); //tempTable
                                countForSavingTempTable = 0;
                            }

                        }
                    }
                }

                //if we finish by time, and allowFinishAfterTime == true, when time passed, if the jumper is jumping
                //if flags the shouldFinishAtNextFall that will finish when he arrives to the platform
                if(shouldFinishAtNextFall && platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                    finish = true;

                //check if reactive jump should finish
                if (jumpsLimited) {
                    if(limitAsDouble != -1) {
                        if(Util.GetNumberOfJumps(tvString, false) >= limitAsDouble)
                        {
                            writeRj(false); //tempTable
                            success = true;

                            //update event progressbar
                            //app1.ProgressBarEventOrTimePreExecution(
                            updateProgressBar= new UpdateProgressBar (
                                    true, //isEvent
                                    true, //percentageMode
                                    tvCount
                                    );
                            needUpdateEventProgressBar = true;

                            //update graph
                            PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(lastTv, lastTc, tvString, tcString);
                            needUpdateGraphType = eventType.JUMPREACTIVE;
                            needUpdateGraph = true;
                        }
                    }
                }
                else {
                    //limited by time, if passed it, write
                    if(success) {
                        //write();
                        //write only if there's a jump at minimum
                        if(Util.GetNumberOfJumps(tcString, false) >= 1 && Util.GetNumberOfJumps(tvString, false) >= 1) {
                            writeRj(false); //tempTable
                        } else {
                            //cancel a jump if clicked finish before any events done
                            cancel = true;
                        }
                    }
                }

        /*
                EndingConditionsJumpRj conditions = new EndingConditionsJumpRj();
                if(! conditionsOk(tv,tc)) {
                    finish = true;
                    posar MARCA de que les conditions no estan be i després mostrar quines
        */

                if(platformState == Chronopic.Plataforma.OFF)
                    loggedState = States.OFF;
                else
                    loggedState = States.ON;

            }
        } while ( ! success && ! cancel && ! finish );

        if (finish) {
            //write only if there's a jump at minimum
            if(Util.GetNumberOfJumps(tcString, false) >= 1 && Util.GetNumberOfJumps(tvString, false) >= 1) {
                writeRj(false); //tempTable

                totallyFinished = true;
            } else {
                //cancel a jump if clicked finish before any events done
                cancel = true;
            }
        }
        //if(cancel || finish) {
        if(cancel) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #35
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool success = false;

        bool ok;

        do {
            if(simulated)
                ok = true;
            else
                ok = cp.Read_event(out timestamp, out platformState);

            //if (ok) {
            if (ok && !cancel) {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //has landed
                    if(hasFall && tc == 0) {
                        //jump with fall, landed first time
                        initializeTimer();

                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //jumpsLimited: percentageMode
                                1 //it's a drop: phase 1/3
                                );
                        needUpdateEventProgressBar = true;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    } else {
                        //jump with fall: second landed; or without fall first landing

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        Log.Write(string.Format("t1:{0}", timestamp));

                        tv = timestamp / 1000.0;
                        write ();

                        success = true;

                        //update event progressbar
                        double percentageToPass = 2; //normal jump has two phases
                        if(hasFall)
                            percentageToPass = 3; //drop jump has three phases

                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                percentageToPass
                                );
                        needUpdateEventProgressBar = true;
                    }

                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {

                    //it's out, was inside (= has jumped)

                    if(hasFall) {

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        Log.Write(string.Format("t2:{0}", timestamp));

                        //record the TC
                        tc = timestamp / 1000.0;

                        //takeOff jump (only one TC)
                        //if(fixedValue == 0.5) {
                        if(type == Constants.TakeOffName || type == Constants.TakeOffWeightName) {
                            tv = 0;
                            write ();
                            success = true;
                        }

                        //update event progressbar
                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                2 //it's a drop jump: phase 2/3
                                );
                        needUpdateEventProgressBar = true;
                    } else {
                        initializeTimer();

                        //update event progressbar
                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                1 //normal jump, phase 1/2
                                );
                        needUpdateEventProgressBar = true;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    }

                    //change the automata state
                    loggedState = States.OFF;

                }
            }
        //Log.WriteLine("PREEXIT");
        } while ( ! success && ! cancel );
        //Log.WriteLine("EXIT");

        if(cancel) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #36
0
 public abstract void Run(string analysisItem, UpdateProgressBar updateProgressBar);
Пример #37
0
 private void SetProgressBar(int minValue, int maxValue, int currentValue)
 {
     if (this.progressBar.InvokeRequired)
     {
         UpdateProgressBar d = new UpdateProgressBar(SetProgressBar);
         this.Invoke(d, minValue, maxValue, currentValue);
     }
     else
     {
         this.progressBar.Minimum = (int)minValue;
         this.progressBar.Maximum = (int)maxValue;
         this.progressBar.Value = (int)currentValue;
     }
 }
Пример #38
0
 void Runtime_Update()
 {
     if (this.InvokeRequired)
     {
         UpdateProgressBar update = new UpdateProgressBar(this.Runtime_Update);
         this.Invoke(update);
     }
     else
     {
         if (this.isNewTable == 1 && pi != null)
         {
             this.pgb_complete.Value = pi.GetPercent();
             this.lb_count.Text = "完成数:" + pi.GetDoneCount();
         }
         else if (this.isNewTable == 0 && jnc != null)
         {
             this.pgb_complete.Value = jnc.GetPercent();
             this.lb_count.Text = "完成数:" + jnc.GetDoneCount();
         }
         else if (this.isNewTable == 0 && fe != null)
         {
             this.pgb_complete.Value = fe.GetPercent();
             this.lb_count.Text = "完成数:" + fe.GetDoneCount();
         }
     }
 }
Пример #39
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool   success   = false;

        shouldFinishAtNextFall = false;

        bool ok;

        int countForSavingTempTable = 0;

        do
        {
            if (simulated)
            {
                ok = true;
            }
            else
            {
                ok = cp.Read_event(out timestamp, out platformState);
            }


            //if chronopic signal is Ok and state has changed
            if (ok && (
                    (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) ||
                    (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)) &&
                !cancel && !finish)
            {
                if (simulated)
                {
                    timestamp = simulatedTimeLast * 1000;                     //conversion to milliseconds
                }
                LogB.Information(Util.GetTotalTime(tcString, tvString).ToString());



                string equal = "";

                //while no finished time or jumps, continue recording events
                if (!success)
                {
                    //don't record the time until the first event
                    if (firstRjValue)
                    {
                        firstRjValue = false;

                        //but start timer
                        initializeTimer();

                        feedbackMessage         = "";
                        needShowFeedbackMessage = true;
                    }
                    else
                    {
                        //reactive jump has not finished... record the next jump
                        LogB.Information(string.Format("tcCount: {0}, tvCount: {1}", tcCount, tvCount));
                        if (tcCount == tvCount)
                        {
                            lastTc = timestamp / 1000.0;

                            if (tcCount > 0)
                            {
                                equal = "=";
                            }
                            tcString = tcString + equal + lastTc.ToString();

                            updateTimerCountWithChronopicData(tcString, tvString);

                            tcCount = tcCount + 1;
                        }
                        else
                        {
                            //tcCount > tvCount
                            lastTv = timestamp / 1000.0;

                            if (tvCount > 0)
                            {
                                equal = "=";
                            }
                            tvString = tvString + equal + lastTv.ToString();

                            updateTimerCountWithChronopicData(tcString, tvString);
                            tvCount = tvCount + 1;

                            //update event progressbar
                            //app1.ProgressBarEventOrTimePreExecution(
                            updateProgressBar = new UpdateProgressBar(
                                true,                                         //isEvent
                                jumpsLimited,                                 //if jumpsLimited: do fraction; if time limited: do pulse
                                tvCount
                                );
                            needUpdateEventProgressBar = true;

                            //update graph
                            PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(lastTv, lastTc, tvString, tcString);
                            needUpdateGraphType = eventType.JUMPREACTIVE;
                            needUpdateGraph     = true;

                            //put button_finish as sensitive when first jump is done (there's something recordable)
                            if (tvCount == 1)
                            {
                                needSensitiveButtonFinish = true;
                            }

                            //save temp table if needed
                            countForSavingTempTable++;
                            if (countForSavingTempTable == timesForSavingRepetitive)
                            {
                                writeRj(true);                                 //tempTable
                                countForSavingTempTable = 0;
                            }
                        }
                    }
                }

                //if we finish by time, and allowFinishAfterTime == true, when time passed, if the jumper is jumping
                //if flags the shouldFinishAtNextFall that will finish when he arrives to the platform
                if (shouldFinishAtNextFall && platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    finish = true;
                }


                //check if reactive jump should finish
                if (jumpsLimited)
                {
                    if (limitAsDouble != -1)
                    {
                        if (Util.GetNumberOfJumps(tvString, false) >= limitAsDouble)
                        {
                            jumpPhase = jumpPhases.PLATFORM_END;

                            writeRj(false);                             //tempTable
                            success = true;

                            //update event progressbar
                            //app1.ProgressBarEventOrTimePreExecution(
                            updateProgressBar = new UpdateProgressBar(
                                true,                                         //isEvent
                                true,                                         //percentageMode
                                tvCount
                                );
                            needUpdateEventProgressBar = true;

                            //update graph
                            PrepareEventGraphJumpReactiveObject = new PrepareEventGraphJumpReactive(lastTv, lastTc, tvString, tcString);
                            needUpdateGraphType = eventType.JUMPREACTIVE;
                            needUpdateGraph     = true;
                        }
                    }
                }

                if (platformState == Chronopic.Plataforma.OFF)
                {
                    loggedState = States.OFF;
                }
                else
                {
                    loggedState = States.ON;
                }
            }
        } while (!success && !cancel && !finish);


        if (finish)
        {
            //write only if there's a jump at minimum
            if (Util.GetNumberOfJumps(tcString, false) >= 1 && Util.GetNumberOfJumps(tvString, false) >= 1)
            {
                jumpPhase = jumpPhases.PLATFORM_END;

                writeRj(false);                 //tempTable

                totallyFinished = true;
            }
            else
            {
                //cancel a jump if clicked finish before any events done
                cancel = true;
            }
        }
        //if(cancel || finish)
        if (cancel)
        {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #40
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool   success   = false;
        string equal     = "";

        bool ok;

        //prepare variables to allow being cancelled or finished
        if (!simulated)
        {
            Chronopic.InitCancelAndFinish();
        }

        do
        {
            if (simulated)
            {
                ok = true;
            }
            else
            {
                ok = cp.Read_event(out timestamp, out platformState);
            }


            if (ok && !cancel && !finish)
            {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //has arrived

                    //if we arrive to the platform for the first time, don't record anything
                    if (pulsePhase == pulsePhases.WAIT_FIRST_EVENT)
                    {
                        pulsePhase = pulsePhases.DOING;
                        //pulse starts
                        initializeTimer();

                        feedbackMessage         = "";
                        needShowFeedbackMessage = true;
                    }
                    else
                    {
                        //is not the first pulse
                        if (totalPulsesNum == -1)
                        {
                            //if is "unlimited",
                            //then play with the progress bar until finish button is pressed
                            if (simulated)
                            {
                                timestamp = simulatedTimeLast * 1000;                                         //conversion to milliseconds
                            }
                            if (timesString.Length > 0)
                            {
                                equal = "=";
                            }
                            timesString = timesString + equal + (contactTime / 1000.0 + timestamp / 1000.0).ToString();
                            tracks++;

                            //update event progressbar
                            //progressBarEventOrTimePreExecution(
                            updateProgressBar = new UpdateProgressBar(
                                true,                                                 //isEvent
                                false,                                                //activityMode
                                tracks
                                );

                            needUpdateEventProgressBar = true;

                            //update graph
                            //preparePulseGraph(timestamp/1000.0, timesString);
                            PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp / 1000.0, timesString);
                            needUpdateGraphType          = eventType.PULSE;
                            needUpdateGraph = true;

                            //put button_finish as sensitive when first jump is done (there's something recordable)
                            if (tracks == 1)
                            {
                                needSensitiveButtonFinish = true;
                            }
                        }
                        else
                        {
                            //is not the first pulse, and it's limited by tracks (ticks)
                            tracks++;

                            if (simulated)
                            {
                                timestamp = simulatedTimeLast * 1000;                                         //conversion to milliseconds
                            }
                            if (timesString.Length > 0)
                            {
                                equal = "=";
                            }
                            timesString = timesString + equal + (contactTime / 1000.0 + timestamp / 1000.0).ToString();

                            if (tracks >= totalPulsesNum)
                            {
                                //finished
                                write();
                                success    = true;
                                pulsePhase = pulsePhases.DONE;
                            }

                            //update event progressbar
                            //progressBarEventOrTimePreExecution(
                            updateProgressBar = new UpdateProgressBar(
                                true,                                                 //isEvent
                                true,                                                 //PercentageMode
                                tracks
                                );
                            needUpdateEventProgressBar = true;

                            //update graph
                            //preparePulseGraph(timestamp/1000.0, timesString);
                            PrepareEventGraphPulseObject = new PrepareEventGraphPulse(timestamp / 1000.0, timesString);
                            needUpdateGraphType          = eventType.PULSE;
                            needUpdateGraph = true;

                            //put button_finish as sensitive when first jump is done (there's something recordable)
                            if (tracks == 1)
                            {
                                needSensitiveButtonFinish = true;
                            }
                        }
                    }

                    //change the automata state
                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {
                    //it's out, was inside (= has abandoned platform)

                    if (simulated)
                    {
                        timestamp = simulatedTimeLast * 1000;                                 //conversion to milliseconds
                    }
                    contactTime = timestamp;

                    //change the automata state
                    loggedState = States.OFF;
                }
            }
        } while (!success && !cancel && !finish);

        if (finish)
        {
            write();
            pulsePhase = pulsePhases.DONE;
        }
    }
Пример #41
0
 void Runtime_Update()
 {
     if (this.InvokeRequired)
     {
         UpdateProgressBar update = new UpdateProgressBar(this.Runtime_Update);
         this.Invoke(update);
     }
     else
     {
         this.pgb.Value = FileWorker.GetPercent();
         this.lb_total.Text = "总数:" + FileWorker.totalCount;
         this.lb_succ.Text = "成功数:" + FileWorker.succCount;
         this.lb_fail.Text = "失败数:" + FileWorker.failCount;
         this.lb_rep.Text = "重复数:" + FileWorker.repCount;
     }
 }
Пример #42
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool success = false;

        bool ok;
        int phase = 0;

        do {
            if(simulated)
                ok = true;
            else
            {
                LogB.Information("calling Read_event");
                ok = cp.Read_event(out timestamp, out platformState);
                LogB.Information("Read_event done!");
            }

            /*
             *           \()/            \()/
             *            \/              \/
             *   _()_     /\     _()_     /\     _()_
             *    \/              \/              \/
             * ___/\______________/\______________/\___
             *
             *  GraphA  graphB  graphC  graphD  graphE
             *  unused  jumps   lands   jumps   lands
             *
             *    ______start_______             end
             *
             *    DJ      DJ      SJ
             * hasFall  hasFall
             * fall -1
             *
             */

            //if (ok)
            if (ok && !cancel) {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF)
                {
                    //has landed
                    if(hasFall && tc == 0)
                    {
                        //**** graphC ****

                        if(fall == -1) {
                            if(simulated)
                                timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                            //calculate the fall height using flight time
                            double tvPreJump = timestamp / 1000.0;
                            fall = Convert.ToDouble(Util.GetHeightInCentimeters(tvPreJump.ToString()));
                        }

                        //jump with fall, landed first time
                        initializeTimer();

                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //jumpsLimited: percentageMode
                                ++phase
                                );
                        needUpdateEventProgressBar = true;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;

                    } else {
                        //**** graphE **** jump with fall: second landed; or without fall first landing

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        LogB.Information(string.Format("t1:{0}", timestamp));

                        tv = timestamp / 1000.0;

                        jumpPhase = jumpPhases.PLATFORM_END;

                        write();

                        success = true;

                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                ++phase
                                );
                        needUpdateEventProgressBar = true;
                    }
                    loggedState = States.ON;
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON)
                {
                    //it's out, was inside (= has jumped)

                    //fall != -1 because if it was == -1, it will change once touching floor for the first time
                    if(hasFall && fall != -1) {
                        //**** graphD ****

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        LogB.Information(string.Format("t2:{0}", timestamp));

                        //record the TC
                        tc = timestamp / 1000.0;

                        //takeOff jump (only one TC)
                        //if(fixedValue == 0.5)
                        if(type == Constants.TakeOffName || type == Constants.TakeOffWeightName) {
                            tv = 0;

                            jumpPhase = jumpPhases.PLATFORM_END;

                            write();
                            success = true;
                        }

                        //update event progressbar
                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                ++phase
                                );
                        needUpdateEventProgressBar = true;
                    } else {
                        //**** graphD (if normal jump) ****
                        //**** graphB (if hasFall and fall == -1) ****

                        initializeTimer();

                        //update event progressbar
                        //app1.ProgressBarEventOrTimePreExecution(
                        //don't do it, put a boolean value and let the PulseGTK do it
                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                ++phase
                                );
                        needUpdateEventProgressBar = true;

                        feedbackMessage = "";
                        needShowFeedbackMessage = true;
                    }

                    //change the automata state
                    loggedState = States.OFF;
                }
            }
        } while ( ! success && ! cancel );

        LogB.Information("Exited waitEvent main bucle");

        if(cancel)
        {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }
Пример #43
0
    protected override void waitEvent()
    {
        double timestamp = 0;
        bool success = false;

        bool ok;

        do {
            if(simulated)
                ok = true;
            else
                ok = cp.Read_event(out timestamp, out platformState);

            //if (ok) {
            if (ok && !cancel) {
                if (platformState == Chronopic.Plataforma.ON && loggedState == States.OFF) {
                    //has arrived
                    loggedState = States.ON;

                    if(runPhase == runPhases.PRE_RUNNING) {
                        runPhase = runPhases.PLATFORM_INI;

                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //tracksLimited: percentageMode
                                1 //just reached platform, phase 1/3
                                );
                        needUpdateEventProgressBar = true;
                    } else {
                        //run finished:
                        //if started outside (behind platform) it's the second arrive
                        //if started inside: it's the first arrive

                        if(simulated)
                            timestamp = simulatedTimeLast * 1000; //conversion to milliseconds

                        time = timestamp / 1000.0;
                        write();

                        success = true;

                        updateProgressBar = new UpdateProgressBar (
                                true, //isEvent
                                true, //percentageMode
                                //percentageToPass
                                3
                                );
                        needUpdateEventProgressBar = true;

                        runPhase = runPhases.PLATFORM_END;
                    }
                }
                else if (platformState == Chronopic.Plataforma.OFF && loggedState == States.ON) {
                    //it's out, was inside (= has abandoned platform)
                    //don't record time

                    initializeTimer();

                    //update event progressbar
                    updateProgressBar = new UpdateProgressBar (
                            true, //isEvent
                            true, //percentageMode
                            2 //normal run, phase 2/3
                            );
                    needUpdateEventProgressBar = true;

                    feedbackMessage = "";
                    needShowFeedbackMessage = true;

                    //change the automata state
                    loggedState = States.OFF;

                    runPhase = runPhases.RUNNING;
                }
            }
        } while ( ! success && ! cancel );

        if(cancel) {
            //event will be raised, and managed in chronojump.cs
            fakeButtonFinished.Click();

            totallyCancelled = true;
        }
    }