示例#1
0
 public Avionics(ushort[] registers, int yawAddr, int pitchAddr, int rollAddr, int depthAddr)
 {
     Yaw   = new ROVInput(registers, yawAddr, -Math.PI, Math.PI);
     Pitch = new ROVInput(registers, pitchAddr, -Math.PI, Math.PI);
     Roll  = new ROVInput(registers, rollAddr, -Math.PI, Math.PI);
     Depth = new ROVInput(registers, depthAddr, 0, 25);
 }
示例#2
0
        public ROV(string portName, int baudRate, int updateInterval)
        {
            //connect to ROV computer
            try
            {
                serialPort = new SerialPort(portName, baudRate, Parity.None, 8, StopBits.One);
                serialPort.Open();
                modbus      = ModbusSerialMaster.CreateRtu(serialPort);
                isConnected = true;
            } catch (Exception e)
            {
                throw new Exception("Failed to start communication: " + e.Message);
            }

            registers = new ushort[29];
            for (int i = 0; i < 29; i++)
            {
                //set all to max value to indicate not operational
                registers[i] = 0;
            }

            //set up thrusters, avionics, manipulator objects with
            //specific indices in register array
            Thrusters = new Thruster[6];
            for (int i = 0; i < 6; i++)
            {
                Thrusters[i] = new Thruster(registers, i, 16 + i, 22 + i);
            }

            Avionics = new Avionics(registers, 6, 7, 8, 9);

            Manipulators = new ROVOutput[4];
            for (int i = 0; i < 4; i++)
            {
                Manipulators[i] = new ROVOutput(registers, 10 + i, -255, 255);
            }

            Relays = new ROVOutput(registers, 14, UInt16.MinValue, UInt16.MaxValue);

            Voltmeter = new ROVInput(registers, 15, 0, 30);

            //every x milliseconds send/receive data with ROV
            timer           = new Timer(updateInterval);
            timer.AutoReset = true;
            timer.Elapsed  += CommunicationTimerElapsed;
            timer.Start();
            loopCounter = 0;
        }
示例#3
0
 public Thruster(ushort[] registers, int speedAddr, int rpmAddr, int tempAddr)
 {
     Speed       = new ROVOutput(registers, speedAddr, Int16.MinValue, Int16.MaxValue);
     Tachometer  = new ROVInput(registers, rpmAddr, UInt16.MinValue, UInt16.MaxValue);
     Thermometer = new ROVInput(registers, tempAddr, 0, 100);
 }