コード例 #1
0
        private DataCurveTriggerSettings GetSettingsFromTriggerInfo(IPlugInAPI.strTrigActInfo triggerInfo)
        {
            _triggerInfo = triggerInfo;
            var formattedAction = _collectionFactory.GetActionsIfPossible(triggerInfo);

            if (formattedAction != null)             //&& formattedAction.Keys.Count > 0)
            {
                var uidAndEvRef = $"{triggerInfo.UID.ToString()}_{triggerInfo.evRef.ToString()}_";

                formattedAction = _reformatCopiedAction.Run(formattedAction, triggerInfo.UID, triggerInfo.evRef);
                var triggerSettings = new DataCurveTriggerSettings();
                triggerSettings.UID   = triggerInfo.UID;
                triggerSettings.EvRef = triggerInfo.evRef;
                foreach (var dataKey in formattedAction.Keys)
                {
                    //if (dataKey.Contains(Constants.EvRef))
                    //{
                    //	triggerSettings.EvRef =
                    //		ParameterExtraction.GetIntOrMinusOneFromObject(formattedAction[dataKey]);
                    //}

                    //if (dataKey.Contains(Constants.Uid))
                    //{
                    //	triggerSettings.UID =
                    //		ParameterExtraction.GetIntOrMinusOneFromObject(formattedAction[dataKey]);
                    //}

                    if (dataKey.Contains(Constants.DeviceDropdownKey))
                    {
                        triggerSettings.DeviceIdChosen =
                            ParameterExtraction.GetIntOrNullFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.RoomKey))
                    {
                        triggerSettings.RoomChosen = (string)(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.FloorKey))
                    {
                        triggerSettings.FloorChosen = (string)(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.IsConditionKey))
                    {
                        triggerSettings.IsCondition = ParameterExtraction.GetBoolFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.TimeSpanKey))
                    {
                        triggerSettings.TimeSpanChosen = ParameterExtraction.GetTimeSpanFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.AscDescKey))
                    {
                        triggerSettings.AscendingOrDescending = ParameterExtraction.GetAscDescEnumFromObject(formattedAction[dataKey]);
                    }
                    if (dataKey.Contains(Constants.CheckIfUseFutureComputationKey))
                    {
                        triggerSettings.UseFutureComputation = ParameterExtraction.GetBoolFromObject(formattedAction[dataKey]);
                    }
                    if (dataKey.Contains(Constants.FutureTimeSpanKey))
                    {
                        triggerSettings.FutureComputationTimeSpan = ParameterExtraction.GetTimeSpanFromObject(formattedAction[dataKey]);
                    }
                    if (dataKey.Contains(Constants.ThresholdValueKey))
                    {
                        triggerSettings.FutureThresholdValue = ParameterExtraction.GetDoubleOrNull(formattedAction[dataKey]);
                    }
                }

                _triggerSettings = triggerSettings;

                return(triggerSettings);
            }

            return(null);
        }
コード例 #2
0
        private DataCurveTriggerBSettings GetSettingsFromTriggerInfo(IPlugInAPI.strTrigActInfo triggerInfo)
        {
            _triggerInfo = triggerInfo;
            var formattedAction = _collectionFactory.GetActionsIfPossible(triggerInfo);

            if (formattedAction != null) //&& formattedAction.Keys.Count > 0)
            {
                var uidAndEvRef = $"{triggerInfo.UID.ToString()}_{triggerInfo.evRef.ToString()}_";

                formattedAction = _reformatCopiedAction.Run(formattedAction, triggerInfo.UID, triggerInfo.evRef);
                var triggerSettings = new DataCurveTriggerBSettings();
                triggerSettings.UID   = triggerInfo.UID;
                triggerSettings.EvRef = triggerInfo.evRef;
                foreach (var dataKey in formattedAction.Keys)
                {
                    if (dataKey.Contains(Constants.DeviceDropdownKey))
                    {
                        triggerSettings.DeviceIdChosen =
                            ParameterExtraction.GetIntOrNullFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.RoomKey))
                    {
                        triggerSettings.RoomChosen = (string)(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.FloorKey))
                    {
                        triggerSettings.FloorChosen = (string)(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.IsConditionKey))
                    {
                        triggerSettings.IsCondition = ParameterExtraction.GetBoolFromObject(formattedAction[dataKey]);
                    }


                    if (dataKey.Contains(Constants.AscDescKey))
                    {
                        triggerSettings.AscendingOrDescending = ParameterExtraction.GetAscDescEnumFromObject(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.ThresholdValueKey))
                    {
                        triggerSettings.ThresholdValue = ParameterExtraction.GetDoubleOrNull(formattedAction[dataKey]);
                    }

                    if (dataKey.Contains(Constants.NumberOfLastMeasurementsKey))
                    {
                        var numberOfLastMeasurements =
                            ParameterExtraction.GetIntOrNullFromObject(formattedAction[dataKey]);
                        if (numberOfLastMeasurements >= 2)
                        {
                            triggerSettings.NumberOfLastMeasurements = numberOfLastMeasurements;
                        }
                    }
                }

                _triggerSettings = triggerSettings;

                return(triggerSettings);
            }

            return(null);
        }