Esempio n. 1
0
        static void SensorList(String filename)
        {
            // try to open it for reading...
            Console.Write("Opening " + filename + " data-store for reading...");
            TinyOnDiskStorage data_store = new TinyOnDiskStorage(filename, false, 100000);

            Console.WriteLine("done");

            Dictionary <String, MiataruDataObject> Sensors = new Dictionary <string, MiataruDataObject>();

            foreach (OnDiscAdress ondisc in data_store.InMemoryIndex)
            {
                MiataruDataObject dataobject = new MiataruDataObject();
                dataobject.Deserialize(data_store.Read(ondisc));
                if (!Sensors.ContainsKey(dataobject.AccountName))
                {
                    Sensors.Add(dataobject.AccountName, dataobject);
                }
                //Console.WriteLine(dataobject.Timecode.ToLongTimeString()+";"+dataobject.Timecode.ToShortDateString()+";"+dataobject.Name+";"+dataobject.Type+";"+dataobject.TypeName+";"+dataobject.Value+";"+dataobject.OriginalXS1Statement);
            }

            foreach (MiataruDataObject dataobject in Sensors.Values)
            {
                Console.WriteLine(dataobject.AccountName);
            }
        }
Esempio n. 2
0
        static void ExportKML(String filename, String Accountname)
        {
            Console.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"><Document><name>" + Accountname + "</name><open>1</open>");
            Console.WriteLine("<Style id=\"trailsstyle\">");
            Console.WriteLine("<LineStyle><color>7f0000ff</color><width>6</width></LineStyle></Style><description>n/a</description>");

            // try to open it for reading...
            TinyOnDiskStorage data_store = new TinyOnDiskStorage(filename, false, 100000);

            Console.WriteLine("<Placemark><styleUrl>#trailsstyle</styleUrl><name>" + Accountname + "</name><LineString>;<tessellate>1</tessellate>");
            Console.WriteLine("<coordinates>");

            foreach (OnDiscAdress ondisc in data_store.InMemoryIndex)
            {
                MiataruDataObject dataobject = new MiataruDataObject();
                dataobject.Deserialize(data_store.Read(ondisc));

                if (dataobject.AccountName == Accountname)
                {
                    Console.WriteLine(String.Format("{0:F6}#{1:F6}#{0:F6}", dataobject.Longitude, dataobject.Latitude, dataobject.AccuracyInMeters).Replace(",", ".").Replace("#", ","));
                    // check which date it is...

                    /*					if (CurrentDay == -1)
                     * {	// the first time...
                     *      Console.WriteLine("<Placemark><styleUrl>#trailsstyle</styleUrl><name>"+DateTime.FromBinary (dataobject.Timecode).ToString()+"</name><LineString>;<tessellate>1</tessellate>");
                     *      Console.WriteLine("<coordinates>");
                     *
                     *      CurrentDay = DateTime.FromBinary (dataobject.Timecode).Day;
                     * }
                     *
                     * if (DateTime.FromBinary (dataobject.Timecode).Day == CurrentDay)
                     * {
                     *      Console.WriteLine(String.Format("{0:F6},{1:F6},{0:F6}",dataobject.Latitude, dataobject.Longitude,dataobject.AccuracyInMeters));
                     * }
                     * else
                     * {
                     *      Console.WriteLine("</coordinates></LineString></Placemark>");
                     *      Console.WriteLine("<Placemark><styleUrl>#trailsstyle</styleUrl><name>"+DateTime.FromBinary (dataobject.Timecode).ToString()+"</name><LineString>;<tessellate>1</tessellate>");
                     *      Console.WriteLine("<coordinates>");
                     *      Console.WriteLine(String.Format("{0:F6},{1:F6},{0:F6}",dataobject.Latitude, dataobject.Longitude,dataobject.AccuracyInMeters));
                     *      CurrentDay = DateTime.FromBinary (dataobject.Timecode).Day;
                     * }*/
                }
            }
            Console.WriteLine("</coordinates></LineString></Placemark></Document></kml>");
        }
Esempio n. 3
0
		static void ExportKML(String filename, String Accountname)
		{
			Console.WriteLine ("<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"><Document><name>" + Accountname + "</name><open>1</open>");
			Console.WriteLine ("<Style id=\"trailsstyle\">");
			Console.WriteLine ("<LineStyle><color>7f0000ff</color><width>6</width></LineStyle></Style><description>n/a</description>");

			// try to open it for reading...			
			TinyOnDiskStorage data_store = new TinyOnDiskStorage(filename, false,100000);
			Console.WriteLine("<Placemark><styleUrl>#trailsstyle</styleUrl><name>"+Accountname+"</name><LineString>;<tessellate>1</tessellate>");
			Console.WriteLine("<coordinates>");

			foreach (OnDiscAdress ondisc in data_store.InMemoryIndex)
			{
				MiataruDataObject dataobject = new MiataruDataObject();
				dataobject.Deserialize(data_store.Read(ondisc));

				if (dataobject.AccountName == Accountname) 
				{
					Console.WriteLine(String.Format("{0:F6}#{1:F6}#{0:F6}",dataobject.Longitude, dataobject.Latitude,dataobject.AccuracyInMeters).Replace(",",".").Replace("#",","));
					// check which date it is...
					/*					if (CurrentDay == -1)
					{	// the first time...
						Console.WriteLine("<Placemark><styleUrl>#trailsstyle</styleUrl><name>"+DateTime.FromBinary (dataobject.Timecode).ToString()+"</name><LineString>;<tessellate>1</tessellate>");
						Console.WriteLine("<coordinates>");

						CurrentDay = DateTime.FromBinary (dataobject.Timecode).Day;
					}

					if (DateTime.FromBinary (dataobject.Timecode).Day == CurrentDay) 
					{
						Console.WriteLine(String.Format("{0:F6},{1:F6},{0:F6}",dataobject.Latitude, dataobject.Longitude,dataobject.AccuracyInMeters));
					}
					else
					{
						Console.WriteLine("</coordinates></LineString></Placemark>");
						Console.WriteLine("<Placemark><styleUrl>#trailsstyle</styleUrl><name>"+DateTime.FromBinary (dataobject.Timecode).ToString()+"</name><LineString>;<tessellate>1</tessellate>");
						Console.WriteLine("<coordinates>");
						Console.WriteLine(String.Format("{0:F6},{1:F6},{0:F6}",dataobject.Latitude, dataobject.Longitude,dataobject.AccuracyInMeters));
						CurrentDay = DateTime.FromBinary (dataobject.Timecode).Day;
					}*/
				}
			}
			Console.WriteLine("</coordinates></LineString></Placemark></Document></kml>");
		}
Esempio n. 4
0
		static void SensorList (String filename)
		{
			// try to open it for reading...
			Console.Write("Opening "+filename+" data-store for reading...");
			TinyOnDiskStorage data_store = new TinyOnDiskStorage(filename, false,100000);
			Console.WriteLine("done");

			Dictionary<String,MiataruDataObject> Sensors = new Dictionary<string, MiataruDataObject>();

			foreach (OnDiscAdress ondisc in data_store.InMemoryIndex)
			{
				MiataruDataObject dataobject = new MiataruDataObject();
				dataobject.Deserialize(data_store.Read(ondisc));
				if (!Sensors.ContainsKey(dataobject.AccountName))
					Sensors.Add(dataobject.AccountName,dataobject);
				//Console.WriteLine(dataobject.Timecode.ToLongTimeString()+";"+dataobject.Timecode.ToShortDateString()+";"+dataobject.Name+";"+dataobject.Type+";"+dataobject.TypeName+";"+dataobject.Value+";"+dataobject.OriginalXS1Statement);
			}

			foreach(MiataruDataObject dataobject in Sensors.Values)
			{
				Console.WriteLine(dataobject.AccountName);
			}

		}
Esempio n. 5
0
        public void Run()
        {
            ConsoleOutputLogger.WriteLine("Miataru Thread started");

            miataruclient client = new miataruclient();

            while (!Shutdown)
            {
                try
                {
                    foreach (MiataruAccount Account in MiataruConfiguration.MiataruAccountConfigFile.MiataruAccounts)
                    {
                        // retrieve new data for this account...
                        #region Retrieve Data
                        List <MiataruLocation> Locations = client.GetLastLocationForDevice(Account.MiataruDeviceID, Account.MiataruServerURL);
                        #endregion

                        #region handle retrieved location data
                        if (Locations != null)
                        {
                            // create a MiataruDataObject out of the last known location
                            MiataruDataObject retrievedData = new MiataruDataObject(Account.Name, Locations[0].Device, Locations[0].Timestamp, Locations[0].Latitude, Locations[0].Longitude, Locations[0].HorizontalAccuracy);


                            if (CurrentLocations.ContainsKey(retrievedData.DeviceID))
                            {
                                // check if the coordinates have been updated...
                                MiataruDataObject alreadyStored = CurrentLocations[Account.MiataruDeviceID];

                                if ((alreadyStored.Latitude != retrievedData.Latitude) || (alreadyStored.Longitude != retrievedData.Longitude))
                                {
                                    CurrentLocations[Account.MiataruDeviceID] = retrievedData;
                                    // store to disk
                                    miatarustore.Write(retrievedData.Serialize());
                                    ConsoleOutputLogger.WriteLine("Miataru: " + retrievedData.AccountName + " - " + retrievedData.Latitude + "," + retrievedData.Longitude + "," + retrievedData.AccuracyInMeters);
                                }
                            }
                            else
                            {
                                // it's new! add it!
                                CurrentLocations.Add(retrievedData.DeviceID, retrievedData);
                                miatarustore.Write(retrievedData.Serialize());
                                ConsoleOutputLogger.WriteLine("Miataru: " + retrievedData.AccountName + " - " + retrievedData.Latitude + "," + retrievedData.Longitude + "," + retrievedData.AccuracyInMeters);
                            }
                        }
                        else
                        {
                            ConsoleOutputLogger.WriteLine("Miataru returned NULL for " + Account.MiataruDeviceID + " on " + Account.MiataruServerURL);
                        }
                        #endregion
                    }
                }
                catch (Exception e)
                {
                    ConsoleOutputLogger.WriteLine(e.Message + " - " + e.StackTrace);
                    Thread.Sleep(100);
                }

                Thread.Sleep(MiataruUpdateTime);
            }
        }