public ErrorLogger(SystemServices systemServices, String managerType, String managerDesc, String directory)
 {
     SystemServices = systemServices;
     ManagerType = managerType;
     ManagerDesc = managerDesc;
     Directory = directory;
 }
 public DeviceDisplay(ApplicationSettings settings, SystemServices services)
 {
     Settings = settings;
     //SystemServices = new SystemServices(settings.BuildFileName("PVBC.log"));
     SystemServices = services;
     DeviceList = new ObservableCollection<DeviceDisplayInfo>();
 }
 public ManageSubscription(GenThreadManager genThreadManager, SystemServices systemServices, 
     Subscriber.MyTransientSubscriber subscriber, IUpdateDials updateDials)
     : base(genThreadManager, systemServices)
 {
     Subscriber = subscriber;
     UpdateDials = updateDials;
 }
 public OwlDatabaseInfo(DeviceManagerSettings owlSettings, SystemServices systemServices)
 {
     Settings = owlSettings;
     SystemServices = systemServices;
     OwlDb = null;
     ApplianceListInternal = null;
 }
 public DeviceStream(GenThreadManagement.GenThreadManager genThreadManager, SystemServices systemServices)
 {
     Stream = null;
     ByteBuffer = null;
     SystemServices = systemServices;
     DeviceError = false;
     // use original threaded byte buffer
     GenThreadManager = genThreadManager;
 }
 public DeviceStream(SystemServices systemServices)
 {
     Stream = null;
     ByteBuffer = null;
     SystemServices = systemServices;
     DeviceError = false;
     // use new synchronous byte buffer
     GenThreadManager = null;
 }
Beispiel #7
0
        public ByteBuffer(SystemServices systemServices,
            DeviceStream.DeviceStream deviceStream, int localBufferSize = 10000)
        {
            DeviceStream = deviceStream;
            SystemServices = systemServices;

            LocalBuffer = new byte[localBufferSize];

            NextByteAvail = 0;
            BytesUsed = 0;
        }
        public PVPublisherService()
        {
            InitializeComponent();

            ApplicationSettings = new ApplicationSettings();
            SystemServices = new MackayFisher.Utilities.SystemServices(ApplicationSettings.BuildFileName("PVPublisher.log"));
            ApplicationSettings.SetSystemServices(SystemServices);

            LoadLogSettings();

            SystemServices.LogMessage("PVPublisher", "Service starting", LogEntryType.Information);
        }
        public EnergyEvents(ApplicationSettings settings, IDeviceManagerManager managerManager)
        {
            ApplicationSettings = settings;
            ManagerManager = managerManager;
            SystemServices = GlobalSettings.SystemServices;
            PVEventReadyEvent = new ManualResetEvent(false);
            NodeReaderWriterLock = new ReaderWriterLock();
            NodeUpdateMutex = new Mutex();
            PendingListMutex = new Mutex();

            PendingEvents = new List<EventPending>();
            LastEmitErrorReported = DateTime.MinValue;
        }
        public SerialStream(GenThreadManagement.GenThreadManager genThreadManager, SystemServices systemServices, String portName, int baudRate = 57600, Parity parity = Parity.None,
            int dataBits = 8, StopBits stopBits = StopBits.One, Handshake handshake = Handshake.None, int readTimeout = 3000, int writeTimeout = 20000)
            : base(genThreadManager, systemServices)
        {
            SerialPort = new SerialPort();
            PortName = portName;
            BaudRate = baudRate;
            DataBits = dataBits;
            StopBits = stopBits;
            Parity = parity;
            Handshake = handshake;
            ReadTimeout = readTimeout;
            WriteTimeout = writeTimeout;
            IsOpen = false;

            ConfigurePort();
        }
        public MainWindow()
        {
            InitializeComponent();
            Services = new SystemServices();
            GenThreadManager = new GenThreadManagement.GenThreadManager(Services);
            Services.LogMessageContent = true;
            Services.LogDetailTrace = true;
            Services.LogTrace = true;
            Converse = null;
            liveElement = null;
            histElements = null;
            rootElement = null;
            EmulatorThread = null;
            butSendHist.Visibility = System.Windows.Visibility.Hidden;
            buttonStop.IsEnabled = false;

            Emulators = new List<String>(EmulatorMatrix.GetLength(0));

            for (int i = 0; i < EmulatorMatrix.GetLength(0); i++)
            {
                Emulators.Add(EmulatorMatrix[i, 0]);
            }

            MainGrid.DataContext = this;
        }
 public GenThread(GenThreadManager genThreadManager, SystemServices systemServices)
 {
     SystemServices = systemServices;
     ConstructorCommon(systemServices);
     GenThreadManager = genThreadManager;
     IsRunning = false;
 }
 private void ConstructorCommon(SystemServices systemServices)
 {
     //SystemServices = systemServices;
     ExitEvent = new ManualResetEvent(false);
     ThreadNo = nextThreadNo++;
 }
Beispiel #14
0
        public static void FormatDump(byte[] buffer, int startByte, int length, SystemServices systemServices)
        {
            const int bytesPerLine = 40;

            int lines = (length + bytesPerLine - 1) / bytesPerLine;

            int start = startByte;
            int scale = GetScale(length);
            String format = "D" + scale.ToString();

            String header = PadString("", scale * 2 + 1); // spaces over position range - "     " for "00-19"

            if (lines > 1)
            {
                for (int i = 0; i < bytesPerLine; i++)
                    header += PadString(i.ToString(), 3, ' ', false);
                header += " ";
                for (int i = 0; i < bytesPerLine; i++)
                    header += (i % 10).ToString();
            }
            else
            {
                header = PadString("", scale * 2 + 1); // spaces over position range - "     " for "00-19"
                for (int i = 0; i < length; i++)
                    header += PadString(i.ToString(), 3, ' ', false);
                header += " ";
                for (int i = 0; i < length; i++)
                    header += (i % 10).ToString();
            }

            systemServices.LogMessage("", header, LogEntryType.Format);

            int pos = 0;
            int line = 0;
            while (line < lines)
            {
                int len;
                if ((pos + bytesPerLine) <= length)
                    len = bytesPerLine;
                else
                    len = length - pos;

                String lineRange = pos.ToString(format) + "-" + (pos+len-1).ToString(format);
                String hex = ByteBuffer.BytesToHex(buffer, " ", len, start);
                String ascii = ByteBuffer.BytesToAscii(buffer, "", len, start);
                if (line > 0 && len < bytesPerLine)
                {
                    hex = PadString(hex, (bytesPerLine * 3)-1);
                    ascii = PadString(ascii, bytesPerLine);
                }

                systemServices.LogMessage("", lineRange + " " + hex + " " + ascii, LogEntryType.Format);

                line++;
                pos += bytesPerLine;
                start += bytesPerLine;
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            Subscriber = null;
            BrushSelected = comboBoxLocalMachines.Background;
            BrushAvailable = comboBoxLocalMachines2.Background;

            visibleDispatcherTimer = new DispatcherTimer();
            visibleDispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            visibleDispatcherTimer.Interval = new TimeSpan(0, 0, 5);

            try
            {
                ApplicationSettings = new ApplicationSettings();
                LocateOrCreateDirectory(ApplicationSettings.DefaultDirectory);
                SystemServices = new MackayFisher.Utilities.SystemServices(ApplicationSettings.BuildFileName("PVMonitor.log"));
                ApplicationSettings.SetSystemServices(SystemServices);
                LoadLogSettings();

                Subscriber = new Subscriber.MyTransientSubscriber(SystemServices, this);
                expanderSettings.DataContext = Subscriber;
                stackPanelMain.DataContext = Subscriber;
                stackPanelGauges.DataContext = Subscriber;
                //listViewActiveEvents.ItemsSource = Subscriber.ActiveEvents;

                GenThreadManager = new GenThreadManager(SystemServices);
                ManageSubscription manageSubscription = new ManageSubscription(GenThreadManager, SystemServices, Subscriber, this);
                int threadId = GenThreadManager.AddThread(manageSubscription);
                GenThreadManager.StartThread(threadId);

                Rect bounds = Properties.Settings.Default.WindowPosition;
                this.Top = bounds.Top;
                this.Left = bounds.Left;
            }
            catch (Exception)
            {
            }
        }
 public TestDatabase(ApplicationSettings settings, SystemServices services)
 {
     Settings = settings;
     SystemServices = services;
 }
 //public override String DeviceName { get; set; }
 public BluetoothStream(GenThreadManagement.GenThreadManager genThreadManager, SystemServices systemServices)
     : base(genThreadManager, systemServices)
 {
 }
 public GenThreadManager(SystemServices systemServices)
 {
     Threads = new List<GenThreadInfo>();
     SystemServices = systemServices;
     AllStopped = new ManualResetEvent(true);
 }
        //public InverterManagerSettings DeviceInverterManagerSettings { get; private set; }
        public ApplicationSettings()
            : base("settings_v2.xml", "configuration", @"\settings_template_SE_SQLite.xml")
        {
            LegacySettingsNames.Add("settings.xml");

            LoadSettings(true);

            DeviceManagementSettings = new DeviceManagementSettings();

            SystemServices = null;

            _InitialSave = new GenericSetting<bool>(true, this, "InitialSave");
            _InitialCheck = new GenericSetting<bool>(true, this, "InitialCheck");
            _ServiceAccountName = new GenericSetting<string>("Local Service", this, "ServiceAccountName");
            _ServiceAccountPassword = new GenericSetting<string>("", this, "ServiceAccountPassword");
            _ServiceAccountRequiresPassword = new GenericSetting<bool>(false, this, "ServiceAccountRequiresPassword");
            _AutoStartPVBCService = new GenericSetting<bool>(true, this, "AutoStartPVBCService");
            _Host = new GenericSetting<string>("", this, "Host");
            _Database = new GenericSetting<string>("", this, "Database");
            _DatabaseType = new GenericSetting<string>("", this, "DatabaseType");
            _DatabaseVersion = new GenericSetting<string>("", this, "DatabaseVersion");
            _ProviderType = new GenericSetting<string>("", this, "ProviderType");
            _ProviderName = new GenericSetting<string>("", this, "ProviderName");
            _OleDbName = new GenericSetting<string>("", this, "OleDbName");
            _ConnectionString = new GenericSetting<string>("", this, "ConnectionString");
            _UserName = new GenericSetting<string>("", this, "UserName");
            _Password = new GenericSetting<string>("", this, "Password");
            _DefaultDirectory = new GenericSetting<string>("", this, "DefaultDirectory");
            _InverterLogs = new GenericSetting<string>("", this, "InverterLogs");
            _ServiceSuspendType = new GenericSetting<string>("", this, "ServiceSuspendType");
            _EveningSuspendType = new GenericSetting<string>("", this, "EveningSuspendType");
            _ServiceStartTime = new GenericSetting<TimeSpan?>(this, "ServiceStartTime");
            _ServiceStopTime = new GenericSetting<TimeSpan?>(this, "ServiceStopTime");
            _WakeDelay = new GenericSetting<Int32>(0, this, "WakeDelay");
            _IntervalStartTime = new GenericSetting<TimeSpan?>(this, "IntervalStartTime");
            _IntervalStopTime = new GenericSetting<TimeSpan?>(this, "IntervalStopTime");
            _InverterStartTime = new GenericSetting<TimeSpan?>(this, "InverterStartTime");
            _InverterStopTime = new GenericSetting<TimeSpan?>(this, "InverterStopTime");
            _MeterHistoryTimeLineAdjust = new GenericSetting<bool>(false, this, "MeterHistoryTimeLineAdjust");
            _MeterHistoryStartMinute = new GenericSetting<Int32?>(this, "MeterHistoryStartMinute");
            _MeterHistoryEndMinute = new GenericSetting<Int32?>(this, "MeterHistoryEndMinute");
            _ServiceWakeInterval = new GenericSetting<TimeSpan?>(this, "ServiceWakeInterval");
            _ServiceSuspendInterval = new GenericSetting<TimeSpan?>(this, "ServiceSuspendInterval");
            _SunnyExplorerPlantName = new GenericSetting<string>("", this, "SunnyExplorerPlantName");
            _FirstFullDay = new GenericSetting<DateTime?>(this, "FirstFullDay", DateStrings);
            _NewLogEachDay = new GenericSetting<bool>(true, this, "NewLogEachDay");
            _LogRetainDays = new GenericSetting<int?>(this, "LogRetainDays");
            _EnableIntervalSuspend = new GenericSetting<bool>(false, this, "EnableIntervalSuspend");
            _EnableEveningSuspend = new GenericSetting<bool>(false, this, "EnableEveningSuspend");
            _ManualSuspendAutoResume = new GenericSetting<bool>(false, this, "ManualSuspendAutoResume");
            _EmitEvents = new GenericSetting<bool>(false, this, "EmitEvents");
            _LogTrace = new GenericSetting<bool>(false, this, "LogTrace");
            _LogDatabase = new GenericSetting<bool>(false, this, "LogDatabase");
            _LogDetailTrace = new GenericSetting<bool>(false, this, "LogMeterTrace");
            _LogMessageContent = new GenericSetting<bool>(false, this, "LogMessageContent");
            _LogInformation = new GenericSetting<bool>(true, this, "LogInformation");
            _LogStatus = new GenericSetting<bool>(true, this, "LogStatus");
            _LogError = new GenericSetting<bool>(true, this, "LogError");
            _LogFormat = new GenericSetting<bool>(true, this, "LogFormat");
            _LogEvent = new GenericSetting<bool>(false, this, "LogEvent");

            LoadSettingsSub();
            ServiceAccountPassword = "";
            ServiceDetailsChanged = false;
            LoadingEnergyEvents = false;

            CheckProtocolDeviceGroups();

            _DatabaseVersions = new ObservableCollection<string>();
            SelectDatabaseVersions();
        }
 public void SetSystemServices(SystemServices systemServices)
 {
     bool oldChangedState = ServiceDetailsChanged;
     SystemServices = systemServices;
     ServiceDetailsChanged = oldChangedState;
 }
 public void UpdateEnergy(SystemServices services)
 {
     DateTime now = DateTime.Now;
     TimeSpan elapsed = now - LastTime;
     Etime = Etime.Add(elapsed);
     LastTime = now;
     PowerPV = PowerFromTime(Etime, 10000.0) * PowerScale;
     PowerAC = PowerPV * 0.95;
     //Double energy = (PowerAC / 1000.0) * elapsed.TotalHours * EnergyScale / PowerScale;
     Double energy = (PowerAC / 1000.0) * elapsed.TotalHours * EnergyScale / PowerScale;
     EToday += energy;
     ETotal += (PowerAC / 1000.0) * elapsed.TotalHours * EnergyTotalScale / PowerScale;
     if (PowerPV > 0.0)
     {
         VoltagePV = 300.0 * VoltageScale;
         CurrentPV = ((PowerPV / PowerScale) / (VoltagePV / VoltageScale)) * CurrentScale;
         CurrentAC = ((PowerAC / PowerScale) / (VoltageAC / VoltageScale)) * CurrentScale;
     }
     else
     {
         CurrentAC = 0.0;
         VoltagePV = 0.0;
         CurrentPV = 0.0;
         PowerAC = 0.0;
         PowerPV = 0.0;
     }
     services.LogMessage("UpdateEnergy", "Power: " + PowerAC +
         " - Duration: " + elapsed.TotalSeconds + " - Energy: " + (energy / EnergyScale) + " - EnergyTotal: " + (EToday / EnergyScale), LogEntryType.Information);
 }
 public CheckEnvironment(ApplicationSettings settings, SystemServices services)
 {
     Settings = settings;
     SystemServices = services;
 }