public void test_MCU_Time_Estimate() { int vel = 170_000, dist = 10_000_000; int time = MCUManager.EstimateMovementTime(vel, dist); Assert.AreEqual(61800, time); }
public int RelativeMovementETA(Orientation movingBy) { // distance is degrees to steps for az/el // time is in milliseconds int EL_Speed = ConversionHelper.DPSToSPS(ConversionHelper.RPMToDPS(0.6), MotorConstants.GEARING_RATIO_ELEVATION); int AZ_Speed = ConversionHelper.DPSToSPS(ConversionHelper.RPMToDPS(0.6), MotorConstants.GEARING_RATIO_AZIMUTH); int positionTranslationAZ = ConversionHelper.DegreesToSteps(movingBy.Azimuth, MotorConstants.GEARING_RATIO_AZIMUTH); int positionTranslationEL = ConversionHelper.DegreesToSteps(movingBy.Elevation, MotorConstants.GEARING_RATIO_ELEVATION); int timeToMoveEl = MCUManager.EstimateMovementTime(EL_Speed, positionTranslationEL); int timeToMoveAz = MCUManager.EstimateMovementTime(AZ_Speed, positionTranslationAZ); // return the greater of the two times (we have to wait for longest mvmt) int timeToMove = timeToMoveEl > timeToMoveAz ? timeToMoveEl : timeToMoveAz; return(timeToMove); }
/// <summary> /// starts a modbus server to comunicate with the PLC on PLC_port and local_ip /// then sets up a modbus client to comunicate with the MCU located at MCU_ip, MCU_port (192.168.0.50 , 502) for actual hardware /// </summary> /// <param name="local_ip"></param> /// <param name="MCU_ip"></param> /// <param name="MCU_port"></param> /// <param name="PLC_port"></param> public ProductionPLCDriver(string local_ip, string MCU_ip, int MCU_port, int PLC_port) : base(local_ip, MCU_ip, MCU_port, PLC_port) { limitSwitchData = new Simulators.Hardware.LimitSwitchData(); homeSensorData = new Simulators.Hardware.HomeSensorData(); pLCEvents = new PLCEvents(); MCU = new MCUManager(MCU_ip, MCU_port); try { PLCTCPListener = new TcpListener(new IPEndPoint(IPAddress.Parse(local_ip), PLC_port)); ClientManagmentThread = new Thread(new ThreadStart(HandleClientManagementThread)) { Name = "PLC server Thread" }; } catch (Exception e) { if ((e is ArgumentNullException) || (e is ArgumentOutOfRangeException)) { logger.Info(Utilities.GetTimeStamp() + ": [AbstractPLCDriver] ERROR: failure creating PLC TCP server or management thread: " + e.ToString()); return; } else { throw e; } // Unexpected exception } try { PLCTCPListener.Start(1); } catch (Exception e) { if ((e is SocketException) || (e is ArgumentOutOfRangeException) || (e is InvalidOperationException)) { logger.Info(Utilities.GetTimeStamp() + ": [AbstractPLCDriver] ERROR: failure starting PLC TCP server: " + e.ToString()); return; } } }