protected override MutableObject Mutate(MutableObject mutable) { var groupId = GroupId.GetFirstValue(mutable); if (groupId == "") { DataShare.Remove(groupId); } foreach (var entry in DiffValue.GetEntries(mutable)) { if (DataShare.ContainsKey(groupId)) { DiffTarget.SetValue( DiffValue.GetValue(entry) - DataShare[groupId], entry); DataShare[groupId] = DiffValue.GetValue(entry); } else { DiffTarget.SetValue(0f, entry); DataShare[groupId] = DiffValue.GetValue(entry); } } return(mutable); }
public override IEnumerator ReceivePayload(VisualPayload payload) { if (DataShare == null) { DataShare = new NodeDataShare <Socket>(); } var IPs = Dns.GetHostAddresses(TargetAddress.GetFirstValue(payload.Data)); var newSocket = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { newSocket.Connect(IPs.First(), TargetPort.GetFirstValue(payload.Data)); DataShare[GroupId.GetFirstValue(payload.Data)] = newSocket; } catch (Exception e) { Debug.LogError("Could not connect to socket! Error: " + e); } yield break; }
public override IEnumerator ReceivePayload(VisualPayload payload) { var groupId = GroupId.GetFirstValue(payload.Data); var singleElement = SingleElement.GetFirstValue(payload.Data); var targetElementCount = NumberOfEntries.GetFirstValue(payload.Data); if (!DataShare.ContainsKey(groupId)) { DataShare[groupId] = new List <MutableObject>(); } DataShare[groupId].Add(singleElement); if (DataShare[groupId].Count >= targetElementCount) { var dataList = DataShare[groupId]; RecombinedListTarget.SetValue(dataList, payload.Data); DataShare[groupId] = new List <MutableObject>(); var iterator = Router.TransmitAll(payload); while (iterator.MoveNext()) { yield return(null); } } }
protected override MutableObject Mutate(MutableObject mutable) { var groupId = GroupId.GetFirstValue(mutable); Dictionary <T, int> localShare; if (groupId != "") { if (!DataShare.ContainsKey(groupId)) { DataShare.Add(groupId, new Dictionary <T, int>()); } localShare = DataShare[groupId]; } else { localShare = new Dictionary <T, int>(); } foreach (var entry in AxisKey.GetEntries(mutable)) { var key = AxisKey.GetValue(entry); if (!localShare.ContainsKey(key)) { localShare[key] = 0; } IndexAxis.SetValue(localShare[key], entry); localShare[key]++; } return(mutable); }
protected override MutableObject Mutate(MutableObject mutable) { if (DataShare == null) { DataShare = new NodeDataShare <Dictionary <int, Vector3> >(); } var groupId = GroupId.GetFirstValue(mutable); if (!DataShare.ContainsKey(groupId)) { DataShare[groupId] = new Dictionary <int, Vector3>(); } var vectors = DataShare[groupId]; //var vectors = new Dictionary<int, Vector3>(); foreach (var subEntry in EntryPosition.GetEntries(mutable)) { var index = EntryIndex.GetValue(subEntry); var position = EntryPosition.GetValue(subEntry); vectors[index] = position; } return(mutable); }
protected override MutableObject Mutate(MutableObject mutable) { var groupId = GroupId.GetFirstValue(mutable); var storeExists = WriteDataSharedVectorList.DataShare != null && WriteDataSharedVectorList.DataShare.ContainsKey(groupId); if (!storeExists) { foreach (var subEntry in Index.GetEntries(mutable)) { VectorTarget.SetValue(Vector3.zero, subEntry); } return(mutable); } var foundStore = WriteDataSharedVectorList.DataShare[groupId]; foreach (var subEntry in Index.GetEntries(mutable)) { var index = Index.GetValue(subEntry); VectorTarget.SetValue( foundStore.ContainsKey(index) ? foundStore[index] : Vector3.zero, subEntry); } return(mutable); }
protected override MutableObject Mutate(MutableObject mutable) { var entries = AxisKey.GetEntries(mutable); var foundStrings = new HashSet <T>(); // identify the set of unique keys foreach (var entry in entries) { var axisKey = InputStack.TransformValue(AxisKey.GetValue(entry)); if (!foundStrings.Contains(axisKey)) { foundStrings.Add(axisKey); } } // DO NOT sort the keys //var sortedKeys = foundStrings.ToList(); //sortedKeys.Sort(); // index the values var axisValues = GroupId.GetFirstValue(mutable) == "" ? new Dictionary <T, int>() : DataShare.ContainsKey(GroupId.GetFirstValue(mutable)) ? DataShare[GroupId.GetFirstValue(mutable)] : new Dictionary <T, int>(); int i = 0; foreach (var key in foundStrings) //sortedKeys { axisValues[key] = OutputStack.TransformValue(i++); } // finally, write the new axis value into each entry entries = AxisKey.GetEntries(mutable); foreach (var entry in entries) { IndexAxis.SetValue( axisValues[InputStack.TransformValue(AxisKey.GetValue(entry))], entry); } if (GroupId.GetFirstValue(mutable) != "") { DataShare[GroupId.GetFirstValue(mutable)] = axisValues; } return(mutable); }
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 groupId = GroupId.GetFirstValue(payload.Data); if (!ConnectToDataSharedSocketMutator.DataShare.ContainsKey(groupId)) { Debug.LogError("Error: could not find socket with group ID " + groupId + " to transmit through."); yield break; } var socket = ConnectToDataSharedSocketMutator.DataShare[groupId]; foreach (var entry in DataToSend.GetEntries(payload.Data)) { var data = DataToSend.GetValue(entry); socket.Send(Encoding.ASCII.GetBytes(data)); } }
public override IEnumerator ReceivePayload(VisualPayload payload) { var groupId = GroupId.GetFirstValue(payload.Data); if (ActivatedGroupIDs.Contains(groupId)) { JobManager.Instance.StartJob( TransmitPair(new TransmitWaitPair(payload, DefaultState)), jobName: "Delay", startImmediately: true, maxExecutionsPerFrame: 1); // mex is 1 for testing yield break; } if (!WaitingTransmissions.ContainsKey(groupId)) { WaitingTransmissions[groupId] = new List <TransmitWaitPair>(); } WaitingTransmissions[groupId].Add(new TransmitWaitPair(payload, DefaultState)); }
public override IEnumerator ReceivePayload(VisualPayload payload) { var groupId = GroupId.GetFirstValue(payload.Data); if (!WaitingTransmissions.ContainsKey(groupId)) { WaitingTransmissions[groupId] = new List <SequencedRepeatPair>(); } WaitingTransmissions[groupId].Add(ProduceTransmissionFunc(payload)); var iterator = BeginSequenceState.Transmit(payload); while (iterator.MoveNext()) { yield return(null); } //start sequence UnwaitGroupId(groupId); }
protected override IEnumerator ProcessPayload(VisualPayload payload) { var groupId = GroupId.GetFirstValue(payload.Data); DataSharedTooltipVisualizer newVisualizer; if (!DataShare.ContainsKey(groupId)) { newVisualizer = VisualizerFactory.InstantiateDataSharedTooltipVisualizer(); newVisualizer.Initialize(this, payload); DataShare[groupId] = newVisualizer; } else { newVisualizer = DataShare[groupId]; } newVisualizer.TextColor = FontColor.GetFirstValue(payload.Data); newVisualizer.FontSize = FontSize.GetFirstValue(payload.Data); newVisualizer.BackgroundColor = BackgroundColor.GetFirstValue(payload.Data); newVisualizer.CheckRedeclareStyle(); newVisualizer.DisplayText = ShowTooltip.GetFirstValue(payload.Data)? Tooltip.GetFirstValue(payload.Data):""; newVisualizer.DrawPosition = ScreenPosition.GetFirstValue(payload.Data); var iterator = Router.TransmitAll(payload); while (iterator.MoveNext()) { yield return(null); } }
private VisualPayload ParseData() { //var randomGen = new Random(1337); var mutablesList = new List <MutableObject>(); foreach (var team in ScoreFromJsonFilter.LoadedTeams) { //var teamColor = ColorUtility.HsvtoRgb((float)randomGen.NextDouble(), .8f, 1f); var teamColor = TeamColorPalette.ColorFromIndex(team.TeamID); foreach (var entry in team.SubmissionScores) { var newMutable = TurnSubmissionIntoMutable(entry, team, teamColor); mutablesList.Add(newMutable); } } ScoreTarget.SetValue(mutablesList, Payload.Data); var groupId = GroupId.GetFirstValue(Payload.Data); var index = (DataShare.ContainsKey(groupId) ? DataShare[groupId] : 0); if (groupId != "") { DataShare[groupId] = index + 1; } IndexField.SetValue(index, Payload.Data); return(Payload); }
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); } }