Ejemplo n.º 1
0
        /// <summary>
        /// Converts this instance of <see cref="restrictionDto"/> to an instance of <see cref="restriction"/>.
        /// </summary>
        /// <param name="dto"><see cref="restrictionDto"/> to convert.</param>
        public static restriction ToEntity(this restrictionDto dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new restriction();

            entity.v_RestrictionId          = dto.v_RestrictionId;
            entity.v_DiagnosticRepositoryId = dto.v_DiagnosticRepositoryId;
            entity.v_ServiceId            = dto.v_ServiceId;
            entity.v_ComponentId          = dto.v_ComponentId;
            entity.v_MasterRestrictionId  = dto.v_MasterRestrictionId;
            entity.d_StartDateRestriction = dto.d_StartDateRestriction;
            entity.d_EndDateRestriction   = dto.d_EndDateRestriction;
            entity.i_IsDeleted            = dto.i_IsDeleted;
            entity.i_InsertUserId         = dto.i_InsertUserId;
            entity.d_InsertDate           = dto.d_InsertDate;
            entity.d_UpdateDate           = dto.d_UpdateDate;
            entity.i_UpdateUserId         = dto.i_UpdateUserId;

            dto.OnEntity(entity);

            return(entity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts this instance of <see cref="restriction"/> to an instance of <see cref="restrictionDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="restriction"/> to convert.</param>
        public static restrictionDto ToDTO(this restriction entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new restrictionDto();

            dto.v_RestrictionId          = entity.v_RestrictionId;
            dto.v_DiagnosticRepositoryId = entity.v_DiagnosticRepositoryId;
            dto.v_ServiceId            = entity.v_ServiceId;
            dto.v_ComponentId          = entity.v_ComponentId;
            dto.v_MasterRestrictionId  = entity.v_MasterRestrictionId;
            dto.d_StartDateRestriction = entity.d_StartDateRestriction;
            dto.d_EndDateRestriction   = entity.d_EndDateRestriction;
            dto.i_IsDeleted            = entity.i_IsDeleted;
            dto.i_InsertUserId         = entity.i_InsertUserId;
            dto.d_InsertDate           = entity.d_InsertDate;
            dto.d_UpdateDate           = entity.d_UpdateDate;
            dto.i_UpdateUserId         = entity.i_UpdateUserId;

            entity.OnDTO(dto);

            return(dto);
        }
Ejemplo n.º 3
0
    private string makeString(ref restriction rest)
    {
        string s = (rest.indexes[0] == 0)? "" : "" + rest.indexes[0] + "*x1";

        for (int i = 1, l = rest.indexes.Length; i < l; i++)
        {
            string tmp = "";
            if (rest.indexes[i] == 0)
            {
                continue;
            }
            tmp += (rest.indexes[i] < 0) ? "-" + Math.Abs(rest.indexes[i]) : "+" + rest.indexes[i];
            s   += tmp + "*x" + (i + 1);
        }
        if (rest.type == 0)
        {
            s += "<=";
        }
        else if (rest.type == 1)
        {
            s += "=";
        }
        else
        {
            s += ">=";
        }
        s += rest.b;
        return(s);
    }
Ejemplo n.º 4
0
        public static int Methodtwo(int param)
        {
            restriction rx          = restrictionMethod;
            int         returnValue = rx(param, "Methodtwo");

            return(returnValue);
        }
Ejemplo n.º 5
0
        private IEnumerable <RestrictionCollection> GetRestrictionSections(stream s)
        {
            var restrictionSections = s.restriction_section.GroupBy(r => r.restriction).ToList();

            foreach (var restrictionSection in restrictionSections)
            {
                var         restrictionCollection = new RestrictionCollection();
                restriction restrictionType       = restrictionSection.Key;
                restrictionCollection.FullText  = restrictionType.legal_text;
                restrictionCollection.ShortText = restrictionType.short_text;
                restrictionCollection.Id        = restrictionType.id;

                var x = restrictionSection.Select(i => new RestrictionSection
                {
                    Start = decimal.Round((decimal)i.start, 3, MidpointRounding.AwayFromZero),
                    Stop  = decimal.Round((decimal)i.stop, 3, MidpointRounding.AwayFromZero)
                }).ToList();

                var numberOfSections = x.Count;

                var shortSections = x.Where(i =>
                {
//                    var isStartOrEnd = i.Start == 0.0M || NearlyEquals(i.Stop, s.length_mi, 0.001M);
//                    if (isStartOrEnd == false)
//                    {
//                        return true;
//                    }

                    var length           = Math.Abs(i.Stop - i.Start);
                    var isTooShort       = length < 0.02M;
                    var isTooFewSections = numberOfSections <= 1;

                    if (isTooShort)
                    {
                        if (isTooFewSections)
                        {
                            return(false);
                        }
                    }

                    return(true);
                }).ToList();

                if (shortSections.Any() == false)
                {
                    continue;
                }

                restrictionCollection.Sections = shortSections;

                yield return(restrictionCollection);
            }
        }
Ejemplo n.º 6
0
    public void getValues()
    {
        string mFunc = mainFunc.transform.Find("aInp").GetComponent <TMP_InputField>().text;

        mFunc = mFunc.TrimEnd(' ');
        mFunc = mFunc.TrimStart(' ');
        mFunc = mFunc.Replace("−", "-").Replace(".", ",");
        double[] mFuncInd = new double[mainCtrl.totalVariables];
        //float mFuncConst = float.Parse(mainFunc.transform.Find("cInp").GetComponent<TMP_InputField>().text.Replace("−", "-").Replace(".", ","));
        //mainCtrl.mFunConst = mFuncConst;
        string tmp = "";

        for (int i = 0, k = 0, l = mFunc.Length; i < l && k < mainCtrl.totalVariables; i++)
        {
            if (mFunc[i] == ' ' && i != l - 1)
            {
                mFuncInd[k] = double.Parse(tmp);
                tmp         = "";
                k++;
            }
            else
            {
                tmp += mFunc[i];
            }
        }
        mFuncInd[mainCtrl.totalVariables - 1] = double.Parse(tmp);
        mainCtrl.indexesMain = mFuncInd;
        TMP_Dropdown dir = mainFunc.transform.Find("direction").GetComponent <TMP_Dropdown>();

        if (dir.value > 0)
        {
            mainCtrl.toMax = false;
        }
        else
        {
            mainCtrl.toMax = true;
        }
        restriction[] restrictions = new restriction[mainCtrl.totalRestrictions];
        int           it           = 0;

        foreach (Transform child in restrContent.transform)
        {
            restrictions[it++] = parseRest(child);
        }
        mainCtrl.rests = restrictions;
        workScreen.SetActive(false);
        resultScreen.SetActive(true);
        //gameObject.SetActive(false);
    }
Ejemplo n.º 7
0
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="restriction"/> converted from <see cref="restrictionDto"/>.</param>
 static partial void OnEntity(this restrictionDto dto, restriction entity);
Ejemplo n.º 8
0
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="restrictionDto"/> converted from <see cref="restriction"/>.</param>
 static partial void OnDTO(this restriction entity, restrictionDto dto);
Ejemplo n.º 9
0
        public string generarJson(List <Dispositivo> LDE, List <Dispositivo> LDI)
        {
            vars = new List <double>();                       //obj es el objeto q se pasa a json
            int           dispTotales = LDE.Count() + LDI.Count();
            List <double> v           = getVars(dispTotales); //se hace la primera fila del archivo json

            vars = v;
            List <double> values1 = new List <double>(); //esta es la primera fila de valores de la parte de "restricciones"

            values1.Add(612);                            //consumo total = 620z
            foreach (var de in LDE)
            {
                values1.Add(de.KWxHora); //se llena la lista con los kwxh de los dispositivos estandars
            }
            foreach (var di in LDI)
            {
                values1.Add(di.KWxHora);//se llena la lista con los kwxh de los dispositivos inteligentes
            }

            restriction restriccion1 = new restriction(values1, "<="); //primera restriccion

            restrictions = new List <restriction>();
            restrictions.Add(restriccion1);

            int contador = 1;

            foreach (var de in LDE)
            {
                if (de.Max > 0)
                {
                    List <double> vv = generarValues(dispTotales, contador, 1, de.Max);    //hay que agregarle a cada dispositivo max y min y numeros de referencia
                    restriction   r  = new restriction(vv);
                    restrictions.Add(r);
                    //se crea nueva restriccion para el maximo
                }
                if (de.Min > 0)
                {
                    List <double> vv = generarValues(dispTotales, contador, 0, de.Min);    //hay que agregarle a cada dispositivo max y min y numeros de referencia
                    restriction   r  = new restriction(vv);
                    restrictions.Add(r);
                    //se crea nueva restriccion para el minimo
                }
                contador++;
            }

            foreach (var di in LDI) //lo mismo q la anterior pero para inteligentes
            {
                if (di.Max > 0)
                {
                    List <double> vv = generarValues(dispTotales, contador, 1, di.Max);
                    restriction   r  = new restriction(vv);
                    restrictions.Add(r);
                }
                if (di.Min > 0)
                {
                    List <double> vv = generarValues(dispTotales, contador, 0, di.Min);
                    restriction   r  = new restriction(vv);
                    restrictions.Add(r);
                }
                contador++;
            }
            string jsonData = JsonConvert.SerializeObject(this);

            return(jsonData.Replace("operador", "operator"));
        }