예제 #1
0
파일: Program.cs 프로젝트: richross/LiveV
        static void AddVehicles()
        {
            Console.WriteLine("\nCreating and adding vehicles to the Live IoT system");

            string defaultCurrentZipCode = "98101";

            //ADD VEHICLE 1 /////////////////////////////////////////////
            int vehicleId1 = 1;
            LiveVehicle tempVehicleData1 = new LiveVehicle();
            tempVehicleData1.VehicleId = vehicleId1;
            //Seattle Pike's Place coordinates
            tempVehicleData1.GPSCoordinates.Latitude = 47.608875;
            tempVehicleData1.GPSCoordinates.Longitude = -122.340098;

            //Here we would find out the ZipCode related to the GPS coordinates.
            //For now, I set the ZipCode directly            
            tempVehicleData1.CurrentZipCode = defaultCurrentZipCode;

            //Call Http Service to add vehicle
            AddLiveVehicle(tempVehicleData1);
            /////////////////////////////////////////////////////////////////////////

            //ADD VEHICLE 2 /////////////////////////////////////////////
            int vehicleId2 = 2;
            LiveVehicle tempVehicleData2 = new LiveVehicle();
            tempVehicleData2.VehicleId = vehicleId2;
            //Seattle STARBUCKS ORIGINAL coordinates 47.610021, -122.342649
            tempVehicleData2.GPSCoordinates.Latitude = 47.610021;
            tempVehicleData2.GPSCoordinates.Longitude = -122.342649;

            //Here we would find out the ZipCode related to the GPS coordinates.
            //For now, I set the ZipCode directly            
            tempVehicleData2.CurrentZipCode = defaultCurrentZipCode;

            //Call Http Service to add vehicle
            AddLiveVehicle(tempVehicleData2);
            /////////////////////////////////////////////////////////////////////////

            //ADD VEHICLE 3 /////////////////////////////////////////////
            int vehicleId3 = 3;
            LiveVehicle tempVehicleData3 = new LiveVehicle();
            tempVehicleData3.VehicleId = vehicleId3;
            //Seattle CONVENTION CENTER coordinates 47.612283, -122.331918
            tempVehicleData3.GPSCoordinates.Latitude = 47.612283;
            tempVehicleData3.GPSCoordinates.Longitude = -122.331918;

            //Here we would find out the ZipCode related to the GPS coordinates.
            //For now, I set the ZipCode directly            
            tempVehicleData3.CurrentZipCode = defaultCurrentZipCode;

            //Call Http Service to add vehicle
            AddLiveVehicle(tempVehicleData3);
            /////////////////////////////////////////////////////////////////////////

            Console.WriteLine("##### END OF ADDING VEHICLES PROCESS #####");
            Console.WriteLine("##########################################");

        }
예제 #2
0
파일: Program.cs 프로젝트: richross/LiveV
        private static void AddLiveVehicle(LiveVehicle vehicle)
        {
            Uri serviceAddress = new Uri(SeatMapGatewayServiceUrl + "LiveVehicle");
            HttpWebRequest req = WebRequest.CreateHttp(serviceAddress);

            string data = JsonConvert.SerializeObject(vehicle);
            //This gives you the byte array.

            var dataToSend = Encoding.UTF8.GetBytes(data);

            req.ContentType = "application/json";
            req.ContentLength = dataToSend.Length;
            req.Method = "POST";

            req.GetRequestStream().Write(dataToSend, 0, dataToSend.Length);

            var response = req.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();
            //Console.WriteLine("********************************");            
            Console.WriteLine(responseFromServer);
            //Console.WriteLine(" ");
        }
예제 #3
0
        public IEnumerable<string> Get()
        {
            //ActorId myActorId = ActorId.NewId();
            int vehicleId = 1;
            ActorId actorId = new ActorId(vehicleId);
            var vehicleProxy = ActorProxy.Create<ILiveVehicleActor>(actorId, "fabric:/LiveVStatefulApp");

            LiveVehicle tempVehicleData1 = new LiveVehicle();
            tempVehicleData1.VehicleId = vehicleId;
            //Seattle Pike's Place coordinates
            tempVehicleData1.GPSCoordinates.Latitude = 47.608875;
            tempVehicleData1.GPSCoordinates.Longitude = -122.340098;

            //Here we would find out the ZipCode related to the GPS coordinates.
            //For now, I set the ZipCode directly
            string currentZipCode = "98101";
            tempVehicleData1.CurrentZipCode = currentZipCode;

            //Output TBD --> ("Setting vehicleId {0} to Actor {1}", vehicleId, vehicleProxy.GetActorId() );
            vehicleProxy.SetVehicleLiveDataAsync(tempVehicleData1).Wait();

            string resultDone = "Actor " + vehicleProxy.GetActorId().ToString() + " is External-VehicleID: " + vehicleProxy.GetCurrentVehicleLiveDataAsync().Result.VehicleId.ToString();

            return new string[] { "TEST: ", resultDone };

            //return new string[] { "TEST: ", "TEST 2" };
        }