Пример #1
0
        public void CableTest3()
        {
            Cable cable = new Cable(1.0,
                                    (Materials.SteelCore, 0.15),
                                    (Materials.AL6201T81, 0.60));

            Assert.AreEqual(1.0, cable.Diameter);
            Assert.AreEqual(0.75, cable.Area);
            Assert.AreEqual(1.22382, cable.Weight);
            Assert.AreEqual(55350.0, cable.RatedStrength);
        }
Пример #2
0
        public void Cable_CloneAndEqualsTest()
        {
            var c1 = new Cable(0.75, 1.0, 1.25, 18000);
            var c2 = c1.Clone();

            Assert.AreEqual(c1, c2);
        }
Пример #3
0
        public static void Connect(Transaction tr, Document doc, Dictionary <Handle, Compuerta> compuertas)
        {
            ObjectId pulsoId, cmpId;
            Point3d  connPoint;

            if (Selector.Entity("Selecciona un pulso", typeof(Polyline), out pulsoId) &&
                Selector.Entity("Selecciona la compuerta a conectar el pulso", out cmpId, out connPoint))
            {
                Cable c;
                //Extraer información del pulso
                Polyline  pl    = pulsoId.GetObject(OpenMode.ForRead) as Polyline;
                Boolean[] data  = Pulso.GetValues(pl);
                Point3d   start = pl.EndPoint;
                //Extraer información de la compuerta
                Compuerta cmp = compuertas.Values.FirstOrDefault(x => x.Block.Id == cmpId);
                if (cmp != null)
                {
                    String            name;
                    Point3dCollection zone;
                    cmp.GetZone(connPoint, out name, out zone);
                    //Obtención del punto de conexión
                    if (cmp.ConnectionPoints.ContainsKey(name))
                    {
                        Point3d end = cmp.ConnectionPoints[name];
                        Drawer  d   = new Drawer(tr);
                        c = Cable.InsertCable(start, end, d);
                        c.SetData(tr, doc, data);
                    }
                }
            }
        }
Пример #4
0
        public void readinfo(String conFile)
        {
            string       line;
            StreamReader streamReader = new StreamReader(conFile);
            List <Cable> readCables   = new List <Cable>(); //RC musi znać kable

            //RoutingController RC = new RoutingController();
            line             = streamReader.ReadLine();
            port             = ushort.Parse(line.Split(' ')[1]);
            line             = streamReader.ReadLine();
            secondDomainPort = ushort.Parse(line.Split(' ')[1]);
            //Domain.port = ushort.Parse(line.Split(' ')[1]);
            while ((line = streamReader.ReadLine()) != null)
            {
                IPAddress ip1 = IPAddress.Parse(line.Split(' ')[1]);
                line = streamReader.ReadLine();
                ushort port1 = ushort.Parse(line.Split(' ')[1]);
                line = streamReader.ReadLine();
                IPAddress ip2 = IPAddress.Parse(line.Split(' ')[1]);
                line = streamReader.ReadLine();
                ushort port2 = ushort.Parse(line.Split(' ')[1]);
                line = streamReader.ReadLine();
                int   len   = int.Parse(line.Split(' ')[1]);
                Cable cable = new Cable(ip1, ip2, port1, port2, len);
                readCables.Add(cable);
            }
            RC.cables = readCables;
            //return RC;
        }
Пример #5
0
        public void Setup()
        {
            conductor = new Conductor();
            billet    = new InsulatedBillet {
                Conductor = conductor, PolymerGroup = new PolymerGroup()
            };
            coverPolymerGroup   = new PolymerGroup();
            fireProtectionClass = new FireProtectionClass();
            twistedElementType  = new TwistedElementType();
            operatingVoltage250 = new OperatingVoltage
            {
                ACVoltage   = 380,
                ACFriquency = 400,
                DCVoltage   = 540
            };
            operatingVoltage660 = new OperatingVoltage
            {
                ACVoltage   = 660,
                ACFriquency = 400,
                DCVoltage   = 1000
            };
            builder = new SkabTitleBuilder();

            cable = new Cable
            {
                CoverPolymerGroup   = coverPolymerGroup,
                TwistedElementType  = twistedElementType,
                FireProtectionClass = fireProtectionClass,
            };
        }
Пример #6
0
        public void NoSendTest()
        {
            // given: full cable with connected cable
            var receivingCable = new Cable();

            receivingCable.Left.CurrentIOMode = IOMode.Input;
            var packet1 = new Packet(0.1);

            receivingCable.Left.Receive(packet1);
            receivingCable.Update();
            var packet2 = new Packet(0.2);

            receivingCable.Left.Receive(packet2);

            // connect the sending cable
            var sendingCable = new Cable();

            sendingCable.Top.CurrentIOMode = IOMode.Input;
            var packet3 = new Packet(0.3);

            sendingCable.Top.Receive(packet3);
            sendingCable.Right.CurrentIOMode = IOMode.Output;
            sendingCable.Right.ConnectToPort(receivingCable.Left);

            // when: simulating
            sendingCable.Update();

            // then: packet3 was not sent.
            Assert.That(receivingCable.CurrentPacket, Is.SameAs(packet1));
            Assert.That(receivingCable.Left.ReceiveBuffer, Is.SameAs(packet2));
            Assert.That(sendingCable.CurrentPacket, Is.SameAs(packet3));
            Assert.That(sendingCable.Top.ReceiveBuffer, Is.Null);
        }
        public string GetCableTitle(Cable cable, InsulatedBillet mainBillet, CablePropertySet?cableProperty, object parameter = null)
        {
            string shield = string.Empty;

            if (cableProperty.HasValue)
            {
                shield = "Э";
            }
            string namePart;

            if (mainBillet.PolymerGroup.Title == "PVC LS")
            {
                namePart = $"КЭВ{shield}Внг(А)-LS ";
            }
            else
            {
                namePart = $"КЭРс{shield}";
            }
            _nameBuilder = new StringBuilder(namePart);

            if (cable.CoverPolymerGroup.Title == "HFCompound")
            {
                _nameBuilder.Append("Пнг(А)-FRHF ");
            }
            if (cable.CoverPolymerGroup.Title == "PUR")
            {
                _nameBuilder.Append("Унг(D)-FRHF ");
            }
            namePart = CableCalculations.FormatConductorArea(mainBillet.Conductor.AreaInSqrMm);

            _nameBuilder.Append($"{cable.ElementsCount}х{namePart}");
            return(_nameBuilder.ToString());
        }
Пример #8
0
        private Point[] FindIntersections(Cable a, Cable b)
        {
            List <Point> found = new List <Point>();

            minIntersectionSteps = TotalSteps(a, b);
            var iSteps = 0;
            var jSteps = 0;

            for (var i = 0; i < a.Segments.Length; i++)
            {
                iSteps += a.Segments[i].Distance;
                jSteps  = 0;

                for (var j = 0; j < b.Segments.Length; j++)
                {
                    jSteps += b.Segments[j].Distance;

                    var intersection = a.Segments[i].FindIntersection(b.Segments[j]);
                    if (intersection != null && intersection.IsNotOrigin())
                    {
                        var intersectionSteps = iSteps + jSteps - intersection.Distance(a.Segments[i].End) - intersection.Distance(b.Segments[j].End);
                        minIntersectionSteps = Math.Min(minIntersectionSteps, intersectionSteps);
                        Intersections.Add(intersection);
                        Console.WriteLine($"Found ({intersection.X}, {intersection.Y}) - {intersectionSteps}");
                    }
                }
            }

            return(found.ToArray());
        }
Пример #9
0
    //plugs in the cable to the port
    public virtual void plugIn(Cable cable, Port endPort)
    {
        Debug.Log("PORT: plugging in cable");
        setCable(cable);
        setConnection(true);
        this.endPort = endPort;

        //if the port belongs to a switch
        if (device.Equals("switch"))
        {
            switch (endPort.device)
            {
            case "pc":
            {
                //bind mac address of pc and store in switch port
                setMAC(endPort.getPC().getMAC());
                link.type         = "access";
                endPort.link.type = link.type;
                link.vlan         = endPort.link.vlan;
                break;
            }

            case "router":
            {
                //bind mac address of router and store in switch port
                setMAC(endPort.getRouter().getMAC());
                link.type         = "trunk";
                endPort.link.type = link.type;
                link.vlan         = 0;
                endPort.link.vlan = 0;
                break;
            }
            }
        }
    }
Пример #10
0
 public void AttachBundleToSender(Cable <R, T> bundle)
 {
     foreach (var pair in endpointMap)
     {
         pair.Value.AddReceiver(bundle.GetSendChannel(pair.Key));
     }
 }
Пример #11
0
 public static bool saveRatio(Cable cable, DateTime startTime, int businesstypeid, RatioDate ratio)
 {
     try
     {
         int CableId     = cable.Id;            //电路代码ID
         int MainUserId  = cable.Userid;        //主销售人员
         int WriteUserId = cable.Controluserid; //录入人员ID
         if (getCommissRatio(CableId, MainUserId) == 0)
         {
             //写入主销售渠道提成比例
             save(CableId, MainUserId, (int)EnmDataType.主销售渠道, cable.Cablestatus, startTime, cable.Cableclass, businesstypeid, ratio);
         }
         if (getCommissRatio(CableId, WriteUserId) == 0)
         {
             //写入主销售渠道提成比例
             save(CableId, WriteUserId, (int)EnmDataType.完工录入, cable.Cablestatus, startTime, cable.Cableclass, businesstypeid, ratio);
         }
         return(true);
     }
     catch (Exception ex)
     {
         MessageHelper.ShowMessage("E999", "保存提成信息失败。");
         return(false);
     }
 }
        private void ParseTableCellData(Cable cable, TableCellData tableCellData, IEnumerable <InsulatedBillet> currentBilletsList,
                                        CablePropertySet?cableProps = null)
        {
            if (decimal.TryParse(tableCellData.ColumnHeaderData, NumberStyles.Any, _cultureInfo, out decimal elementsCount) &&
                decimal.TryParse(tableCellData.RowHeaderData, NumberStyles.Any, _cultureInfo, out decimal conductorAreaInSqrMm) &&
                decimal.TryParse(tableCellData.CellData, NumberStyles.Any, _cultureInfo, out decimal maxCoverDiameter))
            {
                var billet = (from b in currentBilletsList
                              where b.Conductor.AreaInSqrMm == conductorAreaInSqrMm
                              select b).First();
                cable.ElementsCount    = elementsCount;
                cable.MaxCoverDiameter = maxCoverDiameter;
                cable.Title            = _cableTitleBuilder.GetCableTitle(cable, billet, cableProps);

                var cableRec = _dbContext.Cables.Add(cable).Entity;

                _dbContext.ListCableBillets.Add(new ListCableBillets {
                    Billet = billet, Cable = cableRec
                });

                if (cableProps.HasValue)
                {
                    var listOfCableProperties = GetCableAssociatedPropertiesList(cableRec, cableProps.Value);
                    _dbContext.ListCableProperties.AddRange(listOfCableProperties);
                }
                _dbContext.SaveChanges();
            }
            else
            {
                throw new Exception($"Не удалось распарсить ячейку таблицы!");
            }
        }
Пример #13
0
        public void SendTest()
        {
            // given: Cable with packet and output port connected to another cable
            var cable = new Cable();

            cable.Top.CurrentIOMode = IOMode.Input;
            var packet = new Packet(1);

            cable.Top.Receive(packet);
            cable.Right.CurrentIOMode = IOMode.Output;

            var cable2 = new Cable();

            cable2.Left.CurrentIOMode = IOMode.Input;
            cable2.Left.ConnectToPort(cable.Right);

            // when: simulating
            cable.Update();
            cable2.Update();

            // then: packet sent
            Assert.That(cable2.CurrentPacket, Is.SameAs(packet));
            Assert.That(cable.Top.ReceiveBuffer, Is.Null);
            Assert.That(cable2.Left.ReceiveBuffer, Is.Null);
        }
Пример #14
0
 /// <summary>
 /// Sets the cable used by the worker thread.
 /// </summary>
 /// <param name="cable"> The cable to use. </param>
 /// <remarks>
 /// This function stops the worker thread if it is running and does not restart it.
 /// </remarks>
 public void SetCable(Cable cable)
 {
     // stop and join the worker thread
     Stop();
     Join();
     this.cable = cable;
 }
Пример #15
0
        private void Render(CableRoute route, float radius)
        {
            if (m_segmentSpawner == null)
            {
                return;
            }

            // Let OnDrawGizmos handle rendering when in prefab edit mode.
            // It's not possible to use RuntimeObjects while there.
            if (PrefabUtils.IsPartOfEditingPrefab(gameObject))
            {
                return;
            }

            if (!Cable.RoutePointCurveUpToDate)
            {
                Cable.SynchronizeRoutePointCurve();
            }

            m_segmentSpawner.Begin();
            try {
                var points = Cable.GetRoutePoints();
                for (int i = 1; i < points.Length; ++i)
                {
                    m_segmentSpawner.CreateSegment(points[i - 1], points[i], radius);
                }
            }
            catch (System.Exception e) {
                Debug.LogException(e, this);
            }
            m_segmentSpawner.End();
        }
Пример #16
0
    private void changeEffectsState(Arista a, bool canDeactivate)
    {
        Cable spriteToActive = cableToActive.GetComponent <Cable>();

        if (spriteToActive.arista._1().Equals(a._1()) && spriteToActive.arista._2().Equals(a._2()) && !canDeactivate)
        {
            spriteToActive.changeColliderState(false);
            for (int i = 0; i < spriteToActive.transform.childCount; i++)
            {
                spriteToActive.transform.GetChild(i).gameObject.SetActive(true);
            }
        }
        else
        {
            Debug.Log("Desactivamos los efectos");
            //Desactivamos todos los efectos porque nos hemos equivocado
            Vertex[] vert = FindObjectsOfType <Vertex>();
            for (int i = 0; i < vert.Length; i++)
            {
                vert[i].depush();
            }
            Cable[] allCables = FindObjectsOfType <Cable>();
            for (int i = 0; i < allCables.Length; i++)
            {
                allCables[i].changeColliderState(true);
                for (int j = 0; j < allCables[i].transform.childCount; j++)
                {
                    allCables[i].transform.GetChild(j).gameObject.SetActive(false);
                }
            }
        }
    }
        public static void OnDrawGizmosCable(Cable cable, GizmoType gizmoType)
        {
            // Do not render initialized cables.
            if (cable.Native != null)
            {
                return;
            }

            cable.TraverseRoutePoints(routePointData =>
            {
                var lineLength = 2.5f * cable.Radius;

                Gizmos.color = Color.red;
                Gizmos.DrawLine(routePointData.Position,
                                routePointData.Position + lineLength * (routePointData.Rotation * Vector3.right));

                Gizmos.color = Color.green;
                Gizmos.DrawLine(routePointData.Position,
                                routePointData.Position + lineLength * (routePointData.Rotation * Vector3.up));

                Gizmos.color = Color.blue;
                Gizmos.DrawLine(routePointData.Position,
                                routePointData.Position + lineLength * (routePointData.Rotation * Vector3.forward));
            });
        }
Пример #18
0
        public async Task <ActionResult> PostCable(Cable cable)
        {
            _context.Cables.Add(cable);
            await _context.SaveChangesAsync();

            return(Ok(new { cable, Total = await _context.Cables.CountAsync() }));
        }
Пример #19
0
        public async Task <IActionResult> PutCable(int id, Cable cable)
        {
            if (id != cable.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cable).State = EntityState.Modified;

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

            return(NoContent());
        }
Пример #20
0
        public static void ReceiveCablePlacement(BinaryReader reader, int sender)
        {
            TagCompound tag      = TagIO.Read(reader);
            Point16     position = tag.Get <Point16>("Position");
            string      name     = tag.GetString("Name");

            Cable cable = new Cable();

            cable.SetDefaults(name);
            cable.position = position;
            cable.layer    = PTWorld.Instance.layer;
            cable.grid     = new CableGrid
            {
                energy = new EnergyStorage(cable.MaxIO * 2, cable.MaxIO),
                tiles  = new List <Cable> {
                    cable
                }
            };
            PTWorld.Instance.layer.Add(position, cable);

            cable.Merge();
            cable.Frame();

            foreach (Cable merge in Cable.sides.Select(x => x + position).Where(PTWorld.Instance.layer.ContainsKey).Select(x => PTWorld.Instance.layer[x]).Where(x => x.name == name))
            {
                merge.Frame();
            }

            if (Main.netMode == NetmodeID.Server)
            {
                SendCablePlacement(cable, sender);
            }
        }
Пример #21
0
 public void switchInit(string _type, Switch swit)
 {
     this.swit = swit;
     type      = _type;
     device    = "switch";
     connected = false;
     cable     = null;
     Debug.Log("SWITCH PORT: Created!");
 }
Пример #22
0
 /// <summary>
 /// Sets the cable section assignments.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="table">The table.</param>
 private static void setCABLE_SECTION_ASSIGNMENTS(Model model, List <Dictionary <string, string> > table)
 {
     foreach (Dictionary <string, string> tableRow in table)
     {
         Cable cable = model.Structure.Cables[tableRow["Cable"]];
         cable.SectionName = tableRow["Section"];
         cable.AddMaterialOverwrite(model.Components.Materials.FillItem(tableRow["MatProp"]));
     }
 }
Пример #23
0
        public void CableTest()
        {
            Cable cable = new Cable(area: 0.75, diameter: 1.0, unitWeight: 1.25, ratedStrength: 18000);

            Assert.AreEqual(1.0, cable.Diameter);
            Assert.AreEqual(0.75, cable.Area);
            Assert.AreEqual(1.25, cable.Weight);
            Assert.AreEqual(18000, cable.RatedStrength);
        }
Пример #24
0
 public void plugIn(Cable cable, Port endPort)
 {
     Debug.Log("PORT: plugging in cable");
     this.cable        = cable;
     endPort.cable     = cable;
     endPort.connected = true;
     this.connected    = true;
     this.MAC          = endPort.getMAC();
 }
Пример #25
0
        /// <summary>
        /// Get cleared on despawn So need to Reinitialise on spawn
        /// </summary>
        /// <param name="action"></param>
        /// <param name="FromType"></param>
        public void RegisterPort(Action action, Type FromType)
        {
            if (isServer == false)
            {
                return;
            }
            var insertCable = new Cable();

            CableID++;
            insertCable.cableCoilID = CableID;
            insertCable.PanelInput  = action;
            insertCable.PanelOutput = action;
            if (Connections.ContainsKey(action) == false)
            {
                Connections[action] = new List <Cable>();
            }


            Connections[action].Add(insertCable);
            Cables.Add(insertCable);

            var newLocalPortData = new LocalPortData();

            newLocalPortData.LocalAction = action;

            if (ColourDictionary == null)
            {
                Logger.Log("Color dictionary wasn't found. RegisterPort has exited.", Category.Interaction);
                return;
            }

            if (ColourDictionary.ContainsKey(FromType) == false)
            {
                ColourDictionary[FromType]     = new Dictionary <MethodInfo, Color>();
                MonoAvailableColours[FromType] = new List <Color>(AvailableColours);
            }

            if (ColourDictionary[FromType].ContainsKey(action.Method) == false)
            {
                ColourDictionary[FromType][action.Method] = PickARandomColourForPort(action.Method, FromType);
            }
            else
            {
                newLocalPortData.Colour = ColourDictionary[FromType][action.Method];
            }

            newLocalPortData.LocalID = ID;
            ID++;

            DictionaryCurrentPorts[action] = newLocalPortData;
            PanelOutputCurrentPorts.Add(newLocalPortData);
            PanelOutputCurrentPorts =
                PanelOutputCurrentPorts.OrderBy(item => HackingProcessBase.random.Next()).ToList();
            PanelInputCurrentPorts.Add(newLocalPortData);
            PanelInputCurrentPorts = PanelInputCurrentPorts.OrderBy(item => HackingProcessBase.random.Next()).ToList();
        }
Пример #26
0
 public void routerInit(string _type, Router router)
 {
     this.router = router;
     type        = _type;
     device      = "router";
     connected   = false;
     cable       = null;
     MAC         = "1";
     Debug.Log("ROUTER PORT: Created!");
 }
Пример #27
0
 void ToggleCables()
 {
     foreach (Transform CableBox in CurrentButton.transform)
     {
         foreach (Transform Cable in CableBox.transform)
         {
             Cable.GetComponent <CableManager>().TurnON();
         }
     }
 }
Пример #28
0
 public void pcInit(string _type, PC pc, string mac)
 {
     this.pc   = pc;
     type      = _type;
     device    = "pc";
     connected = false;
     cable     = null;
     MAC       = mac;
     Debug.Log("PC PORT: Created!");
 }
Пример #29
0
        public void CreateParametrizedCableTest()
        {
            Cable testEl = new Cable("Test", "SimpleTest", 2, 8);

            Assert.AreEqual("Test", testEl.Name);
            Assert.AreEqual("SimpleTest", testEl.Description);
            Assert.AreEqual(2, testEl.EntryPrice);
            Assert.AreEqual(8, testEl.Price);
            Assert.AreEqual(4, testEl.Coefficient);
        }
Пример #30
0
    private void SetSprite(GameObject space, Cable c)
    {
        if (c.cableType == CableType.EMPTY)
        {
            return;
        }

        space.GetComponent <SpriteRenderer>().sprite = cableSpriteDict[c.cableType];
        space.transform.eulerAngles = new Vector3(0, 0, -c.GetRotation());
    }
    public void CablePropertiesInfluenceElectricProperties()
    {
        const int crossSectionalSquare = 5;
        const int length = 5;
        var resistivity = HelperClass.GetResistivity("silver");
        var resistance = resistivity*length/crossSectionalSquare;

        var cable = new Cable(resistivity, length, crossSectionalSquare);

        Assert.AreEqual(cable.Properties.Resistance, resistance);
    }
    public void VoltmeterTest()
    {
        var battery = HelperClass.GetRandomBattery();
        var cable1 = new Cable("test_one", 1, 2);
        var cable2 = new Cable("test_one", 1, 2);
        var voltmeter = new Voltmeter(2);
        battery.Connect(voltmeter);
        voltmeter.Connect(battery);
        voltmeter.SetMeasuredSubcircuit(cable1);
        cable1.Connect(cable2);

        battery.GiveProperties();

        Assert.AreEqual((battery.Properties.Amperage * (cable1.Properties.Resistance + cable2.Properties.Resistance + 2)).ToString(), voltmeter.GetValue().Replace(" Volt", ""));
    }