コード例 #1
0
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.Entity <UserLog>().HasData(Models.UserLog.GetSeederData());
     modelBuilder.Entity <DroneLog>().HasData(DroneLog.GetSeederData());
     modelBuilder.Entity <Payload>().HasData(Payload.GetSeederData());
     modelBuilder.Entity <ImageLog>().HasData(ImageLog.GetSeederData());
     modelBuilder.Entity <VideoLog>().HasData(VideoLog.GetSeederData());
     modelBuilder.Entity <IncidentLog>().HasData(IncidentLog.GetSeederData());
     modelBuilder.Entity <ObjectObserve>().HasData(ObjectObserve.GetSeederData());
     modelBuilder.Entity <StaticalLog>().HasData(StaticalLog.GetSeederData());
     modelBuilder.Entity <WarningLog>().HasData(WarningLog.GetSeederData());
     modelBuilder.Entity <MonitorRegionLog>().HasData(MonitorRegionLog.GetSeederData());
     modelBuilder.Entity <ResolveProblemLog>().HasData(ResolveProblemLog.GetSeederData());
     modelBuilder.Entity <UavConnectLog>().HasData(UavConnectLog.GetSeederData());
 }
コード例 #2
0
        private void HandleDataPacket(byte[] packet)
        {
            using (MemoryStream stream = new MemoryStream(packet))
            {
                PacketBuffer buffer = new PacketBuffer(stream);
                if (buffer.Size < 3 || buffer.ReadByte() != 'F' || buffer.ReadByte() != 'L' || buffer.ReadByte() != 'Y')
                {
                    return;
                }

                int            revision = buffer.ReadInt();
                DataPacketType type     = (DataPacketType)buffer.ReadByte();

                lastDataTime = Environment.TickCount;

                switch (type)
                {
                case DataPacketType.Drone:
                    if (!CheckRevision(lastDataDroneRevision, revision))
                    {
                        return;
                    }

                    DroneState      state       = (DroneState)buffer.ReadByte();
                    QuadMotorValues motorValues = new QuadMotorValues(buffer);
                    SensorData      sensor      = new SensorData(buffer);

                    float batteryVoltage = buffer.ReadFloat();
                    int   wifiRssi       = buffer.ReadInt();

                    Data = new DroneData(state, motorValues, sensor, batteryVoltage, wifiRssi);

                    lastDataDroneRevision = revision;
                    break;

                case DataPacketType.Log:
                    if (!CheckRevision(lastDataLogRevision, revision))
                    {
                        return;
                    }

                    int lines = buffer.ReadInt();

                    for (int i = 0; i < lines; i++)
                    {
                        string msg = buffer.ReadString();

                        DroneLog.AddLine(msg);
                    }

                    lastDataLogRevision = revision;
                    break;

                case DataPacketType.DebugOutput:
                    if (!CheckRevision(lastDataOutputRevision, revision))
                    {
                        return;
                    }

                    DebugOutputData        = new OutputData(buffer);
                    lastDataOutputRevision = revision;

                    NotifyDebugDataChanged();
                    break;

                case DataPacketType.DebugProfiler:
                    if (!CheckRevision(lastDataProfilerRevision, revision))
                    {
                        return;
                    }

                    DebugProfilerData        = new ProfilerData(buffer);
                    lastDataProfilerRevision = revision;

                    NotifyDebugDataChanged();
                    break;
                }
            }
        }