Exemple #1
0
        public Power(HanReader han)
        {
            PackageTime         = han.getPackageTime();
            MeterID             = han.getString((int)Kamstrup.Kamstrup_List1.MeterID);
            MeterType           = han.getString((int)Kamstrup.Kamstrup_List1.MeterType);
            ActiveImportPower   = han.getInt((int)Kamstrup.Kamstrup_List1.ActiveImportPower);
            ActiveExportPower   = han.getInt((int)Kamstrup.Kamstrup_List1.ActiveExportPower);
            ReactiveImportPower = han.getInt((int)Kamstrup.Kamstrup_List1.ReactiveImportPower);
            ReactiveExportPower = han.getInt((int)Kamstrup.Kamstrup_List1.ReactiveExportPower);

            CurrentL1 = han.getInt((int)Kamstrup.Kamstrup_List1.CurrentL1) / 100.0M;
            CurrentL2 = han.getInt((int)Kamstrup.Kamstrup_List1.CurrentL2) / 100.0M;
            CurrentL3 = han.getInt((int)Kamstrup.Kamstrup_List1.CurrentL3) / 100.0M;

            VoltageL1 = han.getInt((int)Kamstrup.Kamstrup_List1.VoltageL1);
            VoltageL2 = han.getInt((int)Kamstrup.Kamstrup_List1.VoltageL2);
            VoltageL3 = han.getInt((int)Kamstrup.Kamstrup_List1.VoltageL3);
        }
Exemple #2
0
        public Energy(HanReader han)
        {
            PackageTime         = han.getTime((int)Kamstrup.Kamstrup_List2.MeterClock);
            MeterID             = han.getString((int)Kamstrup.Kamstrup_List2.MeterID);
            MeterType           = han.getString((int)Kamstrup.Kamstrup_List2.MeterType);
            ActiveImportPower   = han.getInt((int)Kamstrup.Kamstrup_List2.ActiveImportPower);
            ActiveExportPower   = han.getInt((int)Kamstrup.Kamstrup_List2.ActiveExportPower);
            ReactiveImportPower = han.getInt((int)Kamstrup.Kamstrup_List2.ReactiveImportPower);
            ReactiveExportPower = han.getInt((int)Kamstrup.Kamstrup_List2.ReactiveExportPower);

            CurrentL1 = han.getInt((int)Kamstrup.Kamstrup_List2.CurrentL1) / 100.0M;
            CurrentL2 = han.getInt((int)Kamstrup.Kamstrup_List2.CurrentL2) / 100.0M;
            CurrentL3 = han.getInt((int)Kamstrup.Kamstrup_List2.CurrentL3) / 100.0M;

            VoltageL1 = han.getInt((int)Kamstrup.Kamstrup_List2.VoltageL1);
            VoltageL2 = han.getInt((int)Kamstrup.Kamstrup_List2.VoltageL2);
            VoltageL3 = han.getInt((int)Kamstrup.Kamstrup_List2.VoltageL3);

            CumulativeActiveImportEnergy = han.getInt((int)Kamstrup.Kamstrup_List2.CumulativeActiveImportEnergy) / 100.0M;;
            CumulativeActiveExportEnergy = han.getInt((int)Kamstrup.Kamstrup_List2.CumulativeActiveExportEnergy) / 100.0M;;

            CumulativeReactiveImportEnergy = han.getInt((int)Kamstrup.Kamstrup_List2.CumulativeReactiveImportEnergy) / 100.0M;
            CumulativeReactiveExportEnergy = han.getInt((int)Kamstrup.Kamstrup_List2.CumulativeReactiveExportEnergy) / 100.0M;
        }
Exemple #3
0
        static void Main(string[] args)
        {
            DayAheadPrice prices = new DayAheadPrice();

            prices.GetDayAhead();


            log4net.Config.XmlConfigurator.Configure();
            System.IO.Ports.SerialPort p = new System.IO.Ports.SerialPort();

            var persist = true;
            var comPort = "COM3";

            if (args.Length < 2)
            {
                Console.WriteLine("Usage: ");
                Console.WriteLine("\t AMS_2 [COMX] [PERSIST | NOPERSIST]");
                Console.WriteLine();
                Console.WriteLine("Using Persist without the DB installed *will* fail!");
            }
            else
            {
                if (!args[1].Trim().ToUpper().Equals("PERSIST"))
                {
                    persist = false;
                }

                comPort = args[0].Trim().ToUpper();

                HanReader han = new HanReader();
                han.setup(p, comPort, 2400);

                while (true)
                {
                    // Read one byte from the port, and see if we got a full package
                    if (han.read())
                    {
                        // Get the list identifier
                        int listSize = han.getListSize();

                        log.Debug("");
                        log.Debug("List size: ");
                        log.Debug(listSize);
                        log.Debug(": ");

                        // Only care for the ACtive Power Imported, which is found in the first list
                        if (listSize == (int)Kamstrup.KamstrupLists.List1)
                        {
                            Console.ForegroundColor = ConsoleColor.White;
                            Power pwr = new Power(han);
                            if (persist)
                            {
                                pwr.Save();
                            }
                            Console.WriteLine(pwr.ToString());
                        }
                        else if (listSize == (int)Kamstrup.KamstrupLists.List2)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Energy energy = new Energy(han);
                            if (persist)
                            {
                                energy.Save();
                            }
                            Console.WriteLine(energy.ToString());
                        }
                    }
                }
            }
        }