Esempio n. 1
0
        public static bool VerfuegbarePID(Messgroesse m, byte[] b)
        {
            try
            {
                string[] pidZerlegt = m.zugriff.Split(" ");
                byte     index      = byte.Parse(pidZerlegt[1], System.Globalization.NumberStyles.AllowHexSpecifier);

                System.Collections.BitArray bits = new System.Collections.BitArray(b); //umdrehen?

                var l = new List <String>();
                m.wert_string = "";

                for (int i = 0; i < 32; ++i)
                {
                    l.Add("PID " + pidZerlegt[0] + " " + (index + 1).ToString() + ": " + (bits[i] ? "Ja" : "Noi"));
                    m.wert_string += l[i] + "\n";
                }

                m.wert = l;

                return(true);
            }
            catch (Exception e)
            {
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("VerfuegbarePID erstellen Exception " + e.ToString());
                }
            }

            return(false);
        }
Esempio n. 2
0
 public static void Abfragen(string eintrag)
 {
     try
     {
         Abzufragen.Add(Erfassung.Groessen[eintrag]);
     }
     catch (Exception e)
     {
         if (Zugriff.DebugAusgabe)
         {
             Zugriff.Ausgabe("Abfragen Exception " + e.ToString());
         }
     }
 }
Esempio n. 3
0
        public static bool ErstelleKraftstoffdruck(Messgroesse m, byte[] b)
        {
            try
            {
                int druck = 3 * b[0];

                m.wert        = druck;
                m.wert_string = druck.ToString();
            }
            catch (Exception e)
            {
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("Kraftstoffdruck erstellen Exception " + e.ToString());
                }
            }

            return(false);
        }
Esempio n. 4
0
        public static bool ErstelleGaspedal(Messgroesse m, byte[] b)
        {
            try
            {
                float stellung = 100 / 255 * b[0];

                m.wert        = stellung;
                m.wert_string = stellung.ToString();
            }
            catch (Exception e)
            {
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("ErstelleGaspedal Exception " + e.ToString());
                }
            }

            return(false);
        }
Esempio n. 5
0
        public static bool ErstelleMassenstrom(Messgroesse m, byte[] b)
        {
            try
            {
                double strom = (256 * b[0] + b[1]) / 100;

                m.wert        = strom;
                m.wert_string = strom.ToString();
            }
            catch (Exception e)
            {
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("Massenstrom erstellen Exception " + e.ToString());
                }
            }

            return(false);
        }
Esempio n. 6
0
        public static void MessgroessenVerarbeitung(string nachricht)
        {
            if (nachricht.Contains("48 6B"))
            {
                string pid = nachricht.Substring(nachricht.IndexOf("48 6B") + ("48 6B 11 ").Length, 5);
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("Messgroessenverarbeitung PID: " + pid);
                }

                foreach (var g in Groessen)
                {
                    if (g.Value.schluessel == pid)
                    {
                        string antwort = nachricht.Substring(nachricht.IndexOf(pid) + pid.Length + 1);
                        if (Zugriff.DebugAusgabe)
                        {
                            Zugriff.Ausgabe("Messgroessenverarbeitung rufe Funktion für Antwort " + antwort);
                        }
                        if (g.Value.WertErstellen(antwort))
                        {
                            if (Zugriff.DebugAusgabe)
                            {
                                Zugriff.Ausgabe("Messgroessenverarbeitung Wert erstellt");
                                Zugriff.Ausgabe("Publishe " + g.Value.wert_string + " auf " + g.Value.benennung);
                            }

                            Zugriff.client.Publish(g.Value.benennung, g.Value.wert_string, OpenNETCF.MQTT.QoS.FireAndForget, false);
                        }
                        else
                        {
                            if (Zugriff.DebugAusgabe)
                            {
                                Zugriff.Ausgabe("Messgroessenverarbeitung kein Wert erstellt");
                            }
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 7
0
        public static bool ErstelleTempWasserUOel(Messgroesse m, byte[] b)
        {
            try
            {
                int temperatur = b[0] - 40;

                m.wert        = temperatur;
                m.wert_string = temperatur.ToString();

                return(true);
            }
            catch (Exception e)
            {
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("Temperatur erstellen Exception " + e.ToString());
                }
            }

            return(false);
        }
Esempio n. 8
0
        public static bool ErstelleDrehzahl(Messgroesse m, byte[] b)
        {
            try
            {
                int drehzahl = (256 * b[0] + b[1]) / 4;

                m.wert        = drehzahl;
                m.wert_string = drehzahl.ToString();

                return(true);
            }
            catch (Exception e)
            {
                if (Zugriff.DebugAusgabe)
                {
                    Zugriff.Ausgabe("Drehzahl erstellen Exception " + e.ToString());
                }
            }

            return(false);
        }