示例#1
0
 public SampleSettingsCollection() : base()
 {
     SampleIntSetting    = new GenericSetting <int>(12);
     SampleStringSetting = new GenericSetting <string>("Not Assigned");
     SampleEnumSetting   = new GenericSetting <SampleEnum>(SampleEnum.Value2);
     SampleNested        = new GenericSetting <SampleComplexClass>(new SampleComplexClass());
 }
        public DeviceManagerSettings(ApplicationSettings root, XmlElement element)
            : base(root, element)
        {
            ApplicationSettings = (ApplicationSettings)root;
            SerialPort = null;

            _DeviceGroupName = new GenericSetting<String>("", this, "DeviceGroupName");
            _Enabled = new GenericSetting<bool>(true, this, "Enabled");
            _Name = new GenericSetting<String>("", this, "Name");

            String deviceGroupName = DeviceGroupName;
            DeviceGroup = ApplicationSettings.DeviceManagementSettings.GetDeviceGroup(deviceGroupName);
            ProtocolSettings = ApplicationSettings.DeviceManagementSettings.GetProtocol(DeviceGroup.Protocol);

            LoadDetails();
        }
        public override void HandleType(ComponentTypeWithData componentType, BSMLParserParams parserParams)
        {
            GenericSetting genericSetting = componentType.component as GenericSetting;

            if (componentType.data.TryGetValue("formatter", out string formatterId))
            {
                if (!parserParams.actions.TryGetValue(formatterId, out BSMLAction formatter))
                {
                    throw new Exception("formatter action '" + formatter + "' not found");
                }

                genericSetting.formatter = formatter;
            }

            if (componentType.data.TryGetValue("applyOnChange", out string applyOnChange))
            {
                genericSetting.updateOnChange = Parse.Bool(applyOnChange);
            }

            if (componentType.data.TryGetValue("onChange", out string onChange))
            {
                if (!parserParams.actions.TryGetValue(onChange, out BSMLAction onChangeAction))
                {
                    throw new Exception("on-change action '" + onChange + "' not found");
                }

                genericSetting.onChange = onChangeAction;
            }

            if (componentType.data.TryGetValue("value", out string value))
            {
                if (!parserParams.values.TryGetValue(value, out BSMLValue associatedValue))
                {
                    throw new Exception("value '" + value + "' not found");
                }

                genericSetting.associatedValue = associatedValue;
            }

            parserParams.AddEvent(componentType.data.TryGetValue("setEvent", out string setEvent) ? setEvent : "apply", genericSetting.ApplyValue);
            parserParams.AddEvent(componentType.data.TryGetValue("getEvent", out string getEvent) ? getEvent : "cancel", genericSetting.ReceiveValue);
        }
        //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();
        }
示例#5
0
 public ExtendedSampleSettings() : base()
 {
     ExtendedSampleDecimal     = new GenericSetting <decimal>(1.25m);
     ExtendedSampleStringArray = new GenericSetting <string[]>(new string[] { "abc", "cde" });
 }