Example #1
0
 public LocalComponent(Guid machineGuid, int machineNumber)
 {
     this.machineNumber = machineNumber;
     this.machineGuid   = machineGuid;
     performanceManager = new PerformanceManager();
     activeJobs         = new List <IJob <TJob> >();
 }
 public HomeController(
     IPerformanceManager handler,
     IPerformanceSitemapService performanceSitemapService)
 {
     _handler = handler;
     _performanceSitemapService = performanceSitemapService;
 }
Example #3
0
        private void btnRebuild_Click(object sender, EventArgs e)
        {
            Query q   = null;
            var   cq  = new StringBuilder();
            var   fac = PerformanceManagerFactory.Instance;
            IPerformanceManager man = fac.GetPerformanceManager(_s.ServerConnection);

            foreach (UltraListViewItem li in _view.lvwIndexes.CheckedItems)
            {
                var i = (Sql8rIndex)li.Tag;
                q = man.GetRebuildIndexQuery(_s, _db, _t, i);

                string sql = q.Sql;
                if (cq.Length > 0)
                {   // todo removing first line is not nice solution
                    sql = q.Sql.Remove(0, q.Sql.IndexOf(Environment.NewLine) + Environment.NewLine.Length);
                }
                cq.Append(sql);
                cq.Append(Environment.NewLine);
                //  cq.Append(Environment.NewLine);
            }
            if (q != null)
            {
                var    c        = new Query(q.ServerConnection, q.ServerName, q.DatabaseName, cq.ToString());
                string fileName = string.Format("{0}", "rebuild");
                var    p        = (EditorWithDataGridPresenter)MainPresenter.Instance.OpenMdiTab(MainPresenter.MdiTabKeys.EditorWithDataGrid);
                p.EditIndex(c, fileName);
            }
        }
 public CurrentMachineStateManager(IPerformanceManager performanceManager, IComponentProperties machineInfo,
                                   ITaskRunner <TJob> localBallancer)
 {
     this.performanceManager = performanceManager;
     this.machineInfo        = machineInfo;
     this.localBallancer     = localBallancer;
 }
Example #5
0
 public void testSetup()
 {
     _mockAccessor       = new PerformanceAccessorMock();
     _performanceManager = new PerformanceManager(_mockAccessor);
     _performances       = new List <Performance>();
     _performances       = _performanceManager.RetrieveAllPerformance();
 }
Example #6
0
 public LocalBallancer(IBallancerTask <TJob, TJobType> ballancerTask, IPerformanceManager performanceManager,
                       IRemoteMachinesManager remoteMachines, int currentMachineId)
 {
     if (ballancerTask == null)
     {
         throw new ArgumentNullException("ballancerTask");
     }
     if (performanceManager == null)
     {
         throw new ArgumentNullException("performanceManager");
     }
     if (remoteMachines == null)
     {
         throw new ArgumentNullException("remoteMachines");
     }
     this.ballancerTask      = ballancerTask;
     this.performanceManager = performanceManager;
     this.remoteMachines     = remoteMachines;
     this.currentMachineId   = currentMachineId;
 }
Example #7
0
    /// <summary>
    /// Initializes the ExperimentSystem and its components.
    /// Verifies that all components needed for the experiment are available.
    /// This must be done in Start.
    /// Extend this method by doing your own implementation, with base.InitExperimentSystem() being called at the start.
    /// </summary>
    public override void InitialiseExperimentSystems()
    {
        //
        // Set the experiment type configuration
        //
        // Type one if able-bodied subject
        if (AvatarSystem.AvatarType == AvatarType.AbleBodied)
        {
            experimentType        = ExperimentType.TypeOne; // Able-bodied experiment type
            taskDataFormat        = ablebodiedDataFormat;
            performanceDataFormat = ablebodiedPerformanceDataFormat;
        }
        // Type two if prosthetic (Adaptive Synergy)
        else if (AvatarSystem.AvatarType == AvatarType.Transhumeral)
        {
            experimentType        = ExperimentType.TypeTwo; // Able-bodied experiment type
            taskDataFormat        = prostheticDataFormat;
            performanceDataFormat = prostheticPerformanceDataFormat;
        }
        // Then run the base initialisation which is needed, with a small modification
        //
        // Set the experiment name only when debugging. Take  the name from the gameobject + Debug
        //
        if (debug)
        {
            ExperimentSystem.SetActiveExperimentID(this.gameObject.name + "_Debug");
        }

        // Make sure flow control is initialised
        sessionNumber   = 1;
        iterationNumber = 1;

        //
        // Create the default data loggers
        //
        taskDataLogger = new DataStreamLogger("TaskData/" + AvatarSystem.AvatarType.ToString());
        ExperimentSystem.AddExperimentLogger(taskDataLogger);
        taskDataLogger.AddNewLogFile(sessionNumber, iterationNumber, taskDataFormat); // Add file

        // Restart UDP threads
        foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
        {
            if (sensor is UDPSensorManager udpSensor)
            {
                //Debug.Log(wifiSensor.RunThread);
                udpSensor.StartSensorReading();
                //Debug.Log(wifiSensor.RunThread);
            }
        }

        // Send the player to the experiment centre position
        TeleportToStartPosition();

        startPosPhoto.SetActive(false);

        //
        // Create the performance data loggers
        //
        performanceDataLogger = new DataStreamLogger("PerformanceData");
        ExperimentSystem.AddExperimentLogger(performanceDataLogger);
        performanceDataLogger.AddNewLogFile(AvatarSystem.AvatarType.ToString(), sessionNumber, performanceDataFormat); // Add file

        if (SaveSystem.ActiveUser.lefty)
        {
            leftySign = -1.0f;
        }

        //
        // Iterations configuration
        //
        // Set iterations variables for flow control.
        targetNumber = gridRows * gridColumns;
        for (int i = 0; i < iterationsPerSession.Count; i++)
        {
            iterationsPerSession[i] = targetNumber * iterationsPerTarget;
        }

        // Create the list of target indexes and shuffle it.
        for (int i = 0; i < targetNumber; i++)
        {
            for (int j = 0; j < iterationsPerTarget; j++)
            {
                targetOrder.Add(i);
            }
        }
        targetOrder.Shuffle();

        //
        // Initialize world positioning
        //
        // Get user physiological data.
        float subjectHeight    = SaveSystem.ActiveUser.height;
        float subjectArmLength = SaveSystem.ActiveUser.upperArmLength + SaveSystem.ActiveUser.forearmLength + (SaveSystem.ActiveUser.handLength / 2);

        // Set the grid distance from subject
        gridManager.transform.position = new Vector3((-gridReachMultiplier * subjectArmLength) - 0.1f, gridHeightMultiplier * subjectHeight, 0.0f);

        //
        // Add arm motion trackers for able-bodied case.
        //
        if (experimentType == ExperimentType.TypeOne)
        {
            // Lower limb motion tracker
            GameObject llMotionTrackerGO = GameObject.FindGameObjectWithTag("ForearmTracker");
            lowerArmTracker = new VIVETrackerManager(llMotionTrackerGO.transform);
            ExperimentSystem.AddSensor(lowerArmTracker);

            // Upper limb motion tracker
            GameObject ulMotionTrackerGO = AvatarSystem.AddMotionTracker();
            upperArmTracker = new VIVETrackerManager(ulMotionTrackerGO.transform);
            ExperimentSystem.AddSensor(upperArmTracker);
        }
        else if (experimentType == ExperimentType.TypeTwo)
        {
            // Get active sensors from avatar system and get the vive tracker being used for the UA
            foreach (ISensor sensor in AvatarSystem.GetActiveSensors())
            {
                if (sensor is VIVETrackerManager)
                {
                    upperArmTracker = (VIVETrackerManager)sensor;
                }
            }
            if (upperArmTracker == null)
            {
                throw new System.NullReferenceException("The residual limb tracker was not found.");
            }

            // Set VIVE tracker and Linear synergy as active.
            // Get prosthesis
            prosthesisManagerGO = GameObject.FindGameObjectWithTag("ProsthesisManager");
            elbowManager        = prosthesisManagerGO.GetComponent <ConfigurableElbowManager>();
            // Set the reference generator to linear synergy.
            elbowManager.ChangeSensor("VAL_SENSOR_VIVETRACKER");
            elbowManager.ChangeReferenceGenerator("VAL_REFGEN_LINKINSYN");

            // Create the personalisation algorithm object
            elbowManager.SetSynergy(theta);
            float[]   ditherFrequency = { Mathf.PI / 4, 2 * Mathf.PI / 4 };
            float[]   observerGain    = { 0.3840f, 0.6067f, -0.2273f, -0.8977f, -1.0302f };
            float[][] A = new float[2][];
            A[0] = new float[2] {
                1.3130f, -0.8546f
            };
            A[1] = new float[2] {
                1.0f, 0.0f
            };
            float[] B = { 1.0f, 0.0f };
            float[] C = { 0.0131f, -0.0131f };
            float   D = 0.0f;
            personaliser = new TransCyberHPIPersonalisation(ditherAmplitude, 0, ditherFrequency, observerGain, 1, optimiserGain, 0.1f, A, B, C, D, theta, 0.1f, 3.0f);
        }

        if (evaluatorType == EvaluatorType.Compensation)
        {
            // Performance evaluation objects
            evaluator    = new UpperBodyCompensationMotionPM(0.5f, 0.5f);
            shDataBuffer = new List <Vector3>();
            c7DataBuffer = new List <Vector3>();
        }
        else if (evaluatorType == EvaluatorType.KinematicEnergy)
        {
            throw new System.NotImplementedException("KE method not yet implemented");
        }

        // Debug?
        if (!debug)
        {
            // Shoulder acromium head tracker
            GameObject motionTrackerGO1 = AvatarSystem.AddMotionTracker();
            shoulderTracker = new VIVETrackerManager(motionTrackerGO1.transform);
            ExperimentSystem.AddSensor(shoulderTracker);
            // C7 tracker
            GameObject motionTrackerGO2 = AvatarSystem.AddMotionTracker();
            c7Tracker = new VIVETrackerManager(motionTrackerGO2.transform);
            ExperimentSystem.AddSensor(c7Tracker);
        }

        //
        // Hand tracking sensor
        //
        GameObject handGO = GameObject.FindGameObjectWithTag("Hand");

        handTracker = new VirtualPositionTracker(handGO.transform);
        ExperimentSystem.AddSensor(handTracker);

        // Spawn grid
        gridManager.SpawnGrid(gridRows, gridColumns, gridSpacing);
    }