1 / 19

Monitor de Temperatura

Monitor de Temperatura. OBJETIVO. Monitoreo de Temperatura en Salas de Computo Elaborar graficas de comportamiento Envío de Alertas. Termómetro Digital interfase Serial. Diagrama de Clases de Persistencia. Capas significativas de la Aplicaci ó n. Vista. Servicios. Integración. .Net.

dandre
Télécharger la présentation

Monitor de Temperatura

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Monitor de Temperatura

  2. OBJETIVO • Monitoreo de Temperatura en Salas de Computo • Elaborar graficas de comportamiento • Envío de Alertas

  3. Termómetro Digital interfase Serial

  4. Diagrama de Clases de Persistencia

  5. Capas significativas de la Aplicación Vista Servicios Integración .Net

  6. Mapeo de capas con Vista Física Vista -> Administrador Web, MotorTemperatura.exe Servicios -> MonitorTemperatura.Operaciones , Email Integración -> MonitorTemperatura.DataAccess : Acceso a Servidor DB4O

  7. Vistas

  8. Configuracion DB4O Client/Server • Iniciar Servidor Operaciones Cliente class Comun { . . . public delegate void MethodDelegate(); public void AsyncStartServer() { MethodDelegatedlgt = startServer; IAsyncResultar = dlgt.BeginInvoke(null,null); } private void startServer() { StartServer server = new StartServer(); server.RunServer(); } } class Monitor { . . . private void buttonStart_Click(object sender, EventArgs e) { Comun c = new Comun(); c.AsyncStartServer(); } }

  9. Configuracion DB4O Client/Server Class StartServer : Util {… public void RunServer() { lock (this) { try { IObjectServer server = Db4oFactory.OpenServer(YapFileName, PORT); server.GrantAccess(USER, PASS); server.Ext().Configure().ClientServer().SetMessageRecipient(this); try { if (!this.stop) { Monitor.Wait(this); } } catch (Exception exception) { System.Diagnostics.EventLog.WriteEntry("MonitorTemperatura", exception.ToString()); } server.Close(); } catch (Exception ex) { System.Diagnostics.EventLog.WriteEntry("MonitorTemperatura", ex.ToString()); } }} Acceso a Datos

  10. Configuracion DB4O Client/Server • Detener Servidor Operaciones Cliente class Monitor { . . . private void buttonStop_Click(object sender, EventArgs e) { Comun c = new Comun(); c.stopServer(); } } class Comun { . . . public void stopServer() { StopServer.Stop(); } }

  11. Configuracion DB4O Client/Server Acceso a Datos Class StopServer : Util { public static void Stop() { IObjectContainer container = null; try { container = Db4oFactory.OpenClient("localhost", PORT, USER, PASS); } catch (Exception exception) { System.Diagnostics.EventLog.WriteEntry("MonitorTemperatura", exception.ToString()); } if (container != null) { container.Ext().Configure().ClientServer().GetMessageSender().Send(new StopServer()); container.Close(); } } }

  12. Configuracion Base de Datos public class Util { public static readonly string ServerPassword = "password"; public static readonly string ServerUser = "user“; public static readonly string YapFileName = “MonitorTemperaturaDB.yap"; public static readonly string PASS = "db4o"; public static readonly string HOST = "localhost"; public static readonlyint PORT = 0x1188; public static readonly string USER = "db4o"; } public class ComunDAO { private IObjectContainerOpenFileRemote() { IObjectContainer db = Db4oFactory.OpenClient(Util.HOST, Util.PORT, Util.USER, Util.PASS); ConfigureDBObjects(); return db; } private void CloseFile(IObjectContainer db) { db.Close(); } private void ConfigureDBObjects() // Permite la Actualizacion de Objetos y el Borrado en Cascada { Db4oFactory.Configure().ObjectClass(typeof(Ubicacion)).CascadeOnUpdate(true); Db4oFactory.Configure().ObjectClass(typeof(Ubicacion)).CascadeOnDelete(true); } }

  13. Queries public class UbicacionDAO { public HashtableObtenerUbicaciones(Ubicacionfiltro) { db = OpenFileRemote(); list = db.QueryByExample(filtro); Hashtable t = GetDataTable(list); CloseFile(db); return t; } public UbicacionObtenerUbicacion(Ubicacionfiltro) { return ObtenerUbicacion(filtro,true); } public UbicacionObtenerUbicacion(Ubicacionfiltro, boolclosedb) { db = OpenFileRemote(); list = db.QueryByExample(filtro); Ubicacion obj2=null; if (list.Count > 0) { obj2 = (Ubicacion)list.Next(); } if (closedb) CloseFile(db); return obj2; }

  14. Grabado public class UbicacionDAO { public void GrabarUbicacion(Ubicacionobj) { UbicacionDAOdao = new UbicacionDAO(); dao.GrabarUbicacion(obj); } public void GrabarLecturas(Ubicacionobj) { UbicacionDAOdao = new UbicacionDAO(); Ubicacionfiltro = new Ubicacion(); Ubicacion obj2; if( obj.IdUbicacion>0) filtro.IdUbicacion = obj.IdUbicacion; obj2 = (Ubicacion)dao.ObtenerUbicacion(filtro,false); // false-> no cierra la conexionparaactualizalo if (obj2!= null) { obj2.Estado = obj.Estado; if (obj.Lecturas[0] != null) { obj.Lecturas[0].idLectura = (obj2.Index+1).ToString(); obj2.Lecturas[obj2.Index] = obj.Lecturas[0]; obj2.Index++; } .

  15. Grabado • . • . • . • dao.GrabarUbicacion(obj2); • } • else • { • obj.Estado = true; • dao.GrabarUbicacion(obj); • } • } • } • ClassUbicacionDAO • { • public void GrabarUbicacion(Ubicacionobj) • { • GrabarUbicacion(obj, true); • } • public void GrabarUbicacion(Ubicacionobj, boolclosedb) • { • db = OpenFileRemote(); • db.Store(obj); • if (closedb) • CloseFile(db); • } • }

  16. Borrado de Datos • public class ComunDAO • { • . • . • . • public void DeleteAll() • { • IObjectContainer db = OpenFileRemote(); • Util.DeleteAll(db); • CloseFile(db); • } • } • public class Util • { • . • . • . • public static void DeleteAll(IObjectContainer db) • { • object obj = new object(); • IObjectSet set = db.QueryByExample(obj); • foreach (object obj2 in set) • { • db.Delete(obj2); • } • } • }

  17. Simulación de Lecturas public class Lector { private void startReader() { stop = true; EstablecerEstadoBotones(); inti = 1; int top = int.Parse(ConfigurationManager.AppSettings["MaxLecturas"].Trim()); while (i < top && stop) { double val = ObtenerLectura(); labelLectura.Text = val.ToString() + " °C"; GrabarLectura(val); i++; } } private static double ObtenerLectura() { return RandomDouble(15,70); } . . .

  18. Simulación de Lecturas . . . private void GrabarLectura(double val, boolagregarlectura) { UbicacionOP op = new MonitorTemperatura.Operciones.UbicacionOP(); Ubicacionobj = new Ubicacion(); obj.IdUbicacion = int.Parse(ConfigurationManager.AppSettings["IdUbicacion"].Trim()); obj.Descripcion = ConfigurationManager.AppSettings["Descripcion"].Trim(); obj.Estado = stop; if (agregarlectura) { Lectura l = new Lectura(); l.Tipounidad.IdUnidad = ConfigurationManager.AppSettings["TipoUnidad"].Trim(); l.Valor = val; l.Fecha = System.DateTime.Now; l.Hora = System.DateTime.Now; obj.Lecturas[0] = l; } op.GrabarLecturas(obj); } }

  19. Configuracion Cliente <configuration> <appSettings> <add key="IdUbicacion" value="1" /> <addkey="Descripcion" value="Ubicacion Prueba 1" /> <add key="TipoUnidad" value="1" /> <add key="MaxLecturas" value="20" /> <add key="WebAdmin" value="http://localhost/MonitorTemperatura.View/Default.aspx" /> </appSettings> </configuration>

More Related