コード例 #1
0
        /// <summary>
        /// Receives data from the TRobot's Sharp sensors. Range for Sharp sensor is (200 - 1500 mm).
        /// </summary>
        /// <returns>Distance in mm from the TRobot's Sharp sensors. The key for measured distance is "distance1", "distance2", "distance3" for three Sharp sensors.</returns>
        public Data ReceiveData()
        {
            Data data = new Data();
            data.SelectedDeviceType = SelectedDevice.Sharp;
            try
            {
                String[] distances = arduino.GetSharpsData();

                for (int i = 1; i <= distances.Length; i++)
                {
                    Int16 hexToDecimal = Convert.ToInt16(distances[i - 1], 16);
                    double distance = (60.495 * Math.Pow(hexToDecimal * 0.0049, -1.1904) * 10);

                    if (distance >= 200 && distance <= 1500)
                    {
                        data.Dictionary.Add(key + i, distance);
                    }
                    else
                    {
                        data.Dictionary.Add(key + i, 0);
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
            return data;
        }
コード例 #2
0
        /// <summary>
        /// Receives data from the TRobot's batteries.
        /// </summary>
        /// <returns>Charge of Trobot's batteries in percents. The key for charge value is "charge".</returns>
        public Data ReceiveData()
        {
            Data data = new Data();
            data.SelectedDeviceType = SelectedDevice.Battery;
            try
            {
                String response = roboteQ.GetBatteryVoltage();

                int chargeInPercets = (int)(Double.Parse(response)-uMin)*100/(uMax-uMin);
                if (chargeInPercets < 0)
                {
                    data.Dictionary.Add(key, 0);
                }
                else if (chargeInPercets > 100)
                {
                    data.Dictionary.Add(key, 100);
                }
                else
                {
                    data.Dictionary.Add(key, chargeInPercets);
                }
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
            return data;
        }
コード例 #3
0
        public Data ReceiveData()
        {
            Data response = new Data();
            response.SelectedDeviceType = SelectedDevice.Null;

            return response;
        }
コード例 #4
0
ファイル: Service1.cs プロジェクト: mgorski-zlatan/TRobotWCF
        /// <summary>
        /// Loads data for selected device.
        /// </summary>
        /// <param name="request">Request with selected device type.</param>
        /// <returns>Data with received values for selected device type.</returns>
        public Data LoadData(Data request)
        {
            IDataReceiver dataReceiver = dataReceiverFactory.GetDataReceiver(request.SelectedDeviceType);

            Data response = dataReceiver.ReceiveData();

            return response;
        }
コード例 #5
0
        /// <summary>
        /// Receives data from the TRobot's Mobot sensor. Range for Mobot sensor is (50 - 3500 mm).
        /// </summary>
        /// <returns>Distance in mm from the TRobot's Mobot sensors. The key for measured distance is "distance"</returns>
        public Data ReceiveData()
        {
            Data data = new Data();
            data.SelectedDeviceType = SelectedDevice.Mobot;
            try
            {
                String distance = arduino.GetMobotData();

                data.Dictionary.Add(key, double.Parse(distance));
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
            return data;
        }
コード例 #6
0
        /// <summary>
        /// Receives chipset's temperature from the TRobot's thermometer.
        /// </summary>
        /// <returns>Temperature of chipset in degrees C. The key for temperature value is "temperature".</returns>
        public Data ReceiveData()
        {
            Data data = new Data();
            data.SelectedDeviceType = SelectedDevice.Temperature;
            try
            {
                int degreesC = int.Parse(roboteQ.GetTemperature());

                data.Dictionary.Add(key, degreesC);
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
            return data;
        }
コード例 #7
0
        /// <summary>
        /// Receives data from the TRobot's encoders. Range for encoders is around (0 - 3.06 km/h).
        /// </summary>
        /// <returns>Velocity of Trobot in km/h. The key for measured velocity is "speed".</returns>
        public Data ReceiveData()
        {
            Data data = new Data();
            data.SelectedDeviceType = SelectedDevice.Encoder;
            try
            {
                String[] response = roboteQ.GetSpeed();

                double velocity = ((double.Parse(response[0]) + Double.Parse(response[1])) / 2) * (wheelCircuitInKm / hoursInMinute);
                data.Dictionary.Add(key, velocity);
            }
            catch (Exception e)
            {
                //Logger.Log(e);
            }
            return data;
        }
コード例 #8
0
        /// <summary>
        /// Receives data from the TRobot's Hokuyo sensor. Range for Hokuyo sensor is around (20 - 4000 mm). 
        /// Scan area is 240 degrees semicircle. Sensor outputs the distace measured at 682 points.
        /// </summary>
        /// <returns>Distance in 682 points in mm from the TRobot's Hokuyo sensor. The key for measured distance is "distance0", "distance1", ..., "distance681".</returns>
        public Data ReceiveData()
        {
            Data data = new Data();
            data.SelectedDeviceType = SelectedDevice.Hokuyo;
            try
            {
                int[] distanceValuesFromHokuyo = hokuyo.GetData();
                int numberOfDistanceValues = distanceValuesFromHokuyo.Count();

                String currentKey;
                for (int i = 0; i < numberOfDistanceValues; i++)
                {
                    currentKey = key + i;
                    data.Dictionary.Add(currentKey, distanceValuesFromHokuyo[i]);
                }
            }
            catch (Exception e)
            {
                Logger.Log(e);
            }
            return data;
        }
コード例 #9
0
ファイル: Service1.cs プロジェクト: mgorski-zlatan/TRobotWCF
 /// <summary>
 /// Sends data to selected device.
 /// </summary>
 /// <param name="data">Data with selected device type and values to send to selected device.</param>
 public void SendData(Data data)
 {
     IDataProvider dataProvider = new EncoderDataProvider(data, devicesManager.RoboteQ);
     dataProvider.ProvideData();
 }
コード例 #10
0
 /// <summary>
 /// Constructs a EncoderDataProvider instance.
 /// </summary>
 /// <param name="driversData">Data object with information about left and right wheel power. It must be in the Dictionary wiht keys: "leftWheelPower" and "rightWheelPower".</param>
 /// <param name="roboteQ">Singleton istance of RoboteQ supporter.</param>
 public EncoderDataProvider(Data driversData, Roboteq roboteQ)
 {
     this.driversData = driversData;
     this.roboteQ = roboteQ;
 }