public void MmToTicks_Minimal_WithFlip() { int inMm = MIN_STOPPER_COORD_MM; int expected = _testAsset.TicksPerRod - Communication.SAFETY_TICKS_BUFFER; int actual = _testAsset.MmToTicks(inMm, true); Assert.AreEqual(expected, actual); }
/// <summary> /// Main Flow for communication unit /// </summary> public override void Job() { try { if (!_isInitialized) { throw new InitializationException(String.Format( "[{0}] Instance was not initialized. Must call initialization method before used!", this.GetType().DeclaringType)); } //we don't wan't to receive new data while not finished with old one _publisher.Detach(this); //received command RodAction action = _publisher.Data; //Log.Common.Debug(String.Format("[{0}] New action received for {1} Rotational: {2} Linear: {3}: Coordinate: {4} mm", // MethodBase.GetCurrentMethod().Name, action.RodType.ToString(), action.Rotation.ToString(), // action.Linear.ToString(), action.DcCoordinate)); //Convert mm to ticks int proportinalMove = _converter.MmToTicks(action.DcCoordinate); //Invoke the arduino _arduino.Move(proportinalMove, action.Rotation); } catch (Exception ex) { if (ex is ThreadInterruptedException) { /* Got new data */ } else if (ex is InitializationException) { throw ex; } else { Log.Print(String.Format("Error occurred! Reason: [{0}]", ex.Message), eCategory.Error, LogTag.COMMUNICATION); } } finally { _publisher.Attach(this); } }