Example #1
0
        private void DoAutoWiring(bool isWiringNeeded, Project project, ControlSystem controlSystem)
        {
            controlSys = controlSystem;
            InitWiringNodes(_addflowWiring);
            ControlGroup        controlGroup = project.ControlGroupList.Find(c => c.ControlSystemID.Equals(controlSystem.Id));
            AutoWiringNodeGroup nodeGroup    = null;

            if (controlGroup != null)
            {
                nodeGroup = CreateWiringNodeStructure(controlGroup);

                _addflowWiring.AddNode(nodeGroup);
                float x = X_RowHeader;

                foreach (WiringNodeCentralControl nodeController in nodeGroup.ControllerListLevel1)
                {
                    AutoDrawController(nodeController, x);
                    x += X_OffsetStep;
                }
                x = X_RowHeader;
                foreach (WiringNodeCentralControl nodeController in nodeGroup.ControllerListLevel2)
                {
                    AutoDrawController(nodeController, x);
                    x += X_OffsetStep;
                }
                x = X_RowHeader;
                foreach (WiringNodeCentralControl nodeController in nodeGroup.ControllerListOthers)
                {
                    AutoDrawController(nodeController, x);
                    x += X_OffsetStep;
                }
                x = X_RowHeader;
                foreach (WiringNodeCentralControl nodeSystem in nodeGroup.SystemList)
                {
                    AutoDrawController(nodeSystem, x);
                    x += X_OffsetStep;
                }
                if (isWiringNeeded)
                {
                    DrawLinks(nodeGroup);
                    controlSystem.IsAutoWiringPerformed = true;
                }
                else
                {
                    controlSystem.IsAutoWiringPerformed = false;
                }
            }
        }
Example #2
0
        private void DrawLinks(AutoWiringNodeGroup nodeGroup)
        {
            List <JCHNode> seriesList = new List <JCHNode>();
            JCHNode        nodeStart, nodeEnd;

            if (thisProject.RegionCode == "EU_W" || thisProject.RegionCode == "EU_S" || thisProject.RegionCode == "EU_E")
            {
                if (nodeGroup.ControllerListLevel1.Count > 0)
                {
                    seriesList.Add(nodeGroup.ControllerListLevel1[0]);
                }

                if (nodeGroup.ControllerListLevel2.Count > 0)
                {
                    seriesList.Add(nodeGroup.ControllerListLevel2[0]);
                }
            }
            if (nodeGroup.ControllerListOthers.Count > 0)
            {
                seriesList.Add(nodeGroup.ControllerListOthers[0]);
            }
            if (nodeGroup.SystemList.Count > 0)
            {
                seriesList.Add(nodeGroup.SystemList[0]);
            }

            for (int i = 0; i < seriesList.Count - 1; i++)
            {
                Link myLink = SeriesLink(seriesList[i], seriesList[i + 1]);
                myLink.IsStretchable = true;
                myLink.IsSelectable  = false;
                //myLink.LineStyle = LineStyle.Polyline;
                _addflowWiring.AddLink(myLink);
            }

            for (int i = 0; i < nodeGroup.ControllerListLevel1.Count - 1; i++)
            {
                nodeStart = nodeGroup.ControllerListLevel1[i];
                nodeEnd   = nodeGroup.ControllerListLevel1[i + 1];

                Link customLink = ParallelLink(nodeStart, nodeEnd);
                _addflowWiring.AddLink(customLink);

                CustomizeLink(nodeStart, nodeEnd, customLink);
            }

            for (int i = 0; i < nodeGroup.ControllerListLevel2.Count - 1; i++)
            {
                nodeStart = nodeGroup.ControllerListLevel2[i];
                nodeEnd   = nodeGroup.ControllerListLevel2[i + 1];

                Link customLink = ParallelLink(nodeStart, nodeEnd);
                _addflowWiring.AddLink(customLink);

                CustomizeLink(nodeStart, nodeEnd, customLink);
            }

            for (int i = 0; i < nodeGroup.ControllerListOthers.Count - 1; i++)
            {
                nodeStart = nodeGroup.ControllerListOthers[i];
                nodeEnd   = nodeGroup.ControllerListOthers[i + 1];

                Link customLink = ParallelLink(nodeStart, nodeEnd);
                _addflowWiring.AddLink(customLink);

                CustomizeLink(nodeStart, nodeEnd, customLink);
            }

            for (int i = 0; i < nodeGroup.SystemList.Count - 1; i++)
            {
                nodeStart = nodeGroup.SystemList[i];
                nodeEnd   = nodeGroup.SystemList[i + 1];

                Link customLink = ParallelLink(nodeStart, nodeEnd);
                _addflowWiring.AddLink(customLink);

                CustomizeLink(nodeStart, nodeEnd, customLink);
            }
        }
Example #3
0
        //To draw initial layout
        private AutoWiringNodeGroup CreateWiringNodeStructure(ControlGroup controlGroup)
        {
            AutoWiringNodeGroup wiringGroup = new AutoWiringNodeGroup();

            foreach (Controller controller in Project.CurrentProject.ControllerList)
            {
                if (controller.ControlGroupID == controlGroup.Id)
                {
                    int level = 1;
                    if (controller.Model.Trim() == "CSNET MANAGER 2 T10" ||
                        controller.Model.Trim() == "CSNET MANAGER 2 T15")
                    {
                        level = 1;
                    }
                    else if (controller.Model.Trim() == "HC-A64NET" || controller.Model.Trim() == "PSC-A160WEB1")
                    {
                        level = 2;
                    }
                    else
                    {
                        level = 3;
                    }

                    for (int n = 0; n < controller.Quantity; n++)
                    {
                        JCHVRF.Model.NextGen.WiringNodeCentralControl wiringController =
                            new JCHVRF.Model.NextGen.WiringNodeCentralControl();
                        wiringController.Controller = controller;
                        wiringController.Level      = level;
                        if (level == 1)
                        {
                            wiringGroup.ControllerListLevel1.Add(wiringController);
                        }
                        else if (level == 2)
                        {
                            wiringGroup.ControllerListLevel2.Add(wiringController);
                        }
                        else
                        {
                            wiringGroup.ControllerListOthers.Add(wiringController);
                        }
                    }
                }
            }

            foreach (JCHVRF.Model.NextGen.SystemVRF systemVRF in Project.CurrentProject.SystemListNextGen)
            {
                if (systemVRF.ControlGroupID != null)
                {
                    if (systemVRF.ControlGroupID.Contains(controlGroup.Id))
                    {
                        atleast_1system = true;
                        if (systemVRF.SystemStatus == SystemStatus.VALID)
                        {
                            JCHVRF.Model.NextGen.WiringNodeCentralControl wiringVrf = new JCHVRF.Model.NextGen.WiringNodeCentralControl();
                            wiringVrf.SystemItem = systemVRF;
                            wiringGroup.SystemList.Add(wiringVrf);
                            if (controlSys.SystemStatus != SystemStatus.VALID)
                            {
                                controlSys.SystemStatus = SystemStatus.WIP;
                            }
                        }
                        else
                        {
                            systemVRF.ControlGroupID.Remove(controlGroup.Id);
                            controlSys.SystemsOnCanvasList.RemoveAll(item => item.System.Equals(systemVRF));
                        }
                    }
                }
            }

            foreach (RoomIndoor exchanger in Project.CurrentProject.ExchangerList)
            {
                if (exchanger.ControlGroupID != null)
                {
                    if (exchanger.ControlGroupID.Contains(controlGroup.Id))
                    {
                        if (thisProject.HeatExchangerSystems.Find(he => he.Id == exchanger.SystemID).SystemStatus == SystemStatus.VALID)
                        {
                            JCHVRF.Model.NextGen.WiringNodeCentralControl wiringExchanger = new JCHVRF.Model.NextGen.WiringNodeCentralControl();
                            wiringExchanger.RoomIndoorItem = exchanger;
                            wiringGroup.SystemList.Add(wiringExchanger);
                            if (controlSys.SystemStatus != SystemStatus.VALID)
                            {
                                controlSys.SystemStatus = SystemStatus.WIP;
                            }
                        }
                        else
                        {
                            exchanger.ControlGroupID.Remove(controlGroup.Id);
                            controlSys.SystemsOnCanvasList.RemoveAll(item => item.System.Equals(exchanger));
                        }
                    }
                }
            }
            if (wiringGroup.SystemList.Count <= 0)
            {
                controlSys.IsValid = false;
                ErrorLog.LogError(Model.ErrorType.Error, Model.ErrorCategory.WiringError, "No System Selected");
            }
            return(wiringGroup);
        }