Exemplo 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,100);
			Console.WriteLine("done");

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

			foreach (OnDiscAdress ondisc in data_store.InMemoryIndex)
			{
				XS1_DataObject dataobject = new XS1_DataObject();
                try
                {
                    dataobject.Deserialize(data_store.Read(ondisc));
                    //Console.WriteLine(dataobject.Timecode.ToLongTimeString() + ";" + dataobject.Timecode.ToShortDateString() + ";" + dataobject.Name + ";" + dataobject.Type + ";" + dataobject.TypeName + ";" + dataobject.Value + ";" + dataobject.OriginalXS1Statement);
                    if (!Sensors.ContainsKey(dataobject.Name))
                        Sensors.Add(dataobject.Name, dataobject);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error: "+ondisc.CreationTime+" - "+ ondisc.Start +" - " + e.Message);
                }
			}

			foreach(XS1_DataObject dataobject in Sensors.Values)
			{
				Console.WriteLine(dataobject.Name+";"+dataobject.Type+";"+dataobject.TypeName+";"+dataobject.Value+";"+dataobject.OriginalXS1Statement);
			}

		}
Exemplo 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)
			{
				GoogleLatitudeDataObject dataobject = new GoogleLatitudeDataObject();
				dataobject.Deserialize(data_store.Read(ondisc));
				//Int32 CurrentDay = -1;

				if (dataobject.AccountName == Accountname) 
				{
					Console.WriteLine(String.Format("{0:F6}#{1:F6}#{0:F6}",dataobject.Latitude, dataobject.Longitude,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>");
		}
Exemplo n.º 3
0
		private static XS1_DataObject ReadFromCache(TinyOnDiskStorage sensor_data, OnDiscAdress adress)
		{
			XS1_DataObject dataobject = null;
			
			object cacheditem = sensor_data.Cache.ReadFromCache(adress);
			if (cacheditem == null)
			{
				// not found in cache, read from disk and add to cache
				dataobject.Deserialize(sensor_data.Read(adress));
				sensor_data.Cache.AddToCache(adress,dataobject);
			}
			else
			{
				// found in cache, take it...
				dataobject = (XS1_DataObject)cacheditem;
			}
			
			return dataobject;
		}
Exemplo n.º 4
0
		static void Main(string[] args)
		{
			Console.WriteLine("hacs storage performance tuning project: benchmark");
			Console.WriteLine("(C) 2013 Daniel Kirstenpfad - http://technology-ninja.com");
			Console.WriteLine();

			int number = 100000;
			int cachefactor = 1;
			Stopwatch sw = new Stopwatch();

			#region Generating benchmark data set
			if (Directory.Exists("benchmark-data"))
			{
				Directory.Delete("benchmark-data",true);
				Directory.CreateDirectory("benchmark-data");
			}
			else
				Directory.CreateDirectory("benchmark-data");
			sw.Start();
			TinyOnDiskStorage benchmark_storage = new TinyOnDiskStorage("benchmark-data" + Path.DirectorySeparatorChar + "benchmark-data", false, number/cachefactor);
			sw.Stop();
			Console.WriteLine("Initialized benchmark-data storage in "+sw.ElapsedMilliseconds+" ms");

			sw.Reset();

			Console.Write("Generating data ("+number+") - ");

			int CursorLeft = Console.CursorLeft;
			int CursorTop = Console.CursorTop;

			sw.Start ();
			for (int i=0;i<=number;i++)
			{
				//Console.SetCursorPosition(CursorLeft,CursorTop);
				//Console.Write(i+"/"+number);

				// now generating the file...
				XS1_DataObject data = new XS1_DataObject("ServerName","Name",ObjectTypes.Actor,"TypeName",DateTime.Now,i,i);

				benchmark_storage.Write(data.Serialize());
			}
			sw.Stop();
			Console.WriteLine("done in "+sw.ElapsedMilliseconds+" ms");

			sw.Reset();
			Console.WriteLine("Resetting...");

			benchmark_storage.Shutdown();

			sw.Start();
			benchmark_storage = new TinyOnDiskStorage("benchmark-data" + Path.DirectorySeparatorChar + "benchmark-data", false, number/2);
			sw.Stop();
			Console.WriteLine("Initialized benchmark-data storage in "+sw.ElapsedMilliseconds+" ms");
			sw.Reset();

			Console.Write("Reading ("+number+") - ");
			int o = 0;
			sw.Start();
			foreach(OnDiscAdress addr in benchmark_storage.InMemoryIndex)
			{
				XS1_DataObject data = new XS1_DataObject();
				data.Deserialize(benchmark_storage.Read(addr));
				if (data.XS1ObjectID != o)
					Console.WriteLine(data.Timecode.ToString());
				o++;
			}
			o--;
			sw.Stop();
			Console.WriteLine("done ("+o+") in "+sw.ElapsedMilliseconds+" ms");
			sw.Reset();
			#endregion
		}