Exemplo n.º 1
0
        public async Task <IHttpActionResult> PutCables(string id, Cables cables)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cables.TypeID)
            {
                return(BadRequest());
            }

            db.Entry(cables).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CablesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> PostCables(Cables cables)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Cables.Add(cables);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (CablesExists(cables.TypeID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cables.TypeID }, cables));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clears (removes) all assignments from the specified group.
        /// </summary>
        public void Clear()
        {
            foreach (var point in Points)
            {
                Remove(point);
            }

            foreach (var frame in Frames)
            {
                Remove(frame);
            }

            foreach (var area in Areas)
            {
                Remove(area);
            }

            foreach (var link in Links)
            {
                Remove(link);
            }

            Points.Clear();
            Frames.Clear();
            Areas.Clear();
            Links.Clear();
            Cables.Clear();
            Tendons.Clear();
            Solids.Clear();
        }
Exemplo n.º 4
0
        public async Task <IHttpActionResult> GetCables(string id)
        {
            Cables cables = await db.Cables.FindAsync(id);

            if (cables == null)
            {
                return(NotFound());
            }

            return(Ok(cables));
        }
Exemplo n.º 5
0
 public bool HasInputAnchor(Anchor target)
 {
     if (IsInput)
     {
         return(Cables.Any(c => c.HasInputAnchor(target)));
     }
     else
     {
         return(Gate.HasInputAnchor(target));
     }
 }
Exemplo n.º 6
0
    void Start()
    {
        airp = GameObject.Find("Airports").GetComponent <Airports>();
        ctr  = GameObject.Find("Input Controller").GetComponent <Controller>();
        sd   = GameObject.Find("StraightDist").GetComponent <StraightDist>();
        cbl  = GameObject.Find("FiberCables").GetComponent <Cables>();

        textStraightDist.text = "Please select origin and destination.\n" +
                                "You can also select a submarine cable for comparison.\n" +
                                "Visit www.submarinecablemap.com to browse cables.";
    }
Exemplo n.º 7
0
        public async Task <IHttpActionResult> DeleteCables(string id)
        {
            Cables cables = await db.Cables.FindAsync(id);

            if (cables == null)
            {
                return(NotFound());
            }

            db.Cables.Remove(cables);
            await db.SaveChangesAsync();

            return(Ok(cables));
        }
Exemplo n.º 8
0
        public IActionResult CreateInitialEquipment()
        {
            var equipment = new Equipments {
                IdtNumber = "A0002", Description = "Une simple Description 2", Revision = "Revision B", SuiviAsm = "Ajout", ProjectId = 7
            };

            _context.Equipments.Add(equipment);
            _context.SaveChanges();


            var _equipmentId = equipment.Id;

            var area = new Areas {
                PIDReference = "Initial Reference 2", NumeroZone = "Initial Zone", File = " ", ZoneProcess = " ", Atelier = "Initial Atelier", SousAtelier = "Initial Sous Atelier", EquipmentId = _equipmentId
            };
            var operatinInformation = new OperatingInformations {
                MoteurImerge = false, Atex = "2", Package = false, BackupGenset = false, Vfd = false, BackupInverter = false, Etat = "En cours", PackageTypique = "Initial Package Typique", EquipmentId = _equipmentId
            };
            var electricalDistribution = new ElectricalDistributions {
                Transfo = "Initial Transfo 2", TgbtLocation = "Initial TgbtLocation", MccLocation = "Initial MccLocation", DepartType = 1, AlimentationElectrique = 1, Intensite = 1, CosPhi = 1, EquipmentId = _equipmentId
            };
            var powerFeature = new PowerFeatures {
                NominalInstalledPower = 1, MechanicalPowerDemand = 1, MotorEfficiency = 1, MotorEfficiencyClass = "E1", InstalledAbsorbedPowerDp = 1, DutyAbsorbedPower = 1, EquipmentId = _equipmentId
            };
            var cable = new Cables {
                TypeCablePuissance = "Initial Type Cable Puissance 2", SectionCable = 1, NombreCable = 1, TypeProtection = "Initial TypeProtection", TypeCableProtection = "Initial Type Cable Protection", TypeCableCommande = "Initial Type Cable commande", LongueurCable = 1, EquipmentId = _equipmentId
            };
            var thermalDissipation = new ThermalDissipations {
                HeatDissipation = 2, HVAC = 1, EquipmentId = _equipmentId
            };

            _context.Areas.Add(area);
            _context.OperaOperatingInformations.Add(operatinInformation);
            _context.ElectricalDistributions.Add(electricalDistribution);
            _context.PowerFeatures.Add(powerFeature);
            _context.Cables.Add(cable);
            _context.ThermalDissipations.Add(thermalDissipation);

            _context.SaveChanges();

            return(StatusCode(201));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Clears (removes) all assignments from the specified group.
        /// </summary>
        /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
        public void Clear()
        {
#if !BUILD_ETABS2015 && !BUILD_ETABS2016 && !BUILD_ETABS2017
            _app?.Model.Definitions.Groups.Clear(Name);
#else
            //Node
            foreach (var point in Points)
            {
                Remove(point);
            }
            //Frame
            foreach (var frame in Frames)
            {
                Remove(frame);
            }
            //Area
            foreach (var area in Areas)
            {
                Remove(area);
            }
            //Link
            foreach (var link in Links)
            {
                Remove(link);
            }
#endif
            Points.Clear();
            Frames.Clear();
            Areas.Clear();
            Links.Clear();
#if !BUILD_ETABS2015 && !BUILD_ETABS2016 && !BUILD_ETABS2017
            Cables.Clear();
            Tendons.Clear();
            Solids.Clear();
#endif
        }
Exemplo n.º 10
0
 /// <summary>
 /// Removes objects from the group.
 /// </summary>
 /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
 public void Remove(Cable item)
 {
     setGroupAssign(item, remove: true);
     Cables.Remove(item);
 }
Exemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     my_Cables_script = my_Cables.GetComponent <Cables>();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Removes objects from the group.
 /// </summary>
 public void Remove(Cable item)
 {
     Cables.Remove(item);
     item.RemoveFromGroup(this);
 }
Exemplo n.º 13
0
        public IActionResult CreateSpecificEquipment([FromBody] JObject item)
        {
            var equipment = new Equipments();

            //TODO CHANGE Equipment Id

            JObject dataObject    = item;
            string  dataObjectStr = dataObject.ToString();
            var     equipmentData = JsonConvert.DeserializeObject <EquipmentDesc>(dataObjectStr);

            //Le groupe d'un equipment est facultatif
            if (equipmentData.Infos.GroupeId == 0)
            {
                equipment = new Equipments {
                    IdtNumber = equipmentData.Infos.IdtNumber, Description = equipmentData.MotorizedEquipments.Description,
                    Revision  = equipmentData.MotorizedEquipments.Revision, SuiviAsm = equipmentData.MotorizedEquipments.Revision,
                    GroupeId  = null, ProjectId = equipmentData.Infos.ProjectId
                };
            }
            else
            {
                equipment = new Equipments {
                    IdtNumber = equipmentData.Infos.IdtNumber, Description = equipmentData.MotorizedEquipments.Description,
                    Revision  = equipmentData.MotorizedEquipments.Revision, SuiviAsm = equipmentData.MotorizedEquipments.SuiviAsm, GroupeId = equipmentData.Infos.GroupeId, ProjectId = equipmentData.Infos.ProjectId
                };
            }

            _context.Equipments.Add(equipment);
            _context.SaveChanges();
            var _equipmentId = equipment.Id;

            Areas area = equipmentData.Areas;

            area.EquipmentId = _equipmentId;

            OperatingInformations operatinInformation = equipmentData.OperatingInformations;

            operatinInformation.EquipmentId = _equipmentId;

            ElectricalDistributions electricalDistribution = equipmentData.ElectricalDistributions;

            electricalDistribution.EquipmentId = _equipmentId;

            PowerFeatures powerFeature = equipmentData.PowerFeatures;

            powerFeature.EquipmentId = _equipmentId;

            Cables cable = equipmentData.Cables;

            cable.EquipmentId = _equipmentId;

            ThermalDissipations thermalDissipation = equipmentData.ThermalDissipations;

            thermalDissipation.EquipmentId = _equipmentId;

            _context.Areas.Add(area);
            _context.OperaOperatingInformations.Add(operatinInformation);
            _context.ElectricalDistributions.Add(electricalDistribution);
            _context.PowerFeatures.Add(powerFeature);
            _context.Cables.Add(cable);
            _context.ThermalDissipations.Add(thermalDissipation);

            _context.SaveChanges();
            return(StatusCode(201));
        }
        private async Task StartCallouts()
        {
            List <Guid> Cables;

            //assume
            using (var uow = new UnitOfWork(Tsdl))
                Cables = uow.Query <PhysicalCable>().Select(x => x.Oid).ToList();
            TotalNumberOfRecords = Cables.Count();
            /// var plr =
            await Task.Run(() =>
            {
                Cables.ForEach((guid) =>
                {     //
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        var X = uow.GetObjectByKey <Cable>(guid);
                        try
                        {
                            string cablename = X.CableName, dgroup = string.Empty;// this is so that we know when the count) switched and we need a new line
                            var cpairs       = X.CablePairs.OrderBy(x => x.PairNumber).ToArray();
                            //go through pairs and construct callout
                            List <string> calloutBuilder = new List <string>();
                            StringBuilder lineBuilder    = new StringBuilder();
                            int n = 0;// to keep track of iteration count per line
                            for (int i = 0; i < cpairs.Length; i++)
                            {
                                var pair = cpairs[i];
                                if (n++ == 0)//beginning
                                {
                                    try
                                    { //<pairNum>:<DesignationGroupName>, <pairnumstart-pairnumnend>|
                                      //<pairNum>:XD, <pairnumstart-pairnumnend>|

                                        dgroup = GetDGroupName(pair);
                                        //only want on beginning of each line
                                        lineBuilder.Append($"{pair.PairNumber}: {dgroup}, {pair.PairNumber}-");
                                    }
                                    catch (Exception ex)
                                    {
                                        NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"{ex}");
                                    }
                                }
                                else // if (i <= cpairs.Length - 1)//middle
                                {
                                    string nextdgroup = null;
                                    try
                                    {
                                        bool endline = false;
                                        if (i == cpairs.Length - 1)
                                        {
                                            endline = true;
                                        }
                                        else
                                        {
                                            // must have another row so check its dgroup
                                            //if these are different, then we need to start a new line and finish this line
                                            var nextpair = cpairs[i + 1];
                                            nextdgroup   = GetDGroupName(nextpair);
                                            if (nextdgroup != dgroup)
                                            {
                                                endline = true;
                                            }
                                        }
                                        if (endline)//end
                                        {
                                            n = 0;
                                            lineBuilder.Append($"{pair.PairNumber}");
                                            //only add XD lines if they are on the end of the bunch, last pairs
                                            if (dgroup != "XD" || (i == cpairs.Length - 1))
                                            {
                                                calloutBuilder.Add(lineBuilder.ToString());
                                            }
                                            NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"{lineBuilder}");
                                            lineBuilder.Clear();
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"{ex}");
                                    }
                                }
                            }//end for cpairs
                             //clear call out for this cable and insert value
                            string final = string.Join("|", calloutBuilder);
                            X.CallOut1   = final;
                            uow.CommitChanges();//Async(new DevExpress.Xpo.AsyncCommitCallback(CompleteRead));

                            Dispatcher.BeginInvoke(new Action(() =>
                            {
                                UpdateTextEtc(final);
                            }),
                                                   null);
                        }
                        catch (Exception ex)
                        {
                            NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"{ex}");
                        }
                    }//end using
                });//end foreach
            });

            //await Task.FromResult(plr);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Removes objects from the group.
 /// </summary>
 /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception>
 public void Remove(Cable item)
 {
     setGroupAssign(item, remove: true);
     Cables.Remove(item);
     item.RemoveFromGroup(this);
 }
Exemplo n.º 16
0
        public void Analyse()
        {
            //利用并查集找出所有连通块,在逻辑上,对于每个连通块,块上所有点都属于同一端点,每一个连通块都属不同端点
            {
                Dictionary <G_Pin, G_Pin> Pre = new Dictionary <G_Pin, G_Pin>();              //这一段效率或许不高,暂时不进行处理,记录
                G_Pin find(G_Pin a)
                {
                    if (!Pre[a].Equals(a))
                    {
                        return(find(Pre[a]));
                    }
                    return(Pre[a]);                   //也就是自身
                }

                G_Pin find_compress(G_Pin a)                //压缩/查询并查集
                {
                    if (!Pre[a].Equals(a))
                    {
                        Pre[a] = find_compress(Pre[a]);
                    }
                    return(Pre[a]);
                }

                void join(G_Pin a, G_Pin b)                //连接
                {
                    G_Pin fa = find_compress(a);
                    G_Pin fb = find_compress(b);

                    if (!fa.Equals(fb))
                    {
                        Pre[fb] = fa;
                    }
                }

                void note(DCSimulator.Components.Node node, G_Pin pre)                //记录
                {
                    var r = Pre.Keys.Where(p => find(p).Equals(pre));

                    foreach (var c in r)
                    {
                        Ports[c] = node;
                    }
                }

                foreach (var cb in Components.ToArray())                //显式、用缆线连接
                {
                    foreach (var c in cb.Pins)
                    {
                        Pre[c] = c;
                    }
                }
                foreach (var c in Pre.Keys.ToArray())
                {
                    foreach (var cc in Pre.Keys.ToArray().Where(p => p.RingPosition == c.RingPosition && !p.Equals(c)))                    //隐式、引脚叠合连接
                    {
                        join(c, cc);
                    }
                }
                foreach (var cb in Cables.ToArray())
                {
                    join(cb.P1, cb.P2);
                }
                foreach (var pr in Pre.Keys)
                {
                    if (Pre[pr].Equals(pr))                    //连通块
                    {
                        note(Circuit.NewNode(), pr);           //新的块
                    }
                }
            }
            //加载控件
            {
                foreach (var c in Components.Where(c => c is G_Chip).ToArray())
                {
                    G_Chip  cc  = c as G_Chip;
                    Circuit tmp = null;
                    var     f   = new System.IO.BinaryReader(new System.IO.MemoryStream(cc.Data.Data));
                    tmp = Circuit.FromStream(f);
                    f.Close();
                    List <int> a = new List <int>();
                    foreach (var p in tmp.Nodes)
                    {
                        var t = cc.ToNodes.Where(y => y.Value == p.Index);
                        foreach (var tt in t)
                        {
                            a.Add(p.Index);
                            Ports[tt.Key].AllCombineTo(p);
                        }
                    }
                    for (int i = 0; i < tmp.Nodes.Count; i++)
                    {
                        if (a.Contains(i))
                        {
                            continue;
                        }
                        Circuit.Nodes.Add(tmp.Nodes[i]);
                    }
                    for (int i = 0; i < Circuit.Nodes.Count; i++)
                    {
                        Circuit.Nodes[i].Index = i;
                    }
                    Circuit.Components.AddRange(tmp.Components);
                }
                foreach (var c in Components.ToArray())
                {
                    /*if (c is G_Chip)
                     * {
                     *      G_Chip cc = c as G_Chip;
                     *      Circuit tmp = null;
                     *      var f = new System.IO.BinaryReader(new System.IO.MemoryStream(cc.Data.Data));
                     *      Dictionary<int, DCSimulator.Components.Node> a = new Dictionary<int, DCSimulator.Components.Node>();
                     *      foreach (var p in cc.Pins)
                     *      {
                     *              var t = cc.ToNodes[p];
                     *              a[t] = Ports[p];
                     *              //Ports[p].CombineTo(tmp.Nodes[t]);
                     *      }
                     *      tmp = Circuit.FromStream(f, a);
                     *      f.Close();
                     *      for (int i = 0; i < tmp.Nodes.Count; i++)
                     *      {
                     *              if (a.Keys.Contains(i)) continue;
                     *              Circuit.Nodes.Add(tmp.Nodes[i]);
                     *      }
                     *      for (int i = 0; i < Circuit.Nodes.Count; i++)
                     *      {
                     *              Circuit.Nodes[i].Index = i;
                     *      }
                     *      Circuit.Components.AddRange(tmp.Components);
                     * }
                     * else */
                    if (c is G_Switch)
                    {
                        var sc = c as G_Switch;
                        var sw = new DCSimulator.Components.Switch(Circuit);
                        if (Ports.ContainsKey(sc.Pin))
                        {
                            sw.Output = Ports[sc.Pin];
                        }
                        Circuit.Components.Add(sw);
                        sc.StateFlip = b =>
                        {
                            if (b)
                            {
                                sw.TurnON();
                            }
                            else
                            {
                                sw.TurnOff();
                            }
                        };
                    }
                    else if (c is G_Detector)
                    {
                        var sc = c as G_Detector;
                        var sw = new DCSimulator.Components.Detector(Circuit);
                        if (Ports.ContainsKey(sc.Pin))
                        {
                            sw.Input_1 = Ports[sc.Pin];
                        }
                        Circuit.Components.Add(sw);
                        sc.UpdateEvent = () =>
                        {
                            sc.Powered = sw.Input_1.Value;
                        };
                    }
                    else if (c is G_Pulse)
                    {
                        var sc = c as G_Pulse;
                        var sw = new DCSimulator.Components.Pulse(Circuit)
                        {
                            Delay = sc.Delay, Signal = sc.InitialEL
                        };
                        if (Ports.ContainsKey(sc.Pin))
                        {
                            sw.Output = Ports[sc.Pin];
                        }
                        Circuit.Components.Add(sw);
                    }
                    else if (c is G_Delayer)
                    {
                        var sc = c as G_Delayer;
                        var sw = new DCSimulator.Components.Delayer(Circuit)
                        {
                            Delay = sc.Delay
                        };
                        if (Ports.ContainsKey(sc.IN))
                        {
                            sw.Input = Ports[sc.IN];
                        }
                        if (Ports.ContainsKey(sc.OUT))
                        {
                            sw.Output = Ports[sc.OUT];
                        }
                        Circuit.Components.Add(sw);
                    }
                    else if (c is G_Gate)
                    {
                        var gc = c as G_Gate;
                        switch (gc.GateType)
                        {
                        case "OR":                                //或门
                        {
                            var g_or = gc as G_Gate_Binary;
                            var or   = new DCSimulator.Components.Gate_OR(Circuit, "OR_None");
                            if (Ports.ContainsKey(g_or.IN_1))
                            {
                                or.Input_1 = Ports[g_or.IN_1];
                            }
                            if (Ports.ContainsKey(g_or.IN_2))
                            {
                                or.Input_2 = Ports[g_or.IN_2];
                            }
                            if (Ports.ContainsKey(g_or.OUT))
                            {
                                or.Output = Ports[g_or.OUT];
                            }
                            Circuit.Components.Add(or);
                        }
                        break;

                        case "NOT":                                //非门
                        {
                            var g_not = gc as G_Gate_Unitary;
                            var not   = new DCSimulator.Components.Gate_NOT(Circuit, "NOT_None");

                            if (Ports.ContainsKey(g_not.IN))
                            {
                                not.Input_1 = Ports[g_not.IN];
                            }
                            if (Ports.ContainsKey(g_not.OUT))
                            {
                                not.Output = Ports[g_not.OUT];
                            }
                            Circuit.Components.Add(not);
                        }
                        break;

                        case "AND":                                //与门
                        {
                            var g_and = gc as G_Gate_Binary;
                            var and   = new DCSimulator.Components.Gate_AND(Circuit, "AND_None");

                            if (Ports.ContainsKey(g_and.IN_1))
                            {
                                and.Input_1 = Ports[g_and.IN_1];
                            }
                            if (Ports.ContainsKey(g_and.IN_2))
                            {
                                and.Input_2 = Ports[g_and.IN_2];
                            }
                            if (Ports.ContainsKey(g_and.OUT))
                            {
                                and.Output = Ports[g_and.OUT];
                            }
                            Circuit.Components.Add(and);
                        }
                        break;

                        case "NAND":                                //与非门
                        {
                            var g_and = gc as G_Gate_Binary;
                            var and   = new DCSimulator.Components.Gate_NAND(Circuit, "NAND_None");

                            if (Ports.ContainsKey(g_and.IN_1))
                            {
                                and.Input_1 = Ports[g_and.IN_1];
                            }
                            if (Ports.ContainsKey(g_and.IN_2))
                            {
                                and.Input_2 = Ports[g_and.IN_2];
                            }
                            if (Ports.ContainsKey(g_and.OUT))
                            {
                                and.Output = Ports[g_and.OUT];
                            }
                            Circuit.Components.Add(and);
                        }
                        break;

                        case "NOR":                                //或非门门
                        {
                            var g_and = gc as G_Gate_Binary;
                            var and   = new DCSimulator.Components.Gate_NOR(Circuit, "NOR_None");

                            if (Ports.ContainsKey(g_and.IN_1))
                            {
                                and.Input_1 = Ports[g_and.IN_1];
                            }
                            if (Ports.ContainsKey(g_and.IN_2))
                            {
                                and.Input_2 = Ports[g_and.IN_2];
                            }
                            if (Ports.ContainsKey(g_and.OUT))
                            {
                                and.Output = Ports[g_and.OUT];
                            }
                            Circuit.Components.Add(and);
                        }
                        break;

                        case "XOR":                                //或非门门
                        {
                            var g_and = gc as G_Gate_Binary;
                            var and   = new DCSimulator.Components.Gate_XOR(Circuit, "XOR_None");

                            if (Ports.ContainsKey(g_and.IN_1))
                            {
                                and.Input_1 = Ports[g_and.IN_1];
                            }
                            if (Ports.ContainsKey(g_and.IN_2))
                            {
                                and.Input_2 = Ports[g_and.IN_2];
                            }
                            if (Ports.ContainsKey(g_and.OUT))
                            {
                                and.Output = Ports[g_and.OUT];
                            }
                            Circuit.Components.Add(and);
                        }
                        break;
                        }
                    }
                }
            }
        }