Esempio n. 1
0
        public void CheckAttitudeObject()
        {
            MAVLink.mavlink_attitude_t data = new MAVLink.mavlink_attitude_t();
            data.pitch        = 1;
            data.pitchspeed   = 2;
            data.roll         = 3;
            data.rollspeed    = 4;
            data.time_boot_ms = 5;
            data.yaw          = 6;
            data.yawspeed     = 7;

            MavLinkMessage message = createSampleMessage(MAVLink.MAVLINK_MSG_ID.ATTITUDE, data);

            Attitude obj = new Attitude(message);

            Assert.AreEqual(data.pitch, obj.pitch);
            Assert.AreEqual(data.pitchspeed, obj.pitchspeed);
            Assert.AreEqual(data.roll, obj.roll);
            Assert.AreEqual(data.rollspeed, obj.rollspeed);
            Assert.AreEqual(data.time_boot_ms, obj.time_boot_ms);
            Assert.AreEqual(data.yaw, obj.yaw);
            Assert.AreEqual(data.yawspeed, obj.yawspeed);

            AttitudeDTO dto = DTOFactory.createAttitudeDTO(obj);

            Assert.AreEqual(dto.pitch, obj.pitch);
            Assert.AreEqual(dto.pitchspeed, obj.pitchspeed);
            Assert.AreEqual(dto.roll, obj.roll);
            Assert.AreEqual(dto.rollspeed, obj.rollspeed);
            Assert.AreEqual(dto.time_boot_ms, obj.time_boot_ms);
            Assert.AreEqual(dto.yaw, obj.yaw);
            Assert.AreEqual(dto.yawspeed, obj.yawspeed);
        }
Esempio n. 2
0
        public static AttitudeDTO createAttitudeDTO(Attitude source)
        {
            if (null == source)
            {
                return(null);
            }
            AttitudeDTO result = new AttitudeDTO();

            Utilities.CopySimilar.CopyAll(source, result);
            return(result);
        }
Esempio n. 3
0
        public async Task <OperationResult> SetAttitude(AttitudeDTO attitude)
        {
            var currentAttitude = Db.RelationshipRepository.Get().FirstOrDefault(x => x.UserFromId == attitude.UserFromId && x.UserToId == attitude.UserToId);

            if (currentAttitude == null)
            {
                var rel = _mapper.Map <AttitudeDTO, Relationship>(attitude);
                try
                {
                    Db.RelationshipRepository.Insert(rel);
                    await Db.SaveAsync();

                    return(new OperationResult(true));
                }
                catch (Exception)
                {
                    return(new OperationResult(false, "Set failing", ""));
                }
            }
            currentAttitude.Attitude = (Attitude)attitude.Attitude;
            await Db.SaveAsync();

            return(new OperationResult(true));
        }
Esempio n. 4
0
 public AttitudeDTO GetAttitude(AttitudeDTO attitude) =>
 _mapper.Map <Relationship, AttitudeDTO>(Db.RelationshipRepository.Get().FirstOrDefault(x => x.UserFromId == attitude.UserFromId && x.UserToId == attitude.UserToId));