ParkingMeter

Files at this revision

API Documentation at this revision

Comitter:
williequesada
Date:
Tue Jun 04 16:03:14 2019 +0000
Commit message:
compartir a Pablo

Changed in this revision

ParkingMeter.cpp Show annotated file Show diff for this revision Revisions of this file
ParkingMeter.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ParkingMeter.cpp	Tue Jun 04 16:03:14 2019 +0000
@@ -0,0 +1,97 @@
+#include "ParkingMeter.h"
+#include "mbed.h"
+
+char AlarmString[6]={'A','A','A','A','A','A'};
+bool AlarmBool=0;
+int  Counter_Host=1315;
+int  Hostin_Conection=1320;
+
+PARKING_METER::PARKING_METER(PinName ManteLed, PinName UserLed, PinName HostLed, PinName Max232): _ManteLed(ManteLed), _UserLed(UserLed), _HostLed(HostLed), _Max232(Max232)
+{
+    _HostLed=0; 
+    _UserLed=0;
+    _HostLed=0;
+    _Max232=0;
+}
+
+void    PARKING_METER::AlarmCall(int Device,char State){
+    
+    // Esta funcion permite cambiar los valores de estados que son enviados al hosting.
+    // 1 -> Lector
+    // 2 -> Impresora
+    // 3 -> Papel
+    // 4 -> Puerta1
+    // 5 -> Puerta2
+    // 6 -> Bateria
+    
+    if(AlarmString[Device-1]!=State){
+        if(State=='E') {
+            printf("Alarmas cambio E");
+            AlarmString[Device-1]='E';
+            AlarmBool=1;
+        } else {
+            printf("Alarmas cambio A");
+            AlarmString[Device-1]='A';
+            AlarmBool=1;
+        }
+    }
+}
+
+bool    PARKING_METER::AlarmState(){
+    // Nos devuelve un valor true o false en caso de que alguna alarma inicie.
+    return AlarmBool;
+}
+
+void    PARKING_METER::Hosting(){
+    Counter_Host++;     
+    if(Counter_Host>Hostin_Conection) {
+        AlarmBool=1;     
+        Counter_Host=0; 
+    }    
+}
+
+char   PARKING_METER::HostingOk(){
+    AlarmBool=0; 
+}
+char    PARKING_METER::AlarmReader(){
+    return AlarmString[0];
+}
+    
+char    PARKING_METER::AlarmPrinter(){
+    return AlarmString[1];
+}
+    
+char    PARKING_METER::AlarmPaper(){
+    return AlarmString[2];
+}
+    
+char    PARKING_METER::AlarmDoor1(){
+    return AlarmString[3];
+}
+    
+char    PARKING_METER::AlarmDoor2(){
+    return AlarmString[4];
+}
+
+char    PARKING_METER::AlarmBattery(){
+    return AlarmString[5]; 
+}
+
+void    PARKING_METER::LedMantenimiento(bool StateLed){
+    _ManteLed=StateLed;
+}
+
+void    PARKING_METER::LedHosting(bool StateLed){
+    _HostLed=StateLed;
+}
+
+void    PARKING_METER::LedUsuario(bool StateLed){
+    _UserLed=StateLed;
+}
+
+void    PARKING_METER::Max232(bool StateMax){
+    _Max232=StateMax;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ParkingMeter.h	Tue Jun 04 16:03:14 2019 +0000
@@ -0,0 +1,41 @@
+#ifndef MBED_PARKINGMETER_H
+#define MBED_PARKINGMETER_H
+ 
+#include "mbed.h"
+ 
+class PARKING_METER {
+public:
+    PARKING_METER(PinName ManteLed, PinName UserLed, PinName HostLed, PinName Max232);
+    
+    // 1 -> Lector
+    // 2 -> Impresora
+    // 3 -> Papel
+    // 4 -> Puerta1
+    // 5 -> Puerta2
+    // 6 -> Bateria
+
+    void    AlarmCall(int Periferico,char Estado);
+    bool    AlarmState();
+    char    AlarmReader();
+    char    AlarmPrinter();
+    char    AlarmPaper();
+    char    AlarmDoor1();
+    char    AlarmDoor2();
+    char    AlarmBattery();
+    void    Hosting();
+    char    HostingOk();
+    void    LedMantenimiento(bool StateLed);
+    void    LedHosting(bool StateLed);
+    void    LedUsuario(bool StateLed);
+    void    Max232(bool StateMax);
+
+private: 
+    DigitalOut   _ManteLed;
+    DigitalOut   _HostLed;
+    DigitalOut   _UserLed;
+    DigitalOut   _Max232;
+};
+ 
+#endif
+ 
+ 
\ No newline at end of file