Exemplo n.º 1
0
        private void SaveAdhocMeasurement(string value, string comment, AdhocParameter adhocParameter, int smId)
        {
            AdhocMeasurement AHM = context.AdhocMeasurements.FirstOrDefault(h => h.AdhocParameter.Id == adhocParameter.Id && h.SystemMeasurement.Id == smId);

            if (AHM == null)
            {
                AHM                   = new AdhocMeasurement();
                AHM.Value             = value;
                AHM.Comment           = comment;
                AHM.IsApplicable      = true;
                AHM.SystemMeasurement = context.SystemMeasurements.FirstOrDefault(smt => smt.Id == smId);
                AHM.AdhocParameter    = adhocParameter;
                adhocParameter.AdhocMeasurements.Add(AHM);
            }
            else
            {
                AHM.Value        = value;
                AHM.Comment      = comment;
                AHM.IsApplicable = true;
            }
        }
Exemplo n.º 2
0
        private AdhocParameter SaveAdhocParameter(string unit, string source, string name, int type, int buildingSystemId)
        {
            AdhocParameter ahp = context.AdhocParameters.FirstOrDefault(x => x.BuildingSystem.Id == buildingSystemId && x.Name == name && x.Source == source);

            if (ahp == null)
            {
                ahp                = new AdhocParameter();
                ahp.Unit           = unit;
                ahp.Source         = source;
                ahp.Name           = name;
                ahp.Type           = context.ParameterTypes.FirstOrDefault(PR => PR.Id == type);
                ahp.BuildingSystem = context.BuildingSystems.FirstOrDefault(x => x.Id == buildingSystemId);
                context.AdhocParameters.Add(ahp);
            }
            else
            {
                ahp.Unit   = unit;
                ahp.Source = source;
                ahp.Name   = name;
            }
            return(ahp);
        }
Exemplo n.º 3
0
        private void SaveParameterBound(string range, string type, decimal?minValue, decimal?maxValue, AdhocParameter adhocParameter)
        {
            ParameterBound APB = adhocParameter.ParameterBounds.FirstOrDefault();

            if (APB == null)
            {
                APB                = new ParameterBound();
                APB.IsEnforced     = true;
                APB.MaxValue       = maxValue;
                APB.MinValue       = minValue;
                APB.Type           = type;
                APB.Range          = range;
                APB.AdhocParameter = adhocParameter;
                adhocParameter.ParameterBounds.Add(APB);
            }
            else
            {
                APB.IsEnforced     = true;
                APB.MaxValue       = maxValue;
                APB.MinValue       = minValue;
                APB.Type           = type;
                APB.Range          = range;
                APB.AdhocParameter = adhocParameter;
            }
        }