示例#1
0
        protected override void OnProcessOutputSchema(MutableObject newSchema)
        {
            // We don't modify the input schema in adapters... We may derive values from input schemas, but adapters always send a novel schema...

            var roundScores = new RoundScores();

            roundScores.Add(new TeamScores()
            {
                SubmissionScores = new List <SubmissionScore>()
                {
                    new SubmissionScore()
                }
            });

            var teamsList = ParseRoundData(newSchema, roundScores);

            var newRound = new MutableObject();

            newRound["Teams"] = teamsList;

            newRound["Round Number"] = 0;

            var roundsList = new List <MutableObject>();

            roundsList.Add(newRound);

            RoundsTarget.SetValue(roundsList, newSchema);
            DataIndexTarget.SetValue(1, newSchema);

            Router.TransmitAllSchema(newSchema);
        }
示例#2
0
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var minRound = MinRoundNumber.GetFirstValue(payload.Data);
            var maxRound = MaxRoundNumber.GetFirstValue(payload.Data);

            var roundsList = new List <MutableObject>();

            for (int roundNum = minRound; roundNum <= maxRound; roundNum++)
            {
                var getScoresCommand = new GetScoresForRoundCommand(roundNum);

                var iterator = CommandProcessor.Execute(getScoresCommand);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }

                var teamsList = ParseRoundData(payload.Data, getScoresCommand.Scores);

                var newRound = new MutableObject();
                newRound["Teams"] = teamsList;

                newRound["Round Number"] = roundNum;

                roundsList.Add(newRound);
            }

            RoundsTarget.SetValue(roundsList, payload.Data);

            var groupId = GroupId.GetFirstValue(payload.Data);

            var index = (DataShare.ContainsKey(groupId)
                ? DataShare[groupId]
                : 0);

            if (groupId != "")
            {
                DataShare[groupId] = index + 1;
            }

            DataIndexTarget.SetValue(index, payload.Data);

            var transmitIterator = Router.TransmitAll(payload);

            while (transmitIterator.MoveNext())
            {
                yield return(null);
            }
        }
        public override IEnumerator ReceivePayload(VisualPayload payload)
        {
            var minRound = MinRoundNumber.GetFirstValue(payload.Data);
            var maxRound = MaxRoundNumber.GetFirstValue(payload.Data);

            var scoresList = new List <MutableObject>();

            for (int roundNum = minRound; roundNum <= maxRound; roundNum++)
            {
                var getScoresCommand = new GetScoresForRoundCommand(roundNum);

                var iterator = CommandProcessor.Execute(getScoresCommand);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }

                var roundList = ParseRoundData(payload.Data, getScoresCommand.Scores, roundNum);

                scoresList.AddRange(roundList);
            }

            // if we've just sampled a missing round, fill in with round zero data
            if (scoresList.Count == 0)
            {
                var getScoresCommand = new GetScoresForRoundCommand(0);

                var iterator = CommandProcessor.Execute(getScoresCommand);
                while (iterator.MoveNext())
                {
                    yield return(null);
                }

                // zero out round scores
                foreach (var score in getScoresCommand.Scores)
                {
                    foreach (var subScore in score.SubmissionScores)
                    {
                        subScore.Evaluation.Total = 0;
                        subScore.Availability.Functionality.Total = 0;
                        subScore.Availability.Performance.Total   = 0;
                        subScore.Availability.Total = 0;
                        subScore.Security.Consensus = 0;
                        subScore.Security.Reference = 0;
                        subScore.Security.Total     = 0;
                        subScore.Total = 0;
                    }
                }

                var roundList = ParseRoundData(payload.Data, getScoresCommand.Scores, 0);

                scoresList.AddRange(roundList);
            }

            ScoresTarget.SetValue(scoresList, payload.Data);

            var groupId = GroupId.GetFirstValue(payload.Data);

            var index = (DataShare.ContainsKey(groupId)
                ? DataShare[groupId]
                : 0);

            if (groupId != "")
            {
                DataShare[groupId] = index + 1;
            }

            DataIndexTarget.SetValue(index, payload.Data);

            var transmitIterator = Router.TransmitAll(payload);

            while (transmitIterator.MoveNext())
            {
                yield return(null);
            }
        }