예제 #1
0
        public override LogbookEntry ToLogbookEntry()
        {
            // Always return pending flights
            PendingFlight pf = new PendingFlight()
            {
                Date            = FlightDate,
                Route           = JoinStrings(new string[] { DepartureAirportCode.MostDescriptive, DestinationAirportCode.MostDescriptive }),
                FlightStart     = TakeoffTime ?? DateTime.MinValue,
                FlightEnd       = LandingTime ?? DateTime.MinValue,
                TailNumDisplay  = AircraftRegistration ?? String.Empty,
                ModelDisplay    = AircraftType ?? String.Empty,
                TotalFlightTime = totalFlightTime == null ? 0 : totalFlightTime.SafeParseDecimal(),
                          Nighttime        = NightFlightTime == null ? 0 : NightFlightTime.SafeParseDecimal(),
                          PIC              = PicTime == null ? 0 : PicTime.SafeParseDecimal(),
                          SIC              = SicTime == null ? 0 : SicTime.SafeParseDecimal(),
                          Dual             = DualPilotTimeReceived == null ? 0 : DualPilotTimeReceived.SafeParseDecimal(),
                          CFI              = DualPilotTimeGiven == null ? 0 : DualPilotTimeGiven.SafeParseDecimal(),
                          FullStopLandings = DayLandingCount,
                          NightLandings    = NightLandingCount,
                          Approaches       = ApproachList.Length,
                          User             = Username
            };

            Aircraft ac = BestGuessAircraftID(Username, pf.TailNumDisplay);

            List <CustomFlightProperty> lst = new List <CustomFlightProperty>()
            {
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropFlightNumber, FlightNumber),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropDutyStart, DutyStartTime ?? DateTime.MinValue, true),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropDutyEnd, DutyEndTime ?? DateTime.MinValue, true),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDBlockOut, ActualDepartureTime ?? DateTime.MinValue, true),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDBlockIn, ActualArrivalTime ?? DateTime.MinValue, true),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropNameOfPIC, Pic == null || String.IsNullOrEmpty(Pic.Surname) ? Commander : Pic.Surname),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropNameOfSIC, Sic == null || Sic.Surname == null ? string.Empty : Sic.Surname),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropMultiPilotTime, MultiPilotFlightTime == null ? 0 : MultiPilotFlightTime.SafeParseDecimal()),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropSolo, SoloFlightTime == null ? 0 : SoloFlightTime.DecimalFromHHMM()),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropNightTakeoff, NightTakeoffCount),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropIFRTime, IfrTime == null ? 0 : IfrTime.SafeParseDecimal()),
                CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropApproachName, ApproachTypeList == null ? string.Empty : JoinStrings(ApproachTypeList))
            };

            if (ac != null)
            {
                pf.AircraftID = ac.AircraftID;
                if (ac.IsAnonymous)
                {
                    lst.Add(CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropAircraftRegistration, pf.TailNumDisplay));
                }
            }

            pf.CustomProperties.SetItems(lst);

            AutoComplete(pf);

            return(pf);
        }
예제 #2
0
        private static int MyNETPICSTREAM_NOTIFY(UInt32 _uiRecvID, int _lCommand, IntPtr _pvCallBackInfo, Int32 _BufLen, IntPtr _iUser)
        {
            if (null == _pvCallBackInfo)
            {
                return(-1);
            }

            if (_uiRecvID != g_uiRecvID)
            {
                return(-1);
            }

            if (SDKTypes.NET_PICSTREAM_CMD_ITS != _lCommand)
            {
                return(0);
            }

            if (g_iCount++ >= SDKTypes.MAX_SAVE_PCTURE_COUNT)
            {
                Console.WriteLine("save picture over 2000!\n");
                return(-1);
            }

            IntPtr       ptVca         = _pvCallBackInfo;
            ItsPicStream tItsPicStream = (ItsPicStream)Marshal.PtrToStructure(ptVca, typeof(ItsPicStream));

            int    iPlateColor   = tItsPicStream.iPlateColor;
            string strPlateColor = "";

            if (iPlateColor >= 0 && iPlateColor < g_strPlateColor.Length)
            {
                strPlateColor = g_strPlateColor[iPlateColor];
            }
            else
            {
                strPlateColor = "未知";
            }
            int    iCarColor   = tItsPicStream.iCarColor;
            string strCarColor = "";

            if (iCarColor >= 0 && iCarColor < g_strCarColor.Length)
            {
                strCarColor = g_strCarColor[iCarColor];
            }
            else
            {
                strCarColor = "未知";
            }

            Console.WriteLine("picture info:iPicCount(" + tItsPicStream.iPicCount + "),cCameraIP(" + tItsPicStream.strCameraIP +
                              ")" + "cPlate(" + tItsPicStream.strPlate + ")," + "PlateColor(" + strPlateColor + ")," + "CarColor(" + strCarColor + ")\n");

            //抓拍大图,至多8张
            for (int i = 0; i < tItsPicStream.iPicCount && i < 8; ++i)
            {
                if (null == tItsPicStream.tPicData[i])
                {
                    continue;
                }

                PicData  tPicData  = (PicData)Marshal.PtrToStructure(tItsPicStream.tPicData[i], typeof(PicData));
                PicTime  tTime     = tPicData.tPicTime;
                DateTime tDataTime = new DateTime((int)tTime.uiYear, (int)tTime.uiMonth, (int)tTime.uiDay,
                                                  (int)tTime.uiHour, (int)tTime.uiMinute, (int)tTime.uiSecondsr, (int)tTime.uiMilliseconds);
                string cFileName = ".\\PicStream\\ItsPic-" + tItsPicStream.strCameraIP + "-No" + (g_iCount) + "-Time" + tDataTime.ToString("yyyyMMddhhmmss") + i + ".jpg";
                byte[] btPicData = new byte[tPicData.iDataLen];
                Marshal.Copy(tPicData.piPicData, btPicData, 0, tPicData.iDataLen);
                FileStream fFile = null;
                try
                {
                    fFile = new FileStream(cFileName, FileMode.Create);
                    fFile.Write(btPicData, 0, tPicData.iDataLen);
                }
                catch (IOException e)
                {
                    Console.WriteLine(e.Message);
                }
                finally
                {
                    if (null != fFile)
                    {
                        fFile.Close();
                    }
                }
            }
            //车牌图片
            if (tItsPicStream.iPlatCount > 0 && null != tItsPicStream.tPlatData)
            {
                PicData tPicData  = (PicData)Marshal.PtrToStructure(tItsPicStream.tPlatData, typeof(PicData));
                string  cFileName = ".\\PicStream\\ItsPlat-" + tItsPicStream.strCameraIP + "-No" + (g_iCount) + "CP" + ".jpg";
                byte[]  btPicData = new byte[tPicData.iDataLen];
                Marshal.Copy(tPicData.piPicData, btPicData, 0, tPicData.iDataLen);
                FileStream fFile = new FileStream(cFileName, FileMode.Create);
                if (null != fFile)
                {
                    fFile.Write(btPicData, 0, tPicData.iDataLen);
                    fFile.Close();
                }
            }
            //人脸图片
            for (int i = 0; i < tItsPicStream.iFaceCount && i < 3; ++i)
            {
                if (null == tItsPicStream.tFaceData[i])
                {
                    continue;
                }
                PicData tPicData  = (PicData)Marshal.PtrToStructure(tItsPicStream.tFaceData[i], typeof(PicData));
                string  cFileName = ".\\PicStream\\ItsFace-" + tItsPicStream.strCameraIP + "-No" + (g_iCount) + "CP_" + i + ".jpg";
                byte[]  btPicData = new byte[tPicData.iDataLen];
                Marshal.Copy(tPicData.piPicData, btPicData, 0, tPicData.iDataLen);
                FileStream fFile = new FileStream(cFileName, FileMode.Create);
                if (null != fFile)
                {
                    fFile.Write(btPicData, 0, tPicData.iDataLen);
                    fFile.Close();
                }
            }
            return(0);
        }