private string GetLinkState(ThreadLink link) { String state = ""; if (!link.Started) { state = "Initialisé"; } else if (link.Ended) { state = "Terminé"; } else if (link.Cancelled) { state = "Annulé"; } else if (link.LoopPaused) { state = "En pause"; } else { state = "En cours d'execution"; } return(state); }
private ColorPlus GetLinkColor(ThreadLink link) { ColorPlus color; if (!link.Started) { color = ColorPlus.GetVeryLight(Color.Purple); } else if (link.Ended) { color = Color.LightGray; } else if (link.Cancelled) { color = ColorPlus.GetVeryLight(Color.Red); } else if (link.LoopPaused) { color = ColorPlus.GetVeryLight(Color.Orange); } else { color = ColorPlus.GetVeryLight(Color.Green); } return(color); }
protected async Task <IBoardPostCollection> ReadThread(string resourceFile, ThreadLink link = null, int?firstPosts = null) { var jsonStr = await TestResources.ReadTestTextFile(resourceFile); var dto = JsonConvert.DeserializeObject <BoardEntity2>(jsonStr); if (firstPosts != null) { dto.Threads[0].Posts = dto.Threads[0].Posts.Take(firstPosts.Value).ToArray(); } Assert.IsNotNull(dto, "dto != null"); var parser = _provider.FindNetworkDtoParser <ThreadData, IBoardPostCollectionEtag>(); Assert.IsNotNull(parser, "parser != null"); var param = new ThreadData() { Link = link ?? new ThreadLink() { Board = "mobi", Engine = MakabaConstants.MakabaEngineId, OpPostNum = 1153568 }, Etag = "##etag##", LoadedTime = DateTimeOffset.Now, Entity = dto }; var collection = parser.Parse(param); return(collection); }
private void TestAsser(ThreadLink link) { link.RegisterName(); Robots.MainRobot.MoveForward(2000); Robots.MainRobot.PivotRight(270); Robots.MainRobot.MoveForward(200); Robots.MainRobot.PivotRight(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.PivotRight(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.PivotRight(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.MoveBackward(1000); Robots.MainRobot.PivotLeft(90); Robots.MainRobot.MoveBackward(500); Robots.MainRobot.PivotLeft(10); Robots.MainRobot.MoveForward(1000); Robots.MainRobot.PivotLeft(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.PivotLeft(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.PivotLeft(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.PivotLeft(10); Robots.MainRobot.MoveForward(100); Robots.MainRobot.GoToPosition(Recalibration.StartPosition); Robots.MainRobot.MoveBackward(300); }
private void btnAffichage_Click(object sender, EventArgs e) { if (btnAffichage.Text == "Lancer l'affichage") { _linkDisplay = ThreadManager.CreateThread(link => DisplayInfos()); _linkDisplay.Name = "Affichage des données"; _linkDisplay.StartInfiniteLoop(new TimeSpan(0, 0, 0, 0, 100)); Dessinateur.Start(); btnAffichage.Text = "Stopper l'affichage"; btnAffichage.Image = GoBot.Properties.Resources.Pause16; } else { _linkDisplay?.Cancel(); _linkDisplay?.WaitEnd(); _linkDisplay = null; Dessinateur.Stop(); btnAffichage.Text = "Lancer l'affichage"; btnAffichage.Image = GoBot.Properties.Resources.Play16; } }
private void btnLaunch_Click(object sender, EventArgs e) { if (_linkPolling == null) { btnLaunch.Text = "Stopper"; btnLaunch.Image = Properties.Resources.Pause16; _linkPolling = ThreadManager.CreateThread(link => Measure()); _linkPolling.StartInfiniteLoop(new TimeSpan(0)); _linkDrawing = ThreadManager.CreateThread(link => DrawMeasures()); _linkDrawing.StartInfiniteLoop(new TimeSpan(0, 0, 0, 0, 50)); } else { btnLaunch.Text = "Lancer"; btnLaunch.Image = Properties.Resources.Play16; _linkPolling.Cancel(); _linkDrawing.Cancel(); _linkPolling.WaitEnd(); _linkDrawing.WaitEnd(); _linkPolling = null; _linkDrawing = null; } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == Keys.Down) { _moveVertical = -1; } else if (keyData == Keys.Up) { _moveVertical = 1; } else if (keyData == Keys.Left) { _moveHorizontal = -1; } else if (keyData == Keys.Right) { _moveHorizontal = 1; } if ((_moveVertical != 0 || _moveHorizontal != 0) && _moveLoop == null) { _moveLoop = ThreadManager.CreateThread(o => ZoomStep()); _moveLoop.StartInfiniteLoop(20); } return(base.ProcessCmdKey(ref msg, keyData)); }
private void btnLateral_Click(object sender, EventArgs e) { _isOnLeft = !_isOnLeft; if (_linkAnimation != null) { _linkAnimation.Cancel(); _linkAnimation.WaitEnd(); } if (!_isOnLeft) { Actionneur.ElevatorRight.DoPushInside(); btnLateral.Image = Properties.Resources.BigArrow; } else { Actionneur.ElevatorRight.DoPushOutside(); Bitmap bmp = new Bitmap(Properties.Resources.BigArrow); bmp.RotateFlip(RotateFlipType.RotateNoneFlipX); btnLateral.Image = bmp; } _linkAnimation = ThreadManager.CreateThread(link => ThreadLateral(!_isOnLeft ? -4 : 4)); _linkAnimation.StartInfiniteLoop(15); picStorage.Focus(); }
private void ScoreAnimation(ThreadLink link) { link.RegisterName(); double progress = 0; int startYScore = 600; int endYScore = 241; int startYSlogan = 507; int endYSlogan = startYSlogan + (startYScore - endYScore); int startYSubSlogan = 555; int endYSubSlogan = startYSubSlogan + (startYScore - endYScore); int startYLogo = 301; int endYLogo = startYLogo + (startYScore - endYScore); int animDuration = 1000; int fps = 30; do { progress += 1f / fps; progress = Math.Min(1, progress); this.InvokeAuto(() => { Font f = new Font(lblScore.Font.Name, (float)(172 - (172 - 124) * Math.Max(0, (progress - 0.5) * 2))); lblScore.Font = f; pnlDetails.Location = new Point(pnlDetails.Left, (int)(startYScore - progress * (startYScore - endYScore))); lblSlogan.Location = new Point(lblSlogan.Left, (int)(startYSlogan - progress * (startYSlogan - endYSlogan))); lblSubSlogan.Location = new Point(lblSubSlogan.Left, (int)(startYSubSlogan - progress * (startYSubSlogan - endYSubSlogan))); }); Thread.Sleep(animDuration / fps); } while (progress < 1); }
public static void Start() { PositionCurseur = new RealPoint(); _linkDisplay = ThreadManager.CreateThread(link => DisplayLoop()); _linkDisplay.Name = "Affichage de la table"; _linkDisplay.StartThread(); }
private void FormConfirm_Shown(object sender, EventArgs e) { btnTrap.Focus(); _countdown = 3; btnStay.Text = "Rester (" + _countdown + ")"; _link = ThreadManager.CreateThread(link => Countdown()); _link.StartLoop(1000, _countdown + 2); }
public CanServo(ServomoteurID id, iCanSpeakable communication) { _id = (ServomoteurID)((int)id % 100); _communication = communication; _lockResponse = new Semaphore(0, int.MaxValue); _enableAutoCut = false; _nextDisable = null; }
protected override bool StartLoop() { _linkMeasures = ThreadManager.CreateThread(link => DoMeasure()); _linkMeasures.Name = "Mesure Hokuyo " + _id.ToString(); _linkMeasures.StartInfiniteLoop(new TimeSpan(0, 0, 0, 0, 100)); return(true); }
public ExtendedPostingViewModel(IShell shell, IBoard board, PostInfo postInfo, ThreadLink threadLink) { PostInfo = postInfo; Shell = shell; Board = board; BoardId = threadLink.BoardId; Parent = threadLink.ThreadNumber; SetupProperties(); }
private void ThreadTrajectory(ThreadLink link) { link.RegisterName(); this.InvokeAuto(() => btnPathRPCentre.Enabled = false); Robots.MainRobot.GoToPosition(new Position(positionArrivee.Angle.InDegrees, positionArrivee.Coordinates)); this.InvokeAuto(() => btnPathRPCentre.Enabled = true); }
protected override void StopLoop() { if (_feedLink != null) { _manager.CloseChannelUDP(); _feedLink.Cancel(); _feedLink.WaitEnd(); _feedLink = null; } }
public override async Task<Thread> LoadThreadAsync(ThreadLink link, int startPosition = 0) { var uri = UrlService.GetThreadUrl(link.BoardId, link.ThreadNumber, startPosition); var json = await Get(uri); var posts = DeserializeJson<IList<PostEntity>>(json); var threadEntity = new ThreadEntity { Posts = posts }; return Mapper.MapThread(threadEntity, link); }
private void DoFingersGrab() { ThreadLink left = ThreadManager.CreateThread(link => Actionneur.FingerLeft.DoGrabColor(Buoy.Red)); ThreadLink right = ThreadManager.CreateThread(link => Actionneur.FingerRight.DoGrabColor(Buoy.Green)); left.StartThread(); right.StartThread(); left.WaitEnd(); right.WaitEnd(); }
private void DoElevatorsDropoff(int level) { Color colorLeft = Color.Transparent, colorRight = Color.Transparent; bool okColorLeft, okColorRight; ThreadLink left = ThreadManager.CreateThread(link => colorLeft = Actionneur.ElevatorLeft.DoSequenceDropOff()); ThreadLink right = ThreadManager.CreateThread(link => colorRight = Actionneur.ElevatorRight.DoSequenceDropOff()); while (_zone.LoadsOnGreen < 4 && _zone.LoadsOnRed < 4 && Actionneur.ElevatorLeft.CountTotal > 0 && Actionneur.ElevatorRight.CountTotal > 0) { left.StartThread(); right.StartThread(); left.WaitEnd(); right.WaitEnd(); if (colorLeft != Color.Transparent) { _zone.SetBuoyOnRed(colorLeft, level); okColorLeft = (colorLeft == Buoy.Red); GameBoard.Score += (1 + (okColorLeft ? 1 : 0)); } else { okColorLeft = false; } if (colorRight != Color.Transparent) { _zone.SetBuoyOnGreen(colorRight, level); okColorRight = (colorRight == Buoy.Green); GameBoard.Score += (1 + (okColorRight ? 1 : 0)); } else { okColorRight = false; } if (okColorLeft && okColorRight) { GameBoard.Score += 2; } level++; Robot.Move(-85); } // Pour ranger à la fin : Actionneur.ElevatorLeft.DoPushInsideFast(); Actionneur.ElevatorRight.DoPushInsideFast(); }
public void AsyncAsserEnable(ThreadLink link) { link.RegisterName(); //TODO2020AllDevices.RecGoBot.Buzz(7000, 200); Thread.Sleep(500); TrajectoryFailed = true; Stop(StopMode.Abrupt); _lockFrame[UdpFrameFunction.FinDeplacement]?.Release(); //TODO2020AllDevices.RecGoBot.Buzz(0, 200); }
private void btnUp_Click(object sender, EventArgs e) { if (_linkAnimation != null) { _linkAnimation.Cancel(); _linkAnimation.WaitEnd(); } _linkAnimation = ThreadManager.CreateThread(link => ThreadVertical(4)); _linkAnimation.StartInfiniteLoop(10); picStorage.Focus(); }
private void switchBouton_ValueChanged(object sender, bool value) { if (value) { trackBar.Min = _currentPositionnable.Minimum; trackBar.Max = _currentPositionnable.Maximum; _linkPolling = ThreadManager.CreateThread(link => PollingLoop()); _linkPolling.StartThread(); } else { _linkPolling.Cancel(); } }
private void btnFingerRight_Click(object sender, EventArgs e) { if (_linkFingerRight == null) { _linkFingerRight = Threading.ThreadManager.CreateThread(link => Actionneurs.Actionneur.FingerRight.DoDemoGrab(link)); _linkFingerRight.StartThread(); } else { _linkFingerRight.Cancel(); _linkFingerRight.WaitEnd(); _linkFingerRight = null; } }
/// <summary> /// Execute le match /// </summary> public void ExecuteMatch() { Robots.MainRobot.Historique.Log("DEBUT DU MATCH", TypeLog.Strat); StartingDateTime = DateTime.Now; GameBoard.StartMatch(); endMatchTimer = new System.Timers.Timer(); endMatchTimer.Elapsed += new ElapsedEventHandler(endMatchTimer_Elapsed); endMatchTimer.Interval = MatchDuration.TotalMilliseconds; endMatchTimer.Start(); _linkMatch = ThreadManager.CreateThread(link => Execute()); _linkMatch.StartThread(); }
private void btnColorLeft_ValueChanged(object sender, bool value) { if (value) { Robots.MainRobot.SetActuatorOnOffValue(ActuatorOnOffID.PowerSensorColorBuoyLeft, true); Robots.MainRobot.SensorColorChanged += GrosRobot_SensorColorChanged; ThreadManager.CreateThread(link => PollingColorLeft(link)).StartInfiniteLoop(50); } else { Robots.MainRobot.SetActuatorOnOffValue(ActuatorOnOffID.PowerSensorColorBuoyLeft, false); _linkColorLeft.Cancel(); _linkColorLeft.WaitEnd(); _linkColorLeft = null; } }
private void switchButtonPort_ValueChanged(object sender, bool value) { if ((switchButtonPortA.Value || switchButtonPortB.Value || switchButtonPortC.Value) && _link == null) { _link = ThreadManager.CreateThread(link => AskValues()); _link.Name = "Ports numériques " + _board.ToString(); _link.StartInfiniteLoop(50); } if (!switchButtonPortA.Value & !switchButtonPortB.Value & !switchButtonPortC.Value & _link != null) { _link.Cancel(); _link.WaitEnd(); _link = null; } }
public RobotSimu(IDRobot idRobot) : base(idRobot, "Robot Simu") { _highResolutionAsservissement = true; _rand = new Random(); _linkAsserv = ThreadManager.CreateThread(link => Asservissement()); _linkLogPositions = ThreadManager.CreateThread(link => LogPosition()); _lockMove = new Semaphore(1, 1); _sensMove = SensAR.Avant; _inRecalibration = false; _asserChrono = null; _currentPolarPoint = -1; BatterieVoltage = 25; }
private void btnOnOff_ValueChanged(object sender, bool value) { if (value) { ledState.Color = Robots.MainRobot.ReadSensorOnOff(_sensor) ? Color.LimeGreen : Color.Red; _linkPolling = ThreadManager.CreateThread(link => PollingSensor()); _linkPolling.RegisterName(nameof(PollingSensor) + " " + lblName.Text); _linkPolling.StartInfiniteLoop(50); } else { _linkPolling.Cancel(); _linkPolling.WaitEnd(); _linkPolling = null; ledState.Color = Color.Gray; } }
private void PollingLoop() { double posValue; double ticksCurrent, ticksMin, ticksRange; int pointsParTour = 4096; double toursRange = 5; _linkPolling.RegisterName(); ticksCurrent = 0;//TODO2020 AllDevices.RecGoBot.GetCodeurPosition(); ticksMin = ticksCurrent; ticksRange = pointsParTour * toursRange; posValue = _currentPositionnable.Minimum; while (!_linkPolling.Cancelled) { lock (this) { _linkPolling.LoopsCount++; toursRange = trackBarSpeed.Value; ticksRange = pointsParTour * toursRange; Thread.Sleep(50); ticksCurrent = 0;//TODO2020 AllDevices.RecGoBot.GetCodeurPosition(); if (ticksCurrent > ticksMin + ticksRange) { ticksMin = ticksCurrent - ticksRange; } else if (ticksCurrent < ticksMin) { ticksMin = ticksCurrent; } posValue = (ticksCurrent - ticksMin) / ticksRange * (_currentPositionnable.Maximum - _currentPositionnable.Minimum) + _currentPositionnable.Minimum; posValue = Math.Min(posValue, _currentPositionnable.Maximum); posValue = Math.Max(posValue, _currentPositionnable.Minimum); } SetPosition((int)posValue); } _linkPolling = null; }
private void MainForm_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) { _moveVertical = 0; } else if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right) { _moveHorizontal = 0; } if (_moveVertical == 0 && _moveHorizontal == 0 && _moveLoop != null) { _moveLoop.Cancel(); _moveLoop.WaitEnd(); _moveLoop = null; } }
protected override bool StartLoop() { bool ok; if (_manager.CreateChannelUDP()) { _feedLink = ThreadManager.CreateThread(link => FeedWatchDog()); _feedLink.Name = "R2000 Watchdog"; _feedLink.StartInfiniteLoop(1000); ok = true; } else { ok = false; } return(ok); }
private void boxTorque_ValueChanged(object sender, bool value) { if (value) { _linkPolling = ThreadManager.CreateThread(link => GetServoInfos()); _linkPolling.StartInfiniteLoop(new TimeSpan(0, 0, 0, 0, 20)); _linkDrawing = ThreadManager.CreateThread(link => DrawTorqueCurve()); _linkDrawing.StartInfiniteLoop(new TimeSpan(0, 0, 0, 0, 100)); } else { _linkPolling.Cancel(); _linkDrawing.Cancel(); _linkPolling.WaitEnd(); _linkDrawing.WaitEnd(); _linkPolling = null; _linkDrawing = null; } }
public NavigateToThreadEventArgs(ThreadLink link) { Link = link; }