示例#1
0
        public static void Main(string[] args)
        {
            Trace("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)\n");
            Trace("Begin ManualTestEvent.Main\n");

            ManualTestEvent te = new ManualTestEvent();
            Vehicle         v1 = new Vehicle();

            v1.FuelLevelChanged += new AbstractVehicle.FuelLevelChangedEventHandler(te.FuelLevelChanged);
            v1.FuelLevel         = 0.77;
            v1.FuelLevel         = 0.77;
            v1.FuelLevel         = 0.77;
            v1.FuelLevel         = 1.0;
            v1.FuelLevel         = 1.0;
            v1.FuelLevel         = 1.0;

            TestFloatArrayMethods(v1);

            VehicleDescriptor desc = new VehicleDescriptor();

            try
            {
                desc = v1.TGetDescriptor();
            }
            catch (System.Exception exc)
            {
                Trace("info: Caught exception calling v1.TGetDescriptor...\n");
                Trace("      Is this an older version of mono with the 'struct cannot cross PInvoke boundary' bug?\n");
                Trace("\n");
                Trace(exc.ToString());
                Trace("\n");
                Trace("\n");
            }

            Trace(String.Format("desc.AMarker: {0}\n", desc.AMarker));
            Trace(String.Format("desc.BoolTest1: {0}\n", desc.BoolTest1));
            Trace(String.Format("desc.BoolTest2: {0}\n", desc.BoolTest2));
            Trace(String.Format("desc.c1: {0}\n", desc.c1));
            Trace(String.Format("desc.ColorCode: {0}\n", desc.ColorCode));
            Trace(String.Format("desc.d1: {0}\n", desc.d1));
            Trace(String.Format("desc.f1: {0}\n", desc.f1));
            Trace(String.Format("desc.i1: {0}\n", desc.i1));
            Trace(String.Format("desc.i64: {0}\n", desc.i64));
            Trace(String.Format("desc.l1: {0}\n", desc.l1));
            Trace(String.Format("desc.MileageEstimate: {0}\n", desc.MileageEstimate));
            Trace(String.Format("desc.NumberOfCylinders: {0}\n", desc.NumberOfCylinders));
            Trace(String.Format("desc.NumberOfDoors: {0}\n", desc.NumberOfDoors));
            Trace(String.Format("desc.s1: {0}\n", desc.s1));
            Trace(String.Format("desc.uc1: {0}\n", desc.uc1));
            Trace(String.Format("desc.ui1: {0}\n", desc.ui1));
            Trace(String.Format("desc.ui64: {0}\n", desc.ui64));
            Trace(String.Format("desc.ul1: {0}\n", desc.ul1));
            Trace(String.Format("desc.us1: {0}\n", desc.us1));
            Trace(String.Format("desc.enumMfgID: {0}\n", desc.enumMfgID));
            Trace(String.Format("desc.ZMarker: {0}\n", desc.ZMarker));

            desc.NumberOfCylinders = 16;
            desc.NumberOfDoors     = 16;
            v1.TSetDescriptor(desc);

            desc.NumberOfCylinders = 32;
            desc.NumberOfDoors     = 32;
            v1.TSetDescriptorRef(desc);

            desc.NumberOfCylinders = 64;
            desc.NumberOfDoors     = 64;
            v1.TSetDescriptorConstRef(desc);

            // Silly prove-you-can-do-it tests and improve coverage, too:
            //
            FuelLevelChanged evt = new FuelLevelChanged();

            evt.ReturnMyLong();
            evt.ReturnMyNonClassLong();
            evt = null;

            FuelLevelChangedEventArgs eargs = new FuelLevelChangedEventArgs();

            eargs.Level    = 0.88;
            eargs.OldLevel = 0.55;
            eargs          = null;

            Trace("End ManualTestEvent.Main\n");

            System.GC.Collect();
        }
示例#2
0
        public static void Main(string[] args)
        {
            Trace("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)\n");
              Trace("Begin ManualTestEvent.Main\n");

              ManualTestEvent te = new ManualTestEvent();
              Vehicle v1 = new Vehicle();
              v1.FuelLevelChanged += new AbstractVehicle.FuelLevelChangedEventHandler(te.FuelLevelChanged);
              v1.FuelLevel = 0.77;
              v1.FuelLevel = 0.77;
              v1.FuelLevel = 0.77;
              v1.FuelLevel = 1.0;
              v1.FuelLevel = 1.0;
              v1.FuelLevel = 1.0;

              TestFloatArrayMethods(v1);

              VehicleDescriptor desc = new VehicleDescriptor();

              try
              {
            desc = v1.TGetDescriptor();
              }
              catch(System.Exception exc)
              {
            Trace("info: Caught exception calling v1.TGetDescriptor...\n");
            Trace("      Is this an older version of mono with the 'struct cannot cross PInvoke boundary' bug?\n");
            Trace("\n");
            Trace(exc.ToString());
            Trace("\n");
            Trace("\n");
              }

              Trace(String.Format("desc.AMarker: {0}\n", desc.AMarker));
              Trace(String.Format("desc.BoolTest1: {0}\n", desc.BoolTest1));
              Trace(String.Format("desc.BoolTest2: {0}\n", desc.BoolTest2));
              Trace(String.Format("desc.c1: {0}\n", desc.c1));
              Trace(String.Format("desc.ColorCode: {0}\n", desc.ColorCode));
              Trace(String.Format("desc.d1: {0}\n", desc.d1));
              Trace(String.Format("desc.f1: {0}\n", desc.f1));
              Trace(String.Format("desc.i1: {0}\n", desc.i1));
              Trace(String.Format("desc.i64: {0}\n", desc.i64));
              Trace(String.Format("desc.l1: {0}\n", desc.l1));
              Trace(String.Format("desc.MileageEstimate: {0}\n", desc.MileageEstimate));
              Trace(String.Format("desc.NumberOfCylinders: {0}\n", desc.NumberOfCylinders));
              Trace(String.Format("desc.NumberOfDoors: {0}\n", desc.NumberOfDoors));
              Trace(String.Format("desc.s1: {0}\n", desc.s1));
              Trace(String.Format("desc.uc1: {0}\n", desc.uc1));
              Trace(String.Format("desc.ui1: {0}\n", desc.ui1));
              Trace(String.Format("desc.ui64: {0}\n", desc.ui64));
              Trace(String.Format("desc.ul1: {0}\n", desc.ul1));
              Trace(String.Format("desc.us1: {0}\n", desc.us1));
              Trace(String.Format("desc.enumMfgID: {0}\n", desc.enumMfgID));
              Trace(String.Format("desc.ZMarker: {0}\n", desc.ZMarker));

              desc.NumberOfCylinders = 16;
              desc.NumberOfDoors = 16;
              v1.TSetDescriptor(desc);

              desc.NumberOfCylinders = 32;
              desc.NumberOfDoors = 32;
              v1.TSetDescriptorRef(desc);

              desc.NumberOfCylinders = 64;
              desc.NumberOfDoors = 64;
              v1.TSetDescriptorConstRef(desc);

              // Silly prove-you-can-do-it tests and improve coverage, too:
              //
              FuelLevelChanged evt = new FuelLevelChanged();
              evt.ReturnMyLong();
              evt.ReturnMyNonClassLong();
              evt = null;

              FuelLevelChangedEventArgs eargs = new FuelLevelChangedEventArgs();
              eargs.Level = 0.88;
              eargs.OldLevel = 0.55;
              eargs = null;

              Trace("End ManualTestEvent.Main\n");

              System.GC.Collect();
        }
示例#3
0
        static void Main(string[] args)
        {
            int tsOffset = Convert.ToInt32(ConfigurationManager.AppSettings.Get("TimeStampOffset"));

            long timestamp_from = (long)Functions.ToEpoch(DateTime.UtcNow.AddMinutes(tsOffset));
            long timestamp_to   = (long)Functions.ToEpoch(DateTime.UtcNow);

            List <RTVehiclePositions> vehiclePositions = db.Database
                                                         .SqlQuery <RTVehiclePositions>("RTVehiclePositionsGetActive @timestamp_from, @timestamp_to"
                                                                                        , new SqlParameter("@timestamp_from", timestamp_from)
                                                                                        , new SqlParameter("@timestamp_to", timestamp_to))
                                                         .ToList();

            FeedMessage feed = new FeedMessage();

            if (vehiclePositions.Count > 0)
            {
                foreach (RTVehiclePositions vehiclePosition in vehiclePositions)
                {
                    TripDescriptor td = new TripDescriptor();
                    td.TripId      = vehiclePosition.trip_id;
                    td.RouteId     = vehiclePosition.route_id;
                    td.DirectionId = (uint)vehiclePosition.direction_id;
                    td.StartDate   = vehiclePosition.start_date;
                    td.StartTime   = vehiclePosition.start_time;

                    Position pos = new Position();
                    pos.Latitude  = (float)vehiclePosition.latitude;
                    pos.Longitude = (float)vehiclePosition.longitude;

                    VehicleDescriptor v = new VehicleDescriptor();
                    v.Id           = vehiclePosition.vehicle_id;
                    v.Label        = vehiclePosition.vehicle_label;
                    v.LicensePlate = vehiclePosition.vehicle_license_plate;

                    VehiclePosition vp = new VehiclePosition();
                    vp.Position            = pos;
                    vp.Trip                = td;
                    vp.Vehicle             = v;
                    vp.CurrentStopSequence = (uint)vehiclePosition.current_stop_sequence;
                    vp.StopId              = vehiclePosition.stop_id;
                    vp.Timestamp           = (ulong)vehiclePosition.timestamp;

                    FeedEntity entity = new FeedEntity();
                    entity.Id      = vehiclePosition.id.ToString();
                    entity.Vehicle = vp;

                    feed.Entities.Add(entity);
                }

                byte[] objSerialized = Functions.ProtoSerialize(feed);

                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
                string filename = "vehicleposition.pb";

                // Create a CloudFileClient object for credentialed access to Azure Files.
                CloudFileClient fileClient = storageAccount.CreateCloudFileClient();

                // Get a reference to the file share we created previously.
                CloudFileShare share = fileClient.GetShareReference("gtfsrt");
                share.CreateIfNotExists();

                var rootDir = share.GetRootDirectoryReference();
                using (var stream = new MemoryStream(objSerialized, writable: false))
                {
                    rootDir.GetFileReference(filename).UploadFromStream(stream);
                }
            }
        }