public IIndexResponse AddWatch(Watch watch) { var mock = MockRepository.GenerateMock<IIndexResponse>(); mock.Stub(x => x.Created).Return(true); return mock; }
public IIndexResponse AddWatch(Watch watch) { var client = _config.GetElasticClient(); var indexResponse = client.Index(watch); return indexResponse; }
public void Add_PlusNull_DoesNotAlterDate() { var now = new DateTime(2001, 10, 10, 11, 05, 02); TimeProvider.Now = () => now; var watch = new Watch(); Assert.AreEqual(now, (watch + null).WhatTimeIsIt()); Assert.AreEqual(now, (null + watch).WhatTimeIsIt()); }
private void HardSetDisplayTypeDropDown(Watch.DisplayType type) { foreach (var item in DisplayTypeDropdown.Items) { if (Watch.DisplayTypeToString(type) == item.ToString()) { DisplayTypeDropdown.SelectedItem = item; } } }
public void AddWatchProperty(string name, string fieldName, object instance) { Watch w = new Watch(); w.name = name; w.instance = new WeakReference(instance, false); w.property = instance.GetType().GetProperty(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (instance == null || w.property == null) return; watches.Add(w); }
public void Add_TotalMoreThanSixtySeconds_AsExtraMinute() { TimeProvider.Now = () => new DateTime(2001, 10, 10, 11, 05, 02); var watch = new Watch(); TimeProvider.Now = () => new DateTime(2001, 10, 10, 11, 10, 59); var fiveMinutesLater = new Watch(); var combined = watch + fiveMinutesLater; Assert.AreEqual(16, combined.WhatTimeIsIt().Minute); Assert.AreEqual(01, combined.WhatTimeIsIt().Second); }
public void Add_TotalMoreThanSixtyMinutes_AsExtraHour() { TimeProvider.Now = () => new DateTime(2001, 10, 10, 1, 05, 00); var watch = new Watch(); TimeProvider.Now = () => new DateTime(2001, 10, 10, 1, 56, 00); var fiveMinutesLater = new Watch(); var combined = watch + fiveMinutesLater; Assert.AreEqual(3, combined.WhatTimeIsIt().Hour); Assert.AreEqual(01, combined.WhatTimeIsIt().Minute); }
public void Add_CombinesHourAndMinutesAndSeconds_IntoANewWatch() { TimeProvider.Now = () => new DateTime(2001, 10, 10, 11, 05, 00); var watch = new Watch(); TimeProvider.Now = () => new DateTime(2001, 10, 10, 11, 10, 02); var fiveMinutesLater = new Watch(); var combined = watch + fiveMinutesLater; Assert.AreEqual(22, combined.WhatTimeIsIt().Hour); Assert.AreEqual(15, combined.WhatTimeIsIt().Minute); Assert.AreEqual(02, combined.WhatTimeIsIt().Second); }
public void Add_DoesNotMutate() { var nowWatch = new DateTime(2001, 10, 10, 11, 05, 02); TimeProvider.Now = () => nowWatch; var watch = new Watch(); var nowFiveMinutesLater = new DateTime(2001, 10, 10, 11, 10, 59); TimeProvider.Now = () => nowFiveMinutesLater; var fiveMinutesLater = new Watch(); var newWatch = watch + fiveMinutesLater; Assert.AreNotSame(newWatch, watch); Assert.AreNotSame(newWatch, fiveMinutesLater); Assert.AreEqual(nowWatch, watch.WhatTimeIsIt()); Assert.AreEqual(nowFiveMinutesLater, fiveMinutesLater.WhatTimeIsIt()); }
private UnitOracle(WoWUnit unit, Watch watchFlags) { if (unit != null) { this.Unit = unit; Flags = watchFlags; if (instances.ContainsKey(unit.Guid)) throw new NotSupportedException(); instances[unit.Guid] = this; if ((Flags & Watch.HealthVariance) == Watch.HealthVariance) { health = new CircularBuffer<double>(WINDOW_SIZE); for (var i = 0; i < WINDOW_SIZE; i++) health.Enqueue((double)Unit.CurrentHealth); } } }
public void Freeze_Test_On_WatchNode() { var model = CurrentDynamoModel; //create some numbers var numberNode1 = new DoubleInput(); numberNode1.Value = "1"; var numberNode2 = new DoubleInput(); numberNode2.Value = "2"; var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+")); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false)); //connect them up model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); //add a watch node var watchNode = new Watch(); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4); Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3); //check the value AssertPreviewValue(addNode.GUID.ToString(), 3); //check the watch node value AssertPreviewValue(watchNode.GUID.ToString(), 3); }
public Task ReceiveAsync(IContext context) { switch (context.Message) { case RemoteTerminate msg: { _watched.Remove(msg.Watcher.Id); _watcher.Remove(msg.Watchee.Id); //create a terminated event for the Watched actor var t = new Terminated { Who = msg.Watchee, AddressTerminated = true }; //send the address Terminated event to the Watcher msg.Watcher.SendSystemMessage(t); break; } case EndpointTerminatedEvent _: { foreach (var kvp in _watched) { var id = kvp.Key; var pid = kvp.Value; //create a terminated event for the Watched actor var t = new Terminated { Who = pid, AddressTerminated = true }; var watcher = new PID(ProcessRegistry.Instance.Address, id); //send the address Terminated event to the Watcher watcher.SendSystemMessage(t); } break; } case RemoteUnwatch msg: { _watched[msg.Watcher.Id] = null; _watcher[msg.Watchee.Id] = null; var w = new Unwatch(msg.Watcher); msg.Watchee.SendSystemMessage(w); break; } case RemoteWatch msg: { _watched[msg.Watcher.Id] = msg.Watchee; _watcher[msg.Watchee.Id] = msg.Watcher; var w = new Watch(msg.Watcher); msg.Watchee.SendSystemMessage(w); break; } default: break; } return(Actor.Done); }
private void DrawWatchVariableNamePopup(Watch watch) { if (watchableVariableNames == null || watchableVariableNames.Length == 0) { List<string> variableNames = new List<string>(); if (database != null) { foreach (var variable in database.variables) { variableNames.Add(variable.Name); } } watchableVariableNames = variableNames.ToArray(); } int newIndex = EditorGUILayout.Popup(watch.variableIndex, watchableVariableNames); if (newIndex != watch.variableIndex) { watch.variableIndex = newIndex; if (0 <= watch.variableIndex && watch.variableIndex < watchableVariableNames.Length) { watch.expression = string.Format("Variable[\"{0}\"]", DialogueLua.StringToTableIndex(watchableVariableNames[watch.variableIndex])); } else { watch.expression = string.Empty; } watch.Evaluate(); } }
public void UnFreeze_ParentNode_UnfreezesChildNodes_Test() { var model = CurrentDynamoModel; //create some numbers var numberNode1 = new DoubleInput(); numberNode1.Value = "1"; var numberNode2 = new DoubleInput(); numberNode2.Value = "2"; var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+")); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false)); //connect them up model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); //add a watch node var watchNode = new Watch(); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4); Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3); BeginRun(); //check the value AssertPreviewValue(addNode.GUID.ToString(), 3); //Add the number node to selection and call Freeze state on the workspace. //this should freeze the number node. numberNode1.IsFrozen = true; // the number node must be frozen and not executing state Assert.AreEqual(numberNode1.IsFrozen, true); //the add node must be frozen and can execute state Assert.AreEqual(addNode.IsFrozen, true); //check the value AssertPreviewValue(addNode.GUID.ToString(), 3); //check the watch node value AssertPreviewValue(watchNode.GUID.ToString(), 3); //now the number node1 is frozen. change the value. numberNode1.Value = "3.0"; //check the value of add node. it should not change. AssertPreviewValue(addNode.GUID.ToString(), 3); //unfreeze the input node numberNode1.IsFrozen = false; Assert.AreEqual(numberNode1.IsFrozen, false); //Now the add node should be in unfreeze state Assert.AreEqual(addNode.IsFrozen, false); //Now the add node should get the value AssertPreviewValue(addNode.GUID.ToString(), 5); //check the watch node value AssertPreviewValue(watchNode.GUID.ToString(), 5); }
/// <summary> /// Stops the stop watch /// </summary> public virtual void Stop() { StartTime = 0; StopTime = (int)Watch.ElapsedMilliseconds; Watch.Stop(); }
/// <summary> /// 结束计时 /// </summary> public virtual void Stop() { Watch.Stop(); }
/// <summary> /// 重置计时器 /// </summary> public virtual void Reset() { Watch.Reset(); }
/// <summary> /// 开始计时 /// </summary> public virtual void Start() { Reset(); Watch.Start(); }
/// <summary> /// Watches a file descriptor for activity. /// </summary> /// <remarks> /// When the condition is met, the provided callback /// is invoked. If the callback returns false, the /// watch is automatically removed. /// /// The return value is a token that represents this watch, you can /// use this token to remove the watch by calling RemoveWatch. /// </remarks> public object AddWatch(int fileDescriptor, Condition condition, Func<MainLoop,bool> callback) { if (callback == null) throw new ArgumentNullException ("callback"); var watch = new Watch () { Condition = condition, Callback = callback, File = fileDescriptor }; descriptorWatchers [fileDescriptor] = watch; poll_dirty = true; return watch; }
public void Stop() { Watch.Stop(); }
private void bntConnect_Click(object sender, EventArgs e) { if (bntConnect.Text == "CONNECT") { try { if (cbCom.Text == "" || cbBaur.Text == "") { lbStripStatus.Text = "Please select PORT setting."; } else { UART.PortName = cbCom.Text; UART.BaudRate = Convert.ToInt32(cbBaur.Text); UART.Open(); progressBar.Value = 100; UART.Write("R"); if (bntMode.Text == "MODE 1") { UART.Write("2"); } else if (bntMode.Text == "MODE 2") { UART.Write("1"); } lbStripStatus.Text = "CONNECT TO " + UART.PortName; bntConnect.Text = "DISCONNECT"; cbCom.Enabled = false; cbBaur.Enabled = false; bntGate.Enabled = true; bntReset.Enabled = true; bntReady.Enabled = true; bntSend.Enabled = true; bntMode.Enabled = true; tbTx.Enabled = true; } } catch (UnauthorizedAccessException) { lbStripStatus.Text = "Unauthor Access."; } } else { progressBar.Value = 0; UART.Write("R"); UART.Close(); CountDown.Stop(); Watch.Stop(); TimerWatch.Stop(); lbCountDown.Text = "READY"; lbWatch1.Text = "00:00:000"; lbWatch2.Text = "00:00:000"; bntConnect.Text = "CONNECT"; cbCom.Enabled = true; cbBaur.Enabled = true; bntGate.Enabled = false; bntReady.Enabled = false; bntStart.Enabled = false; bntSend.Enabled = false; bntMode.Enabled = false; tbTx.Enabled = false; } }
public void AddWatch(string name, ulong address, int size) { if (!(size == 8 || size == 16 || size == 32 || size == 64)) return; var watch = new Watch(address, size); watches.Add(watch); watchView.AddWatch(name, address, size, false); }
protected override void OnHandler(ParameterHandlerInfo info) { Core.Log.Warning("Starting MEMORY STREAMS TEST"); Core.Log.WriteEmptyLine(); Core.Log.InfoBasic("Press Enter to Start RecycleMemoryStream Test."); Console.ReadLine(); var xbuffer = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; using (Watch.Create("RecycleMemoryStream")) { for (var m = 0; m < 50000; m++) { using (var rms = new RecycleMemoryStream()) { for (var x = 0; x < 1; x++) { for (int i = 0; i < 10000; i++) { rms.Write(xbuffer, 0, xbuffer.Length); } } rms.Position = 0; for (var x = 0; x < 10; x++) { for (int i = 0; i < 2000; i++) { var bt = rms.ReadByte(); } } } } } Core.Log.WriteEmptyLine(); Core.Log.InfoBasic("Press Enter to Start MemoryStream Test."); Console.ReadLine(); using (Watch.Create("MemoryStream")) { for (var m = 0; m < 50000; m++) { using (var rms = new MemoryStream()) { for (var x = 0; x < 1; x++) { for (var i = 0; i < 10000; i++) { rms.Write(xbuffer, 0, xbuffer.Length); } } rms.Position = 0; for (var x = 0; x < 10; x++) { for (var i = 0; i < 2000; i++) { var bt = rms.ReadByte(); } } } } } Core.Log.WriteEmptyLine(); Core.Log.InfoBasic("Press Enter to Start CircularBufferStream Test. Press Enter Again to finish the test."); Console.ReadLine(); using (var cbs = new CircularBufferStream(50)) { var cts = new CancellationTokenSource(); Task.Run(async() => { var i = 0; while (!cts.Token.IsCancellationRequested) { i++; cbs.WriteBytes(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }); if (i % 50 == 0) { Core.Log.InfoMedium("Write {0}", i); } await Task.Delay(1, cts.Token).ConfigureAwait(false); } }); Task.Run(async() => { var i = 0; var buffer = new byte[15]; while (!cts.Token.IsCancellationRequested) { i++; cbs.Read(buffer, 0, 7); if (i % 50 == 0) { Core.Log.InfoMedium("Read {0}", i); } await Task.Delay(1, cts.Token).ConfigureAwait(false); } }); Console.ReadLine(); cts.Cancel(); } Core.Log.WriteEmptyLine(); Core.Log.InfoBasic("Press Enter to Start SharedMemoryStream Test. Press Enter Again to finish the test."); Console.ReadLine(); using (var sharedms = new SharedMemoryStream("test", 2000)) { var cts = new CancellationTokenSource(); Task.Run(async() => { var i = 0; while (!cts.Token.IsCancellationRequested) { i++; sharedms.WriteBytes(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }); if (i % 50 == 0) { Core.Log.InfoMedium("Write {0}", i); } await Task.Delay(1, cts.Token).ConfigureAwait(false); } }); Task.Run(async() => { var i = 0; var buffer = new byte[15]; while (!cts.Token.IsCancellationRequested) { i++; sharedms.Read(buffer, 0, 7); if (i % 50 == 0) { Core.Log.InfoMedium("Read {0}", i); } await Task.Delay(1, cts.Token).ConfigureAwait(false); } }); Console.ReadLine(); } }
internal static void Complete(Watch watch) { watch.Duration = DateTime.Now.Subtract(watch.Start); Watches.Add(watch); }
private void SetSizeSelected(Watch.WatchSize size) { switch (size) { default: case Watch.WatchSize.Byte: SizeDropDown.SelectedIndex = 0; break; case Watch.WatchSize.Word: SizeDropDown.SelectedIndex = 1; break; case Watch.WatchSize.DWord: SizeDropDown.SelectedIndex = 2; break; } }
public WatchViewModel(Watch watch) { _watch = watch; }
public void Node_AttachedTThatHasParents_ShouldNotUnfreeze_UntilAllParentsUnfreeze_Test() { var model = CurrentDynamoModel; //create some numbers var numberNode1 = new DoubleInput(); numberNode1.Value = "1"; var numberNode2 = new DoubleInput(); numberNode2.Value = "2"; var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+")); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false)); //connect them up model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); //add a watch node var watchNode = new Watch() { X = 100, Y = 300 }; model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4); Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3); //check the value. AssertPreviewValue(addNode.GUID.ToString(), 3); //now freeze both the number nodes. numberNode1.IsFrozen = true; numberNode2.IsFrozen = true; //Number nodes in frozen and not executing state Assert.AreEqual(numberNode1.IsFrozen, true); Assert.AreEqual(numberNode2.IsFrozen, true); //change the value of number nodes numberNode1.Value = "3.0"; numberNode2.Value = "3.0"; //add node in frozen and can execute state Assert.AreEqual(addNode.IsFrozen, true); //addnode should not change the value. AssertPreviewValue(addNode.GUID.ToString(), 3); Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue),3); //unfreeze one of the number node numberNode1.IsFrozen = false; //Number nodes in frozen and not executing state Assert.AreEqual(numberNode1.IsFrozen, false); Assert.AreEqual(numberNode2.IsFrozen, true); //add node should still be in frozen and can execute state Assert.AreEqual(addNode.IsFrozen, true); //now unfreeze the other node. numberNode2.IsFrozen = false; Assert.AreEqual(numberNode2.IsFrozen, false); //now the add node should not be in frozen state Assert.AreEqual(addNode.IsFrozen, false); //addnode should change the value now. AssertPreviewValue(addNode.GUID.ToString(), 6); AssertPreviewValue(watchNode.GUID.ToString(), 6); }
/* * @see Flash.Tools.Debugger.Session#clearWatch(Flash.Tools.Debugger.Watch) */ public virtual Watch clearWatch(Watch watch) { Watch[] list = WatchList; Watch w = null; if (removeWatch(watch.ValueId, watch.MemberName)) { // now let's first check the size of the list, it // should now be one less if (m_manager.WatchpointCount < list.Length) { // ok we made a change. So let's compare list and see which // one went away Watch[] newList = WatchList; for (int i = 0; i < newList.Length; i++) { // where they differ is the missing one if (list[i] != newList[i]) { w = list[i]; break; } } // might be the last one... if (w == null) w = list[list.Length - 1]; } } return w; }
public void SetToAddresses(IEnumerable<long> addresses, MemoryDomain domain, Watch.WatchSize size) { DataSize = (int)size; SetDataSize(DataSize); var addrList = addresses.ToList(); if (addrList.Any()) { SetDomain(domain); SetHighlighted(addrList[0]); _secondaryHighlightedAddresses.Clear(); _secondaryHighlightedAddresses.AddRange(addrList.Where(addr => addr != addrList[0]).ToList()); ClearNibbles(); UpdateValues(); MemoryViewerBox.Refresh(); AddressLabel.Text = GenerateAddressString(); } }
static void Main(string[] args) { Console.Clear(); var testModel = new TestModel("Testcontent"); var watch = new Watch(); var binding = new Binding(testModel, nameof(TestModel.Text)); var timeBinding = new Binding(watch, nameof(watch.Time)); var dialog1 = new BindingWindow(binding, binding, binding, timeBinding); var dialog2 = new BindingDialog(testModel, nameof(TestModel.Text)); /* * _grid = new Grid(); * _grid.GridRowDefinitions.Add(new GridRowDefinition()); * _grid.GridRowDefinitions.Add(new GridRowDefinition()); * _grid.GridColDefinitions.Add(new GridColDefinition()); * _grid.GridColDefinitions.Add(new GridColDefinition()); * _grid.SetContentAt(0, 0, dialog1); * _grid.SetContentAt(0, 1, dialog2); */ _root = new Frame(); _root.Content = dialog1; _root.PropertyChanged += Grid_PropertyChanged; /* * var dialog = new MessageDialog($"Dies ist ein:{Environment.NewLine}Test.sadfsadfsafdsafdsafsafdasfdsafdsafdlkjlqwjrlwqjrljwqrl;wqjre;lqwjr;lwqjre;lwqjre;lwqjoicoeboiebrqwewqwqfewqefwqefwqfewqfwqfejl;j;lj;ljas;ofdijsa;ofdjw;oejowqeoweowoqiejqofeqe", 3, 3, 20, 6); * //var dialog = new MessageDialog($"Dies ist ein:{Environment.NewLine}Test."); * dialog.ZIndex = 1000; * dialog.HorizontalAnchor = HorizontalAnchors.Left; * dialog.VerticalAnchor = VerticalAnchors.Top; * * //root.Content = dialog; * * var topBar = new StatusBar("I am a top status bar!"); * var bottomBar = new StatusBar($"I am a two-line{Environment.NewLine}status bar :-O"); * bottomBar.VerticalAnchor = VerticalAnchors.Bottom; * * /* * var window = new Window * { * Top = 6, * Left = 3, * ContentWidth = 40, * ContentHeight = 5, * }; */ _renderer.Render(_root); //_renderer.Render(_grid); //_grid.PropertyChanged += Grid_PropertyChanged; //renderer.Render(new BaseControl[] { dialog, topBar, bottomBar }); testModel.Text = "new text"; dialog2.ZIndex = 10; Console.CursorVisible = false; Console.ReadKey(); Console.CursorVisible = true; Console.Clear(); }
/// <summary> /// Sets up the MainWindowViewModel /// </summary> public MainWindowViewModel() { _watch = new Watch(); _watch.UpdateTimeDelegate += UpdateTime; }
// Pick up the object and add it to the inventory or use it instantly void PickUp() { Debug.Log("Picking up " + item.name); // Use the item item.Use(); // If it is the weapon it is treated differently if (item is Weapon) { bool pickedUp = Inventory.instance.Add(item); AudioSource.PlayClipAtPoint(item.sound, transform.position, volumeSounds); // If the weapon was picked up then deactivate it if (pickedUp) { transform.position = new Vector3(-50f, 0f, 0f); // If gotItemTextGO isn't null then show in the screen the object gotten, if not then search for it GameObject gotItemTextGO = GameObject.FindGameObjectWithTag(Tags.GotItemText); if (gotItemTextGO != null) { gotItemText = gotItemTextGO.GetComponent <TextMeshProUGUI>(); gotItemText.text = string.Concat(item.name.ToString()); gotItemText.color = new Color(0, 1, 0, 1); StartCoroutine(DeactivateText(gotItemText)); } itemPickedUp = true; } return; } else { if (item is Potion) { // If gotItemTextGO isn't null then show in the screen the object gotten, if not then search for it GameObject gotItemTextGO = GameObject.FindGameObjectWithTag(Tags.GotItemText); if (gotItemTextGO != null) { gotItemText = gotItemTextGO.GetComponent <TextMeshProUGUI>(); Potion potion = (Potion)item; gotItemText.text = string.Concat("+", potion.percentageHealthToHeal.ToString(), "% HP"); gotItemText.color = new Color(0, 1, 0, 1); StartCoroutine(DeactivateText(gotItemText)); } } else { // If gotItemTextGO isn't null then show in the screen the object gotten, if not then search for it GameObject gotItemTextGO = GameObject.FindGameObjectWithTag(Tags.GotItemText); if (gotItemTextGO != null) { gotItemText = gotItemTextGO.GetComponent <TextMeshProUGUI>(); Watch watch = (Watch)item; gotItemText.text = string.Concat("+", watch.stopTime.ToString(), " s"); gotItemText.color = new Color(0, 1, 0, 1); StartCoroutine(DeactivateText(gotItemText)); } } } // Play the clip attached to the item AudioSource.PlayClipAtPoint(item.sound, transform.position, volumeSounds); itemPickedUp = true; transform.position = new Vector3(-50f, 0f, 0f); Destroy(gameObject, item.sound.length); }
public DotNetCoreWatcher(Watch watch, ConcurrentDictionary <Watch, Process> runningProcesses) : base(watch, runningProcesses) { }
private void DoDisplayTypeClick(Watch.DisplayType type) { if (_settings.Type != type && !string.IsNullOrEmpty(SpecificValueBox.Text)) { SpecificValueBox.Text = "0"; } SpecificValueBox.Type = _settings.Type = type; _searches.SetType(type); _dropdownDontfire = true; DisplayTypeDropdown.SelectedItem = Watch.DisplayTypeToString(type); _dropdownDontfire = false; SpecificValueBox.Type = type; WatchListView.Refresh(); }
public void Start() { Executions++; Watch.Start(); }
private void SetPreviousStype(Watch.PreviousType type) { _settings.PreviousType = type; _searches.SetPreviousType(type); }
//_____________________________________________________________ // //_____________________________________________________________ private void Watch_Tick(object sender, EventArgs e) { if (isFinish == true && state == 1) { try { CountDown.Stop(); Watch.Stop(); TimerWatch.Stop(); min = TimerWatch.Elapsed.Minutes; sec = TimerWatch.Elapsed.Seconds; milisec = TimerWatch.Elapsed.Milliseconds; this.lbWatch1.Text = min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000"); System.IO.File.WriteAllText("result\\" + textBox_name_team_1.Text + ".txt", "Team " + textBox_name_team_1.Text + ":\nCheck point " + check_point.ToString() + ": " + min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000")); UART.Write("F"); } catch { } this.lbCountDown.Text = "FINISH !!!"; frm.lbCountDown.Text = "FINISH !!!"; } if (isFinish == true && state == 2) { try { TimerWatch.Stop(); min = TimerWatch.Elapsed.Minutes; sec = TimerWatch.Elapsed.Seconds; milisec = TimerWatch.Elapsed.Milliseconds; this.lbWatch2.Text = min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000"); System.IO.File.WriteAllText("result\\" + textBox_name_team_1.Text + ".txt", "Team " + textBox_name_team_1.Text + ":\nCheck point " + check_point.ToString() + ": " + min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000")); } catch { } this.lbCountDown.Text = "PLAYER 1 FINISH !!!"; frm.lbCountDown.Text = "PLAYER 1 FINISH !!!"; } if (isFinish2 == true && state == 2) { try { TimerWatch2.Stop(); min = TimerWatch2.Elapsed.Minutes; sec = TimerWatch2.Elapsed.Seconds; milisec = TimerWatch2.Elapsed.Milliseconds; System.IO.File.WriteAllText("result\\" + textBox_name_team_2.Text + ".txt", "Team " + textBox_name_team_2.Text + ":\nCheck point " + check_point2.ToString() + ": " + min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000")); } catch { } this.lbCountDown.Text = "PLAYER 2 FINISH !!!"; frm.lbCountDown.Text = "PLAYER 2 FINISH !!!"; } if (isFinish2 == true && isFinish == true && state == 2) { try { Watch.Stop(); UART.Write("F"); } catch { } this.lbCountDown.Text = "FINISH !!!"; frm.lbCountDown.Text = "FINISH !!!"; } if (isFinish == false) { min = TimerWatch.Elapsed.Minutes; sec = TimerWatch.Elapsed.Seconds; milisec = TimerWatch.Elapsed.Milliseconds; this.lbWatch1.Text = min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000"); frm.lbWatch.Text = min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000"); } if (isFinish2 == false) { min = TimerWatch2.Elapsed.Minutes; sec = TimerWatch2.Elapsed.Seconds; milisec = TimerWatch2.Elapsed.Milliseconds; this.lbWatch2.Text = min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000"); frm.lbWatch.Text = min.ToString("00") + ":" + sec.ToString("00") + "." + milisec.ToString("000"); } }
private void SetSize(Watch.WatchSize size) { SpecificValueBox.ByteSize = _settings.Size = size; if (!string.IsNullOrEmpty(SpecificAddressBox.Text)) { SpecificAddressBox.Text = "0"; } if (!string.IsNullOrEmpty(SpecificValueBox.Text)) { SpecificValueBox.Text = "0"; } if (!Watch.AvailableTypes(size).Contains(_settings.Type)) { _settings.Type = Watch.AvailableTypes(size)[0]; } _dropdownDontfire = true; switch (size) { case Watch.WatchSize.Byte: SizeDropdown.SelectedIndex = 0; break; case Watch.WatchSize.Word: SizeDropdown.SelectedIndex = 1; break; case Watch.WatchSize.DWord: SizeDropdown.SelectedIndex = 2; break; } PopulateTypeDropDown(); _dropdownDontfire = false; SpecificValueBox.Type = _settings.Type; SetReboot(true); }
/// <summary> /// Starts the stop watch /// </summary> public virtual void Start() { StopTime = StartTime = 0; Watch.Start(); }
private async Task <List <TrendingWatch> > LoadAndFilterDataAsync(IEnumerable <DomainMostSignaledItem> pageData, DataQueryOptions filter) { // Preparing int? productId = null; WatchState? videoState = null; List <DataFilterRule> filters = filter.Filters.Where(f => f.Value != null).ToList(); foreach (DataFilterRule dataFilterRule in filters) { DataFilterRule f = dataFilterRule; if (string.Compare(f.Name, NameOfHelper.PropertyName <TrendingWatch>(x => x.Generator), StringComparison.OrdinalIgnoreCase) == 0 && f.Type == DataFilterTypes.Equal) { // by product id productId = Int32.Parse(f.Value.ToString()); } else if (string.Compare(f.Name, NameOfHelper.PropertyName <TrendingWatch>(x => x.State), StringComparison.OrdinalIgnoreCase) == 0 && f.Type == DataFilterTypes.Equal) { // by video state videoState = (WatchState)Enum.Parse(typeof(WatchState), f.Value.ToString()); } } // Loading List <DomainMostSignaledItem> items = pageData.ToList(); List <Watch> watches = await _watchProjectService.GetByIdsAsync(items.Select(i => i.ItemId).ToArray(), string.Empty); // Processing projects var filtered = new List <TrendingWatch>(); foreach (DomainMostSignaledItem i in items) { DomainMostSignaledItem item = i; Watch watch = watches.FirstOrDefault(w => w.Id == item.ItemId); // Display only existing & public videos if (watch == null || watch.Access != ProjectAccess.Public) { continue; } // filtering by product id if (productId.HasValue) { if (watch.Generator != productId.Value) { continue; } } // filterring by state if (videoState.HasValue) { if (watch.State != videoState.Value) { continue; } } TrendingWatch trendingWatch = _mapper.Map <Watch, TrendingWatch>(watch); trendingWatch.Version = item.Version; filtered.Add(trendingWatch); } return(filtered); }
public void AddWatch(Watch watch) { _watches.Add(watch); WatchListView.ItemCount = _watches.ItemCount; UpdateValues(); UpdateWatchCount(); Changes(); }
public void Run(List <string> argv) { string inFileString; int address; string label, opcode, arg0, arg1, arg2; int numLabels = 0; int num = 0; int addressField; List <Label> labelArray = new List <Label>(CommonUtil.MAXNUMLABELS); inFileString = argv[0]; ResultFile = argv[1]; Watch.Start(); using (StreamReader inFile = new StreamReader(inFileString)) { using (StreamWriter outFile = new StreamWriter(ResultFile)) { /* map symbols to addresses */ /* assume address start at 0 */ for (address = 0; ReadAndParse(inFile, out label, out opcode, out arg0, out arg1, out arg2); ++address) { /* check for illegal opcode */ if (!CommonUtil.Commands.ContainsValue(opcode)) { throw new MessageException("Unrecognized opcode '" + opcode + "' at address " + (address + 1)); } /* check register fields */ if (opcode == CommonUtil.Commands[Command.ADD] || opcode == CommonUtil.Commands[Command.NAND] || opcode == CommonUtil.Commands[Command.LW] || opcode == CommonUtil.Commands[Command.SW] || opcode == CommonUtil.Commands[Command.BEQ] || opcode == CommonUtil.Commands[Command.JALR] || opcode == CommonUtil.Commands[Command.MUL]) { TestRegArg(arg0); TestRegArg(arg1); } if (opcode == CommonUtil.Commands[Command.ADD] || opcode == CommonUtil.Commands[Command.NAND] || opcode == CommonUtil.Commands[Command.MUL]) { TestRegArg(arg2); } /* check addressField */ if (opcode == CommonUtil.Commands[Command.LW] || opcode == CommonUtil.Commands[Command.SW] || opcode == CommonUtil.Commands[Command.BEQ]) { TestAddrArg(arg2); } if (opcode == CommonUtil.Commands[Command.FILL]) { TestAddrArg(arg0); } /* check for enough arguments */ if ((opcode != CommonUtil.Commands[Command.HALT] && opcode != CommonUtil.Commands[Command.FILL] && opcode != CommonUtil.Commands[Command.JALR] && opcode != CommonUtil.Commands[Command.NOOP] && string.IsNullOrEmpty(arg2)) || (opcode == CommonUtil.Commands[Command.JALR] && string.IsNullOrEmpty(arg1)) || (opcode == CommonUtil.Commands[Command.FILL] && string.IsNullOrEmpty(arg0))) { throw new MessageException("Error at address " + (address + 1) + ": not enough arguments"); } if (!string.IsNullOrEmpty(label)) { /* check for labels that are too long */ if (label.Length >= CommonUtil.MAXLABELLENGTH) { throw new MessageException($"Label {label} is too long!(max length: {CommonUtil.MAXLABELLENGTH})"); } /* make sure label starts with letter */ if (!Regex.IsMatch(label, "[a-zA-Z]")) { throw new MessageException($"Label {label} doesn't start with letter!"); } /* make sure label consists of only letters and numbers */ if (!Regex.IsMatch(label, "[a-zA-Z0-9]")) { throw new MessageException($"Label {label} has character other that letters and numbers!"); } /* look for duplicate label */ Label lbl = labelArray.FirstOrDefault(l => l.label == label); if (lbl != null) { int index = lbl.Address; throw new MessageException($"Error: duplicate label {label} at address {index}"); } } /* see if there are too many labels */ if (numLabels >= CommonUtil.MAXNUMLABELS) { throw new MessageException($"Error: too many labels (label = {label})"); } labelArray.Add(new Label { label = label, Address = address }); } /* now do second pass (print machine code, with symbols filled in as addresses) */ inFile.DiscardBufferedData(); inFile.BaseStream.Seek(0, SeekOrigin.Begin); for (address = 0; ReadAndParse(inFile, out label, out opcode, out arg0, out arg1, out arg2); ++address) { if (opcode == CommonUtil.Commands[Command.ADD]) { num = ((int)Command.ADD << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16) | int.Parse(arg2); } else if (opcode == CommonUtil.Commands[Command.NAND]) { num = ((int)Command.NAND << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16) | int.Parse(arg2); } else if (opcode == CommonUtil.Commands[Command.JALR]) { num = ((int)Command.JALR << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16); } else if (opcode == CommonUtil.Commands[Command.HALT]) { num = (int)Command.HALT << 22; } else if (opcode == CommonUtil.Commands[Command.NOOP]) { num = (int)Command.NOOP << 22; } else if (opcode == CommonUtil.Commands[Command.MUL]) { num = ((int)Command.MUL << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16) | int.Parse(arg2); } else if (opcode == CommonUtil.Commands[Command.LW] || opcode == CommonUtil.Commands[Command.SW] || opcode == CommonUtil.Commands[Command.BEQ]) { /* if arg2 is symbolic, then translate into an address */ if (!IsNumber(arg2)) { addressField = TranslateSymbol(labelArray, arg2); if (opcode == CommonUtil.Commands[Command.BEQ]) { addressField = addressField - address - 1; } } else { addressField = int.Parse(arg2); } if (addressField < -32768 || addressField > 32767) { throw new MessageException($"Error: offset {addressField} out of range"); } addressField &= 0xFFFF; if (opcode == CommonUtil.Commands[Command.BEQ]) { num = ((int)Command.BEQ << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16) | addressField; } else { /* lw or sw */ if (opcode == CommonUtil.Commands[Command.LW]) { num = ((int)Command.LW << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16) | addressField; } else { num = ((int)Command.SW << 22) | (int.Parse(arg0) << 19) | (int.Parse(arg1) << 16) | addressField; } } } else if (opcode == (CommonUtil.Commands[Command.FILL])) { if (int.TryParse(arg0, out num)) { num = int.Parse(arg0); } else { num = TranslateSymbol(labelArray, arg0); } } outFile.WriteLine(num); } } } Watch.Stop(); }
public WatchEntry(Watch watch) { Watch = watch; }
private static void RawTest(MQPairConfig mqConfig) { using (var mqServer = mqConfig.GetRawServer()) { var byteRequest = new byte[] { 0x21, 0x22, 0x23, 0x24, 0x25, 0x30, 0x31, 0x32, 0x33, 0x34 }; var byteResponse = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x10, 0x11, 0x12, 0x13, 0x14 }; mqServer.RequestReceived += (s, e) => { e.Response = byteResponse; return(Task.CompletedTask); }; mqServer.StartListeners(); using (var mqClient = mqConfig.GetRawClient()) { var totalQ = 50000; #region Sync Mode Core.Log.Warning("RAW Sync Mode Test, using Unique Response Queue"); using (var w = Watch.Create($"Hello World Example in Sync Mode for {totalQ} times")) { for (var i = 0; i < totalQ; i++) { var response = mqClient.SendAndReceiveAsync(byteRequest).WaitAsync(); } Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion totalQ = 50000; #region Parallel Mode Core.Log.Warning("RAW Parallel Mode Test, using Unique Response Queue"); using (var w = Watch.Create($"Hello World Example in Parallel Mode for {totalQ} times")) { Task.WaitAll( Enumerable.Range(0, totalQ).Select((i, vTuple) => (Task)vTuple.mqClient.SendAndReceiveAsync(vTuple.byteRequest), (mqClient, byteRequest)).ToArray() ); //Parallel.For(0, totalQ, i => //{ // var response = mqClient.SendAndReceiveAsync(byteRequest).WaitAndResults(); //}); Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion } mqConfig.ResponseOptions.ClientReceiverOptions.Parameters["SingleResponseQueue"] = "false"; using (var mqClient = mqConfig.GetRawClient()) { var totalQ = 50000; #region Sync Mode Core.Log.Warning("RAW Sync Mode Test, using Multiple Response Queue"); using (var w = Watch.Create($"Hello World Example in Sync Mode for {totalQ} times")) { for (var i = 0; i < totalQ; i++) { var response = mqClient.SendAndReceiveAsync(byteRequest).WaitAndResults(); } Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion #region Parallel Mode Core.Log.Warning("RAW Parallel Mode Test, using Multiple Response Queue"); using (var w = Watch.Create($"Hello World Example in Parallel Mode for {totalQ} times")) { Task.WaitAll( Enumerable.Range(0, totalQ).Select((i, vTuple) => (Task)vTuple.mqClient.SendAndReceiveAsync(vTuple.byteRequest), (mqClient, byteRequest)).ToArray() ); //Parallel.For(0, totalQ, i => //{ // var response = mqClient.SendAndReceiveAsync(byteRequest).WaitAndResults(); //}); Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion } } }
protected override async Task OnHandlerAsync(ParameterHandlerInfo info) { var serializer = new NBinarySerializer(); var service = new SampleProvider(); Core.Log.InfoBasic("Setting RPC Server"); var rpcServer = new RPCServer(new DefaultTransportServer(20050, serializer)); rpcServer.AddService(typeof(ISampleProvider), service); await rpcServer.StartAsync().ConfigureAwait(false); Core.Log.InfoBasic("Setting RPC Client"); var rpcClient = new RPCClient(new DefaultTransportClient("127.0.0.1", 20050, 1, serializer)); var hClient = await rpcClient.CreateDynamicProxyAsync <ISampleProvider>().ConfigureAwait(false); var client = hClient.ActAs <ISampleProvider>(); double perItemMs; try { var intEnumerable = await client.GetInt().ConfigureAwait(false); } catch (Exception ex) { Core.Log.Write(ex); } using (var watch = Watch.Create("GetSampleAsync")) { Sample res; for (var i = 0; i < 100000; i++) { res = await client.GetSampleAsync().ConfigureAwait(false); } perItemMs = watch.GlobalElapsedMilliseconds / 100000; } Core.Log.InfoBasic($"GetSampleAsync per item: {perItemMs}ms"); Console.ReadLine(); Core.Log.InfoBasic("DelayTestAsync"); await client.DelayTestAsync().ConfigureAwait(false); Core.Log.InfoBasic("GetSample"); var sample = client.GetSample(); Core.Log.InfoBasic("GetSample as Async"); var sampleSimAsync = ((dynamic)hClient).GetSample2Async().Result; Console.ReadLine(); var pClient = await rpcClient.CreateProxyAsync <SampleProxy>().ConfigureAwait(false); using (var watch = Watch.Create("GetSampleAsync")) { Sample res; for (var i = 0; i < 100000; i++) { res = await pClient.GetSampleAsync().ConfigureAwait(false); } perItemMs = watch.GlobalElapsedMilliseconds / 100000; } Core.Log.InfoBasic($"GetSampleAsync per item: {perItemMs}ms"); Console.ReadLine(); Core.Log.InfoBasic("DelayTestAsync"); await pClient.DelayTestAsync().ConfigureAwait(false); Core.Log.InfoBasic("GetSample"); var sample2 = pClient.GetSample(); rpcClient.Dispose(); await rpcServer.StopAsync().ConfigureAwait(false); }
private void HardSetSizeDropDown(Watch.WatchSize size) { switch (size) { case Watch.WatchSize.Byte: SizeDropdown.SelectedIndex = 0; break; case Watch.WatchSize.Word: SizeDropdown.SelectedIndex = 1; break; case Watch.WatchSize.DWord: SizeDropdown.SelectedIndex = 2; break; } }
private static void NormalTest(MQPairConfig mqConfig) { using (var mqServer = mqConfig.GetServer()) { mqServer.RequestReceived += (s, e) => { //Core.Log.Warning("Waiting..."); //try //{ // await Task.Delay(int.MaxValue, e.ProcessResponseTimeoutCancellationToken); //} //catch { } //Core.Log.Warning("Cancelled."); //Core.Log.InfoBasic("Received"); e.Response.Body = new SerializedObject("Bienvenido!!!"); return(Task.CompletedTask); }; mqServer.StartListeners(); using (var mqClient = mqConfig.GetClient()) { var totalQ = 50000; #region Sync Mode Core.Log.Warning("Sync Mode Test, using Unique Response Queue"); using (var w = Watch.Create($"Hello World Example in Sync Mode for {totalQ} times")) { for (var i = 0; i < totalQ; i++) { var response = mqClient.SendAndReceiveAsync <string>("Hola mundo").WaitAsync(); } Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion totalQ = 50000; #region Parallel Mode Core.Log.Warning("Parallel Mode Test, using Unique Response Queue"); using (var w = Watch.Create($"Hello World Example in Parallel Mode for {totalQ} times")) { var oldContext = Core.ContextGroupName; Task.WaitAll( Enumerable.Range(0, totalQ).Select((i, mc) => { Core.ContextGroupName = "Message: " + i; return((Task)mc.SendAndReceiveAsync <string>("Hola mundo")); } , mqClient).ToArray()); Core.ContextGroupName = oldContext; //Parallel.For(0, totalQ, i => //{ // var response = mqClient.SendAndReceiveAsync<string>("Hola mundo").WaitAndResults(); //}); Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion } mqConfig.ResponseOptions.ClientReceiverOptions.Parameters["SingleResponseQueue"] = "false"; using (var mqClient = mqConfig.GetClient()) { var totalQ = 50000; #region Sync Mode Core.Log.Warning("Sync Mode Test, using Multiple Response Queue"); using (var w = Watch.Create($"Hello World Example in Sync Mode for {totalQ} times")) { for (var i = 0; i < totalQ; i++) { var response = mqClient.SendAndReceiveAsync <string>("Hola mundo").WaitAndResults(); } Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion #region Parallel Mode Core.Log.Warning("Parallel Mode Test, using Multiple Response Queue"); using (var w = Watch.Create($"Hello World Example in Parallel Mode for {totalQ} times")) { Task.WaitAll( Enumerable.Range(0, totalQ).Select((i, mc) => (Task)mc.SendAndReceiveAsync <string>("Hola mundo"), mqClient).ToArray() ); //Parallel.For(0, totalQ, i => //{ // var response = mqClient.SendAndReceiveAsync<string>("Hola mundo").WaitAndResults(); //}); Core.Log.InfoBasic("Total time: {0}", TimeSpan.FromMilliseconds(w.GlobalElapsedMilliseconds)); Core.Log.InfoBasic("Average time in ms: {0}. Press ENTER To Continue.", (w.GlobalElapsedMilliseconds / totalQ)); } Console.ReadLine(); #endregion } } }
public void Start() { Watch.Start(); }
/// <summary> /// Setup the session with a configuration Node. /// </summary> protected void OnConfigLoad(Configuration config) { _lock.Take(); // skip if no longer running if (!Running) { _lock.Release(); return; } // persist the config node Node node = config.Node; // setup updater watch _updater = new Watch(1000, true, Update, false); // number of crawlers to initialize with _crawlerCount = node.Default((ThreadHandle.HandleCount + 1) / 2, "Crawler_Count"); // url control parameters UrlControl.UrlBufferSize = node.Default(20, "Url_Buffer"); // parse control parameters ParseControl.HostNewScore = node.Default(50, "Host_New_Score"); ParseControl.HostParseScore = node.Default(-20, "Host_Parse_Score"); ParseControl.HostAttemptScore = node.Default(-40, "Host_Attempt_Score"); ParseControl.HostAssetScore = node.Default(10, "Host_Asset_Score"); ParseControl.HostMaxScore = node.Default(1000, "Host_Max_Score"); // crawler parameters CrawlerUrlBufferSize = node.Default(1000, "Url_Crawl_Buffer"); CrawlerByteBuffer = node.Default(4096, "Byte_Buffer"); CrawlerMaxBytes = (int)node.Default(Global.Kilobyte * 100, "Max_Bytes"); CrawlerMinBytes = (int)node.Default(Global.Kilobyte * 55, "Min_Bytes"); CrawlerMaxConnectTimeout = node.Default(5000, "Max_Connect_Timeout"); CrawlerMinConnectTimeout = node.Default(3000, "Min_Connect_Timeout"); CrawlerMaxProcessTimeout = node.Default(10000, "Max_Process_Timeout"); CrawlerMinProcessTimeout = node.Default(7000, "Min_Process_Timeout"); CrawlerMaxCookieCount = node.Default(8, "Max_Cookie_Count"); CrawlerMaxCookieSize = node.Default(3435, "Max_Cookie_Size"); // were any identities specified? if (node["Identities"].ArraySet) { // iterate the defined headers foreach (Node identityNode in node["Identities"].Array) { if (identityNode.DictionarySet) { // start the name value collection Identity identity = new Identity(true); // iterate the headers in the identity foreach (KeyValuePair <string, Node> entry in identityNode.Dictionary) { identity.Add(entry.Key, entry.Value.String); } } } } // have the url root files been set? if (node["Files"].ArraySet) { // yes, add the root file paths to the file extractor foreach (Node pathNode in node["Files"].Array) { if (!pathNode["Parsed"].Bool) { _lock.Release(); AddUrlFile(pathNode.String); _lock.Take(); } } } // run the task machine to start the session TaskMachine tm = new TaskMachine(); tm.AddOnDone(() => _updater.Run = true); tm.Add("Set up parse control", ParseControl.Start); tm.Add("Set up URL control", UrlControl.Start); #if INFO tm.OnTask = new ActionSet <string>(s => Log.Info(s)); #endif tm.Run(); config.Save(); _lock.Release(); Log.Debug("Crawler session configuration loaded."); }
public ProfilingResult Stop() { Watch.Stop(); return new ProfilingResult(DisplayName, new ProfilingTime(Watch)); }
private void SetTypeSelected(Watch.DisplayType type) { foreach (var item in DisplayTypeDropDown.Items) { if (item.ToString() == Watch.DisplayTypeToString(type)) { DisplayTypeDropDown.SelectedItem = item; return; } } }
public void InsertWatch(Watch watch) { _context.Watchs.Add(watch); }
public void Unfreeze_ParentNode_MakesATemporaryStateNode_SwitchBackToPreviousState_Test() { var model = CurrentDynamoModel; //create some numbers var numberNode1 = new DoubleInput(); numberNode1.Value = "1"; var numberNode2 = new DoubleInput(); numberNode2.Value = "2"; var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+")); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false)); //connect them up model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); //add a watch node var watchNode = new Watch() {X = 100, Y = 300}; model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4); Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3); //check the value AssertPreviewValue(addNode.GUID.ToString(), 3); //freeze add node addNode.IsFrozen = true; // the add node must be frozen and not executing state Assert.AreEqual(addNode.IsFrozen, true); //freeze number node. numberNode1.IsFrozen = true; // the number node must be frozen and not executing state Assert.AreEqual(numberNode1.IsFrozen, true); //change the value on number node 1 numberNode1.Value = "3.0"; // the add node must be frozen and in a temporary state Assert.AreEqual(addNode.IsFrozen, true); //check the value on add node. AssertPreviewValue(addNode.GUID.ToString(), 3); //now unfreeze number node. numberNode1.IsFrozen = false; //now number node is not frozen Assert.AreEqual(numberNode1.IsFrozen, false); //this causes the add node to switch back from temporary state //to frozen and not executing state Assert.AreEqual(addNode.IsFrozen, true); //check the value on add node. Add node is not executed in the run, // becuase the frozen nodes are removed from AST. So the value of add node // should be 0. But the cached value should be 3, which is from the previous execution. AssertPreviewValue(addNode.GUID.ToString(), 0); Assert.IsNotNull(addNode.CachedValue.Data); Assert.AreEqual(Convert.ToInt32(addNode.CachedValue.Data),3); Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue), 3); }
public void DeleteWatch(int watchID) { Watch watch = _context.Watchs.Find(watchID); _context.Watchs.Remove(watch); }
public void Undo_Freeze_OnParentNode_Test() { var model = CurrentDynamoModel; //create some numbers var numberNode1 = new DoubleInput(); numberNode1.Value = "1"; var numberNode2 = new DoubleInput(); numberNode2.Value = "2"; var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+")); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false)); //connect them up model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); //add a watch node var watchNode = new Watch() { X = 100, Y = 300 }; model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4); Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3); //check the value AssertPreviewValue(addNode.GUID.ToString(), 3); //Record for undo. model.ExecuteCommand( new DynCmd.UpdateModelValueCommand( Guid.Empty, numberNode1.GUID, "IsFrozen", numberNode1.IsFrozen.ToString())); numberNode1.IsFrozen = true; //Number nodes in frozen and not executing state Assert.AreEqual(numberNode1.IsFrozen, true); //add node in frozen and can execute state Assert.AreEqual(addNode.IsFrozen, true); //check the value AssertPreviewValue(addNode.GUID.ToString(), 3); Assert.AreEqual(Convert.ToInt32(watchNode.CachedValue), 3); //undo the freeze on numbernode1 model.CurrentWorkspace.Undo(); //Now change the value on number node1 numberNode1.Value = "3.0"; //now the first number node unfreeze mode. Assert.AreEqual(numberNode1.IsFrozen, false); //add node in normal state Assert.AreEqual(addNode.IsFrozen, false); //check the value AssertPreviewValue(addNode.GUID.ToString(), 5); AssertPreviewValue(watchNode.GUID.ToString(), 5); }
public void UpdateWatch(Watch watch) { _context.Entry(watch).State = EntityState.Modified; }
public void ParentNode_Freeze_Test() { var model = CurrentDynamoModel; //create some numbers var numberNode1 = new DoubleInput(); numberNode1.Value = "1"; var numberNode2 = new DoubleInput(); numberNode2.Value = "2"; var addNode = new DSFunction(model.LibraryServices.GetFunctionDescriptor("+")); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode1, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(numberNode2, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(addNode, 0, 0, true, false)); //connect them up model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode1.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(numberNode2.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 1, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); //add a watch node var watchNode = new Watch(); model.ExecuteCommand(new DynamoModel.CreateNodeCommand(watchNode, 0, 0, true, false)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(addNode.GUID, 0, PortType.Output, DynCmd.MakeConnectionCommand.Mode.Begin)); model.ExecuteCommand(new DynamoModel.MakeConnectionCommand(watchNode.GUID, 0, PortType.Input, DynCmd.MakeConnectionCommand.Mode.End)); Assert.AreEqual(model.CurrentWorkspace.Nodes.Count(), 4); Assert.AreEqual(model.CurrentWorkspace.Connectors.Count(), 3); //Check the value AssertPreviewValue(addNode.GUID.ToString(), 3); //Freeeze the numbernode1 and compute the Freeze state of other nodes. numberNode1.IsFrozen = true; //change the value of number node1. numberNode1.Value = "3.0"; // the number node must be frozen and not executing state Assert.AreEqual(numberNode1.IsFrozen, true); //the add node must be frozen and can execute state Assert.AreEqual(addNode.IsFrozen, true); //Since the nodes are frozen, the value of add node should not change. AssertPreviewValue(addNode.GUID.ToString(), 3); //check the watch node value AssertPreviewValue(watchNode.GUID.ToString(), 3); }
static void Main(string[] args) { Console.Title = $"HabBit[{GetVersion()}] ~ Processing Arguments..."; HandleArguments(args); UpdateTitle(); Watch.Restart(); if (Decompress(Game)) { Game.Disassemble(); Revision = Game.GetClientRevision(); UpdateTitle(); Console.Title += (", Revision: " + Revision); if (!FileDirectory.EndsWith(Revision)) { FileDirectory += ("\\" + Revision); Directory.CreateDirectory(FileDirectory); } string headerDump = string.Empty; if (IsDumpingHeaders) { WriteLine($"Generating unique hashes for Outgoing({Game.OutgoingMessages.Count})/Incoming({Game.IncomingMessages.Count}) messages..."); headerDump += DumpHeaders(Game, true); headerDump += "\r\n\r\n"; headerDump += DumpHeaders(Game, false); WriteLine($"Unique Message Hashes Generated: Outgoing[{UniqueOutMessageHashCount}], Incoming[{UniqueInMessageHashCount}]"); if (IsUpdatingHeaders) { WriteLine("Replacing previous Outgoing/Incoming headers with hashes..."); PreviousGame.Decompress(); PreviousGame.Disassemble(); string fileHeader = $"//Current: {Game.GetClientRevision()}\r\n//Previous: {PreviousGame.GetClientRevision()}\r\n"; OutgoingHeaders = (fileHeader + UpdateHeaders( OutgoingHeadersPath, Game, PreviousGame, true)); IncomingHeaders = (fileHeader + UpdateHeaders( IncomingHeadersPath, Game, PreviousGame, false)); } } Game.BypassOriginCheck(); Game.BypassRemoteHostCheck(); Game.ReplaceRSAKeys(Exponent, Modulus); WriteLine("Assembling..."); Game.Assemble(); byte[] reconstructed = (IsCompressingClient ? Compress(Game) : Game.ToByteArray()); Watch.Stop(); WriteLine($"Finished! | Completion Time: {Watch.Elapsed:s\\.ff} Seconds"); string clientPath = $"{FileDirectory}\\Habbo.swf"; File.WriteAllBytes(clientPath, reconstructed); string rsaKeysPath = $"{FileDirectory}\\RSAKeys.txt"; File.WriteAllText(rsaKeysPath, string.Format( "Exponent(e): {0:x}\r\nModulus(n): {1}\r\nPrivate Exponent(d): {2}", Exponent, Modulus, PrivateExponent)); Console.WriteLine("Client: " + clientPath); Console.WriteLine("RSA Keys: " + rsaKeysPath); if (!string.IsNullOrWhiteSpace(headerDump)) { string headersPath = $"{FileDirectory}\\Headers.txt"; File.WriteAllText(headersPath, headerDump); Console.WriteLine("Headers: " + headersPath); if (IsUpdatingHeaders) { string inPath = $"{FileDirectory}\\{Path.GetFileName(IncomingHeadersPath)}"; string outPath = $"{FileDirectory}\\{Path.GetFileName(OutgoingHeadersPath)}"; File.WriteAllText(outPath, OutgoingHeaders); Console.WriteLine("Client Outgoing Headers: " + outPath); File.WriteAllText(inPath, IncomingHeaders); Console.WriteLine("Client Incoming Headers: " + inPath); } } WriteLine(); } else { WriteLine($"File decompression failed! | {Game.Compression}"); } Console.CursorVisible = true; Console.ReadKey(true); }
public Watch SetWatch(string expression) { Watch result; _watches.Add(result = new Watch() { Debugger = this, Expression = expression }); return result; }
public override void RemoveLine(Watch product) { base.RemoveLine(product); Session.SetJson("Cart", this); }