Esempio n. 1
0
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// Stores the accuracy of the marker position when player responded.
    /// </summary>
    protected override void AddResult(Trial t, float xPos)
    {
        TrialResult r = new TrialResult(t);

        r.accuracy = GetAccuracy(xPos);
        int score = GetScore(xPos);

        if (IsHighResponse(score))
        {
            DisplayFeedback(HIGH_RESPONSE, RESPONSE_COLOR_HIGH, score);
            r.success = true;
            GUILog.Log("EXCELLENT! Score = {0}", score);
        }
        else if (IsMediumResponse(score))
        {
            DisplayFeedback(MEDIUM_RESPONSE, RESPONSE_COLOR_MEDIUM, score);
            r.success = true;
            GUILog.Log("Good! Score = {0}", score);
        }
        else if (IsLowResponse(score))
        {
            DisplayFeedback(LOW_RESPONSE, RESPONSE_COLOR_LOW, score);
            r.success = true;
            GUILog.Log("Ok. Score = {0}", score);
        }
        else
        {
            DisplayFeedback(LOWEST_RESPONSE, RESPONSE_COLOR_LOWEST, score);
            r.success = false;
            GUILog.Log("Bad... Score = {0}", score);
        }
        sessionData.results.Add(r);
    }
Esempio n. 2
0
        public void Save(MeasureValueHolder holder)
        {
            SimulationContext        context           = new SimulationContext();
            Func <TrialResult, bool> selecTionFunction = x => x.Size == ((int)holder.SimulationSize) &&
                                                         x.StartUtil == holder.StartUtilization.ToString() &&
                                                         x.Change == holder.ChangeAction.ToString() &&
                                                         x.Algorithm == holder.Strategy.ToString() &&
                                                         x.PushAuctionType == holder.Configuration.PushAuctionType.ToString() &&
                                                         x.PullAuctionType == holder.Configuration.PullAuctionType.ToString() &&
                                                         x.TestedPercent == (int)holder.TestedPercent &&
                                                         x.SchedulingAlgorithm == holder.Scheduling.ToString() &&
                                                         x.NetworkDelay == holder.NetworkDelay &&
                                                         x.ContainerType == holder.ContainerType.ToString() &&
                                                         x.TrialId == holder.TrialId;

            TrialResult t = context.TrialResults.SingleOrDefault(selecTionFunction) ?? new TrialResult();

            t.Size                    = ((int)holder.SimulationSize);
            t.StartUtil               = holder.StartUtilization.ToString();
            t.Change                  = holder.ChangeAction.ToString();
            t.Algorithm               = holder.Strategy.ToString();
            t.PushAuctionType         = holder.Configuration.PushAuctionType.ToString();
            t.PullAuctionType         = holder.Configuration.PullAuctionType.ToString();
            t.TestedPercent           = (int)holder.TestedPercent;
            t.SchedulingAlgorithm     = holder.Scheduling.ToString();
            t.ContainerType           = holder.ContainerType.ToString();
            t.NetworkDelay            = holder.NetworkDelay;
            t.TrialId                 = holder.TrialId;
            t.PredictionAlg           = holder.Prediction.ToString();
            t.AverageEntropy          = holder.AverageEntropy;
            t.Power                   = holder.PowerConsumption;
            t.StdDev                  = holder.AverageStdDeviation;
            t.Hosts                   = holder.AverageHosts;
            t.RMSE                    = holder.RMSE;
            t.TotalMessages           = holder.TotalMessages;
            t.TotalCommunicatedData   = holder.TotalCommunicatedSize;
            t.Migrations              = holder.TotalMigrations;
            t.SlaViolations           = holder.TotalSlaViolationsCount;
            t.SlaViolationsPercent    = holder.AverageSlaViolationsPercent;
            t.ImagePullsTotal         = holder.ImagePulls;
            t.ImagePullsRatio         = holder.AveragePullPerImage;
            t.FinalEntropy            = holder.FinalEntropy;
            t.ContainersAverage       = holder.AverageContainers;
            t.AverageContainerPerHost = holder.AverageContainersPerHost;
            t.TotalContainers         = holder.TotalContainers;
            t.AverageDownTime         = holder.AverageDownTime;
            context.TrialResults.AddOrUpdate(t);
            context.SaveChanges();
        }
Esempio n. 3
0
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// </summary>
    protected override void AddResult(Trial t, float time)
    {
        TrialResult r = new TrialResult(t);

        r.responseTime = time;
        if (time == 0 && !t.isRed)
        {
            DisplayFeedback(RESPONSE_TIMEOUT, RESPONSE_COLOR_BAD);
            GUILog.Log("FAIL! No Response");
        }
        else if (time == 0 && t.isRed)
        {
            r.success = true;
            DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
            GUILog.Log("Correct! responseTime = {0}", time);
        }
        else
        {
            if (IsGuessResponse(time))
            {
                DisplayFeedback(RESPONSE_GUESS, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Guess response! responseTime = {0}", time);
            }
            else if (IsValidResponse(time) && !t.isRed)
            {
                DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                r.success  = true;
                r.accuracy = GetAccuracy(t, time);
                GUILog.Log("Success! responseTime = {0}", time);
            }
            else if (IsValidResponse(time) && t.isRed)
            {
                DisplayFeedback(RESPONSE_INCORRECT, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Incorrect response! responseTime = {0}", time);
            }
            else
            {
                DisplayFeedback(RESPONSE_SLOW, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Slow response! responseTime = {0}", time);
            }
        }
        sessionData.results.Add(r);
    }
Esempio n. 4
0
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// </summary>
    protected override void AddResult(Trial t, float time)
    {
        if (!t.isRed)
        {
            //Stimulus is not red. The new implementation is not required.
            base.AddResult(t, time);
            return;
        }
        //Stimulus is red. New implementation is required.
        TrialResult r = new TrialResult(t);

        r.responseTime = time;
        r.isRed        = true;
        if (time == 0)
        {
            // No response.
            DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
            r.success  = true;
            r.accuracy = 1;
            GUILog.Log("Success! No response!");
        }
        else
        {
            if (IsGuessResponse(time))
            {
                // Responded before the guess limit, aka guessed.
                DisplayFeedback(RESPONSE_GUESS, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Guess response! responseTime = {0}", time);
            }
            else
            {
                // Responded too slow.
                DisplayFeedback(RESPONSE_WRONG, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Response detected! responseTime = {0}", time);
            }
        }
        sessionData.results.Add(r);
    }
Esempio n. 5
0
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// </summary>
    protected override void AddResult(Trial t, float time)
    {
        TrialResult r = new TrialResult(t);

        r.responseTime = time;
        if (time == 0)
        {
            // No response.
            DisplayFeedback(RESPONSE_TIMEOUT, RESPONSE_COLOR_BAD);
            GUILog.Log("Fail! No response!");
        }
        else
        {
            if (IsGuessResponse(time))
            {
                // Responded before the guess limit, aka guessed.
                DisplayFeedback(RESPONSE_GUESS, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Guess response! responseTime = {0}", time);
            }
            else if (IsValidResponse(time))
            {
                // Responded correctly.
                DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                r.success  = true;
                r.accuracy = GetAccuracy(t, time);
                GUILog.Log("Success! responseTime = {0}", time);
            }
            else
            {
                // Responded too slow.
                DisplayFeedback(RESPONSE_SLOW, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Slow response! responseTime = {0}", time);
            }
        }
        sessionData.results.Add(r);
    }
Esempio n. 6
0
        private TrialResult RequestTrial(
            string companyName
            , string sizeOfGroup
            , string description
            , string domain
            , string firstName
            , string lastName
            , string email
            , string phone
            , string country
            , string login
            , string password
            , string resellerGuid
            , string xml
            , string locale
            , string referrer
            , out int requestId
            , out string requestGuid
            )
        {
            TrialResult retVal = TrialResult.Failed;

            requestId   = -1;
            requestGuid = string.Empty;

            AspSettings settings = AspSettings.Load();

            domain += "." + settings.DnsParentDomain;
            try
            {
                //if (CManage.IsUserRegistered(settings, email))
                //    retVal = TrialResult.UserRegistered;
                //else
                if (CManage.CompanyExists(domain))
                {
                    retVal = TrialResult.DomainExists;
                }
                else
                {
                    requestId = DBTrialRequest.Create(
                        companyName,
                        sizeOfGroup,
                        description,
                        domain,
                        firstName,
                        lastName,
                        email,
                        phone,
                        country,
                        login,
                        password,
                        new Guid(resellerGuid),
                        xml,
                        locale
                        , referrer
                        );

                    TemplateVariables vars = DBTrialRequest.GetVariables(requestId);
                    requestGuid = vars["RequestGUID"];
                    retVal      = TrialResult.WaitingForActivation;

//					if (!string.IsNullOrEmpty(settings.OperatorEmail))
//						CManage.SendEmail(settings.OperatorEmail, EmailType.TrialNewRequest, vars);
                }
            }
            finally
            {
                if (retVal != TrialResult.Success && retVal != TrialResult.WaitingForActivation && retVal != TrialResult.RequestPending)
                {
                    object obj = null;
                    try
                    {
                        obj = new Guid(resellerGuid);
                    }
                    catch (ArgumentNullException)
                    {
                    }
                    catch (FormatException)
                    {
                    }

                    DBTrialRequestFailed.Create(
                        companyName,
                        sizeOfGroup,
                        description,
                        domain,
                        firstName,
                        lastName,
                        email,
                        phone,
                        login,
                        login,
                        password,
                        obj
                        , locale
                        , referrer
                        , (int)retVal
                        );
                }
            }
            return(retVal);
        }
Esempio n. 7
0
        public TrialResult ActivateTrialCompany2(
            int requestId
            , string requestGuid
            , out string portalUrl
            , out string login
            , out string password
            , out string companyId
            )
        {
            portalUrl = "";
            login     = "";
            password  = "";
            companyId = "";

            TrialResult ret  = TrialResult.InvalidRequest;
            Guid        guid = new Guid(requestGuid);

            if (DBTrialRequest.CheckGuid(requestId, guid))
            {
                bool isActive = false;
                using (IDataReader reader = DBTrialRequest.Get(requestId, true, false))
                {
                    if (reader.Read())
                    {
                        isActive = (bool)reader["IsActive"];
                        if (reader["Company_uid"] != DBNull.Value)
                        {
                            companyId = (string)reader["Company_uid"];
                        }
                    }
                }

                if (isActive)
                {
                    ret = TrialResult.AlreadyActivated;
                }
                else
                {
                    Guid companyUid = CManage.ASPCreateTrialCompany(requestId);
                    ret       = TrialResult.Success;
                    companyId = companyUid.ToString();

                    AspSettings       settings = AspSettings.Load();
                    TemplateVariables vars     = CManage.CompanyGetVariables(companyUid);
                    TemplateVariables varsR    = DBTrialRequest.GetVariables(requestId);
                    vars["Login"]          = varsR["Login"];
                    vars["Password"]       = varsR["Password"];
                    vars["TrialUsers"]     = settings.MaxUsers.ToString();
                    vars["TrialDiskSpace"] = settings.MaxHDD.ToString();
                    vars["TrialPeriod"]    = settings.TrialPeriod.ToString();

                    portalUrl = vars["PortalLink"];

                    if (!string.IsNullOrEmpty(vars["ContactEmail"]))
                    {
                        CManage.SendEmail(vars["ContactEmail"], EmailType.UserActivated, vars);
                    }
                    if (!string.IsNullOrEmpty(settings.OperatorEmail))
                    {
                        CManage.SendEmail(settings.OperatorEmail, EmailType.TrialActivated, vars);
                    }

                    login    = varsR["Login"];
                    password = varsR["Password"];
                }
            }
            return(ret);
        }
Esempio n. 8
0
        private void UpdateCachedTrialResult()
        {
#if Iron7Free
            CachedTrialResult = TrialResult.Trial;
#else
            if (CachedTrialResult == TrialResult.Unknown)
            {
                Microsoft.Phone.Marketplace.LicenseInformation license = new Microsoft.Phone.Marketplace.LicenseInformation();
                if (license.IsTrial())
                    CachedTrialResult = TrialResult.Trial;
                else
                    CachedTrialResult = TrialResult.Full;
            }
#endif
        }
Esempio n. 9
0
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// </summary>
    protected override void AddResult(Trial t, float time)
    {
        TrialResult r = new TrialResult(t);

        r.responseTime = time;
        if (time == 0)
        {
            if (((AzzaranoTrial)t).red == "false" && ball == false)
            {
                // No response.
                DisplayFeedback(RESPONSE_TIMEOUT, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! No response!");
            }
            else if (((AzzaranoTrial)t).red == "false" && ball == true)
            {
                DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                r.success  = true;
                r.accuracy = GetAccuracy(t, time);
                GUILog.Log("Success! Didn't respond to BALL.");
                score += 1;
            }
            else
            {
                // Responded correctly.
                DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                r.success  = true;
                r.accuracy = GetAccuracy(t, time);
                GUILog.Log("Success! Didn't respond to RED.");
                score += 1;
            }
        }
        else
        {
            if (IsGuessResponse(time))
            {
                // Responded before the guess limit, aka guessed.
                DisplayFeedback(RESPONSE_GUESS, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Guess response! responseTime = {0}", time);
            }
            else if (IsValidResponse(time))
            {
                if (((AzzaranoTrial)t).red == "false" && ball == false)
                {
                    // Responded correctly.
                    DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                    r.success  = true;
                    r.accuracy = GetAccuracy(t, time);
                    GUILog.Log("Success! responseTime = {0}", time);
                    score += 1;
                }
                else if (((AzzaranoTrial)t).red == "false" && ball == true)
                {
                    // Responded incorrectly.
                    DisplayFeedback(RESPONSE_HITBALL, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Not supposed to respond to BALL");
                }
                else
                {
                    // Responded incorrectly.
                    DisplayFeedback(RESPONSE_HITRED, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Not supposed to respond to RED");
                }
            }
            else
            {
                if (((AzzaranoTrial)t).red == "false" && ball == false)
                {
                    // Responded too slow.
                    DisplayFeedback(RESPONSE_SLOW, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Slow response! responseTime = {0}", time);
                }
                else if (((AzzaranoTrial)t).red == "false" && ball == true)
                {
                    // Responded incorrectly.
                    DisplayFeedback(RESPONSE_HITBALL, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Not supposed to respond to BALL");
                }
                else
                {
                    // Responded incorrectly.
                    DisplayFeedback(RESPONSE_HITRED, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Not supposed to respond to RED");
                }
            }
        }
        sessionData.results.Add(r);
    }
Esempio n. 10
0
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// </summary>
    protected override void AddResult(Trial t, float time)
    {
        TrialResult r = new TrialResult(t);

        r.responseTime = time;
        // stim isRed and times out
        // Result: Correct response
        if (time == 0 && t.isRed)
        {
            DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
            GUILog.Log("Success! Didn't click red! responseTime = {0}", time);
            sessionData.results.Add(r);
            return;
        }
        // If not red and times out
        // Result: Fail. No response
        if (time == 0 && !t.isRed)
        {
            // No response.
            DisplayFeedback(RESPONSE_TIMEOUT, RESPONSE_COLOR_BAD);
            GUILog.Log("Fail! No response!");
        }
        else
        {
            // Player Guesses
            if (IsGuessResponse(time))
            {
                // Responded before the guess limit, aka guessed.
                DisplayFeedback(RESPONSE_GUESS, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Guess response! responseTime = {0}", time);
            }

            // Player responds in time and it is not red
            else if (IsValidResponse(time) && !t.isRed)
            {
                // Responded correctly.
                DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                r.success  = true;
                r.accuracy = GetAccuracy(t, time);
                GUILog.Log("Success! responseTime = {0}", time);
            }

            // player responds and it is red
            else if (IsValidResponse(time) && t.isRed)
            {
                // Responded correctly but wrong color
                DisplayFeedback(RESPONSE_INCORRECT, RESPONSE_COLOR_BAD);
                r.success  = false;
                r.accuracy = GetAccuracy(t, time);
                GUILog.Log("Fail! responseTime = {0}", time);
            }

            // No responce
            else
            {
                // Catch in case it is red and gets to here
                if (t.isRed)
                {
                    DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                    GUILog.Log("Success! Didn't click red! responseTime = {0}", time);
                }
                // No response and fail
                else
                {
                    DisplayFeedback(RESPONSE_SLOW, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Slow response! responseTime = {0}", time);
                }
            }
        }
        sessionData.results.Add(r);
    }
    /// <summary>
    /// Adds a result to the SessionData for the given trial.
    /// </summary>
    protected override void AddResult(Trial t, float time)
    {
        TrialResult r = new TrialResult(t);

        r.responseTime = time;
        if (time == 0)
        {
            // If no response, check if stimulus has valid color or not (Valid color = white, not valid color = red).
            if (IsValidStimulusColor(t))
            {
                GUILog.Log("Fail! No response!");
                DisplayFeedback(RESPONSE_TIMEOUT, RESPONSE_COLOR_BAD);
            }
            else
            {
                GUILog.Log("Success! Ignored the red square!");
                DisplayFeedback(RESPONSE_RED_IGNORED, RESPONSE_COLOR_GOOD);
                r.success = true;
            }
        }
        else
        {
            if (IsGuessResponse(time) && IsValidStimulusColor(t))
            {
                // Responded before the guess limit, aka guessed.
                DisplayFeedback(RESPONSE_GUESS, RESPONSE_COLOR_BAD);
                GUILog.Log("Fail! Guess response! responseTime = {0}", time);
            }
            else if (IsValidResponse(time))
            {
                if (IsValidStimulusColor(t))
                {
                    // Responded correctly.
                    DisplayFeedback(RESPONSE_CORRECT, RESPONSE_COLOR_GOOD);
                    r.success  = true;
                    r.accuracy = GetAccuracy(t, time);
                    GUILog.Log("Success! responseTime = {0}", time);
                }
                else
                {
                    DisplayFeedback(RESPONSE_RED, RESPONSE_COLOR_BAD);
                    r.success  = false;
                    r.accuracy = GetAccuracy(t, time);
                    GUILog.Log("Fail! Responded to wrong color");
                }
            }
            else
            {
                // Responded too slow.
                if (IsValidStimulusColor(t))
                {
                    DisplayFeedback(RESPONSE_SLOW, RESPONSE_COLOR_BAD);
                    GUILog.Log("Fail! Slow response! responseTime = {0}", time);
                }
                else
                {
                    DisplayFeedback(RESPONSE_RED, RESPONSE_COLOR_BAD);
                    r.success  = false;
                    r.accuracy = GetAccuracy(t, time);
                    GUILog.Log("Fail! Responded to wrong color");
                }
            }
        }

        // Preparing and writing data in result
        if (currentColorIsRed)
        {
            r.isRed = true;
        }
        else
        {
            r.isRed = false;
        }
        r.positionX = (int)StimRandomPos.x;
        r.positionY = (int)StimRandomPos.y;
        sessionData.results.Add(r);
    }