示例#1
0
    //Cable is set to default position with 0 rotation
    public Cable(CableType cable)
    {
        cableType = cable;
        rotation  = 0;

        SetConnections();
    }
示例#2
0
        public void AddMesurement(string source, string dest, CableType type, int now, double dist, int cop, int cow, double realA, bool result)
        {
            Mesurement m = new Mesurement(Mesurements.Count + 1, source, dest, type, now, dist, cop, cow, realA, result);

            Mesurements.Add(m);
            RefreshId();
        }
示例#3
0
        public void CreateCableTypesDictionary()
        {
            using (var odw = new OracleDatabaseWorker(tbOracleConnectionStringText))
            {
                List <string> types = odw.GetListForDataColumn("Select distinct std_code from cable_Type where std_code is not null order by std_code");

                //type
                var del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var rawData in lst.Where(s => s != ""))
                        {
                            // add to dictionary
                            string normalizedData = GetAllUntilNumber(rawData.Trim());
                            CableTypeDictionary[rawData.Trim()] = normalizedData;
                            if (!uow.Query <CableType>().Any(x => "" + x.TypeName == normalizedData))
                            {
                                CableType cs = new CableType(uow)
                                {
                                    TypeName = normalizedData, TypeDescription = rawData
                                };
                                uow.CommitChanges();
                            }
                        }
                    }
                    return(true);
                });
                del.Invoke(types);//**

                NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"TYPES DICTIONARY {CableTypeDictionary.Count} items from {types.Count} total.\n{string.Join(" ", CableTypeDictionary.Select(x => $"\t{x.Key} ->  {x.Value}\t|"))}");
            }
        }
示例#4
0
    public Cable(CableType cable, int r)
    {
        cableType = cable;
        rotation  = r * 90;

        SetConnections();
        Rotate(r);
    }
示例#5
0
 /// <summary>
 /// Create a new socket outlet.
 /// </summary>
 /// <param name="Plug">The type of the charging plug.</param>
 /// <param name="Cable">The type of the charging cable.</param>
 /// <param name="CableLength">The length of the charging cable [mm].</param>
 public SocketOutlet(PlugTypes Plug,
                     CableType Cable    = CableType.unspecified,
                     Double CableLength = 0)
 {
     this._Plug        = Plug;
     this._Cable       = Cable;
     this._CableLength = CableLength;
 }
示例#6
0
        /***************************************************/
        /**** Constructors                              ****/
        /***************************************************/


        //Main constructor setting all of the properties of the object
        public CableSection(
            IMaterialFragment material,
            int numberOfCables,
            double cableDiameter,
            CableType cableType,
            double breakingLoad,

            double area,
            double rgy,
            double rgz,
            double j,
            double iy,
            double iz,
            double iw,
            double wely,
            double welz,
            double wply,
            double wplz,
            double centreZ,
            double centreY,
            double vz,
            double vpz,
            double vy,
            double vpy,
            double asy,
            double asz)

        {
            Material       = material;
            CableDiameter  = cableDiameter;
            NumberOfCables = numberOfCables;
            CableType      = cableType;
            BreakingLoad   = breakingLoad;

            Area    = area;
            Rgy     = rgy;
            Rgz     = rgz;
            J       = j;
            Iy      = iy;
            Iz      = iz;
            Iw      = iw;
            Wely    = wely;
            Welz    = welz;
            Wply    = wply;
            Wplz    = wplz;
            CentreZ = centreZ;
            CentreY = centreY;
            Vz      = vz;
            Vpz     = vpz;
            Vy      = vy;
            Vpy     = vpy;
            Asy     = asy;
            Asz     = asz;
        }
示例#7
0
        /// <summary>
        /// 获取某一工序中具体的一种线材的参数
        /// </summary>
        /// <param name="cableName"></param>
        /// <param name="processName"></param>
        /// <returns></returns>
        public static CableType GetCableType(string cableName, string processName)
        {
            CableType cableType = null;
            string    filePath  = @"Config\CableTypes\" + processName + "\\" + cableName + ".xml";

            if (File.Exists(filePath))
            {
                cableType             = new CableType();
                cableType.Name        = cableName;
                cableType.ProcessName = processName;
                cableType.Patterns    = XmlUtil.GetModelFromXmlFile <DataPattern>(filePath);
            }
            return(cableType);
        }
示例#8
0
    Material GetMaterialByType(CableType _type)
    {
        Material toReturn = null;

        switch (_type)
        {
        case CableType.Red1:
            toReturn = new Material(RedCab_Mat);
            break;

        case CableType.Yellow2:
            toReturn = new Material(YellowCab_Mat);
            break;

        case CableType.Green3:
            toReturn = new Material(GreenCab_Mat);
            break;

        case CableType.Blue4:
            toReturn = new Material(BlueCab_Mat);
            break;

        case CableType.White5:
            toReturn = new Material(WhiteCab_Mat);
            break;

        case CableType.Brown6:
            toReturn = new Material(BrownCab_Mat);
            break;

        default:
            break;
        }

        return(toReturn);
    }
示例#9
0
        /// <summary>
        /// 读取某一工序所有线材的参数信息
        /// </summary>
        /// <param name="processName"></param>
        /// <returns></returns>
        public static List <CableType> GetCableTypes(string processName)
        {
            List <CableType> cableTypes = new List <CableType>();
            string           dirPath    = @"Config\CableTypes\" + processName;

            if (!Directory.Exists(dirPath))
            {
                try
                {
                    Directory.CreateDirectory(dirPath);
                }
                catch
                {
                    return(cableTypes);
                }
            }

            string[] files = Directory.GetFiles(dirPath, "*.xml", SearchOption.TopDirectoryOnly);
            foreach (string filePath in files)
            {
                try
                {
                    CableType cableType = new CableType();
                    cableType.Name        = filePath.Split('\\').Last().Split('.').First();
                    cableType.ProcessName = processName;

                    cableType.Patterns = XmlUtil.GetModelFromXmlFile <DataPattern>(filePath);
                    if (cableType.Patterns != null && cableType.Patterns.Count > 0)
                    {
                        cableTypes.Add(cableType);
                    }
                }
                catch { }
            }
            return(cableTypes);
        }
示例#10
0
        public void AddCableType(string name, double a)
        {
            CableType c = new CableType(name, a);

            CableTypes.Add(c);
        }
示例#11
0
    void InitCables()
    {
        int toConnectCabs = chosenSetup.ConnectedCables.Count;
        int toDetachCabs  = chosenSetup.DetachedCables.Count;
        int noCab         = Components.Cables.Count - 2 /*Per i cavi virtuali dei posti 1 e 5*/ - toConnectCabs - toDetachCabs;

        List <int> alreadySetCabs = new List <int>()
        {
            1, 5
        };

        while (toConnectCabs + toDetachCabs + noCab > 0)
        {
            //choose an avaiable cable
            int        cabIndex = Random.Range(0, Components.Cables.Count);
            GameObject cab      = Components.Cables[cabIndex];
            if (alreadySetCabs.Contains(cabIndex))
            {
                if (alreadySetCabs.Count >= Components.Cables.Count)
                {
                    Debug.LogError("Impossible Setup");
                    return;
                }
                continue;
            }
            else
            {
                alreadySetCabs.Add(cabIndex);
            }

            if (toConnectCabs > 0)
            {
                cab.SetActive(true);

                toConnectCabs--;
                CableType    cabColor    = chosenSetup.ConnectedCables[toConnectCabs];
                MeshRenderer cabRenderer = cab.GetComponentInChildren <MeshRenderer>();
                cabRenderer.material = GetMaterialByType(cabColor);

                SelectableSwitch cabSwitch = cab.GetComponentInChildren <SelectableSwitch>();
                cabSwitch.Init(this, new CabSwitchData()
                {
                    CabType = cabColor, CabID = cabIndex
                });
                cabSwitch.selectStatus = true;
                switches.Add(cabSwitch);
            }
            else if (toDetachCabs > 0)
            {
                cab.SetActive(true);

                toDetachCabs--;
                CableType    cabColor    = chosenSetup.DetachedCables[toDetachCabs];
                MeshRenderer cabRenderer = cab.GetComponentInChildren <MeshRenderer>();
                cabRenderer.material = GetMaterialByType(cabColor);

                SelectableSwitch cabSwitch = cab.GetComponentInChildren <SelectableSwitch>();
                cabSwitch.Init(this, new CabSwitchData()
                {
                    CabType = cabColor, CabID = cabIndex
                });
                cabSwitch.selectStatus = false;
                switches.Add(cabSwitch);
            }
            else
            {
                noCab--;
                cab.SetActive(false);
            }
        }
    }
示例#12
0
        private async Task CableDefaults()
        {
            using (var odw = new OracleDatabaseWorker(tbOracleConnectionStringText))
            {
                List <string> classes        = odw.GetListForDataColumn(@"select distinct class from (
                                                                                Select  case when cable_type=1 then 'COPPER' else case when cable_type=2 then 'FIBER' else 'UNKNOWN' end end as Class
                                                                                from cable_Type where cable_type is not null order by cable_type)");
                List <string> sizes          = odw.GetListForDataColumn("Select distinct capacity from cable_type where capacity is not null order by capacity");
                List <string> wiredimensions = odw.GetListForDataColumn("Select diameter from cable_type where diameter is not null order by diameter");
                List <string> media          = new List <string>()
                {
                    "Media"
                };
                List <string> types = odw.GetListForDataColumn("Select distinct std_code from cable_Type where std_code is not null order by std_code");
                ;
                List <string> statuses = odw.GetListForDataColumn(@"select distinct CABLESTATUS from(
                                                                                            select CASE cast(cs.Status as varchar(50)) WHEN '5' 
                                                                                            THEN 'Active' 
                                                                                            when '6' then 'UNKNOWN'
                                                                                            else cast(cs.Status as varchar(50)) end   AS CABLESTATUS
                                                                                            from cable_seg cs)
                                                                                                                                ");

                List <string> classrelationships = odw.GetListForDataColumn(@"select  Capacity||'|'||std_code||'|'||class  as sizetypeclass from(
                Select DISTINCT  case when Capacity is null then 0 else Capacity end as CAPACITY,case when  std_code is null then  'null' else std_code end as std_code, case when cable_type=1 then 'COPPER' else case when cable_type=2 then 'FIBER' else 'UNKNOWN' end end as CLASS
                from cable_Type where capacity is not null order by capacity)");
                /// will be size|type|class if size is null 0, if type null then 'null'
                List <string> routes = odw.GetDistinctDataColumn(cablesWithOUTSpansTable, "CABLEROUTE");

                //run types through ffunction to normalize the names
                //   temptypes.ForEach((x) => types.Add(ImporterHelper.GetAllUntilNumber(x)));
                //extras
                //class
                var del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst.Where(s => s != ""))
                        {
                            if (!uow.Query <CableClass>().Any(x => x.TypeName == str))
                            {
                                CableClass cs = new CableClass(uow)
                                {
                                    TypeName = str, TypeDescription = str
                                };
                                uow.CommitChanges();
                            }
                        }
                    }
                    return(true);
                });
                del.Invoke(classes);//**

                //type
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var rawData in lst.Where(s => s != ""))
                        {
                            // add to dictionary
                            string normalizedData = GetAllUntilNumber(rawData.Trim());
                            CableTypeDictionary[rawData.Trim()] = normalizedData;
                            if (!uow.Query <CableType>().Any(x => "" + x.TypeName == normalizedData))
                            {
                                CableType cs = new CableType(uow)
                                {
                                    TypeName = normalizedData, TypeDescription = rawData
                                };
                                uow.CommitChanges();
                            }
                        }
                    }
                    return(true);
                });
                del.Invoke(types);//**

                //size
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst.Where(s => s != ""))
                        {
                            if (!uow.Query <CableSize>().Any(x => x.Code == str))
                            {
                                CableSize cs = new CableSize(uow)
                                {
                                    Count = int.Parse(str), Code = str
                                };
                                uow.CommitChanges();
                            }
                        }
                    }
                    return(true);
                });
                del.Invoke(sizes);//**
                //media
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst
                                 .Where(s => s != ""))
                        {
                            if (!uow.Query <CableMedia>().Any(x => x.TypeName == str))

                            {
                                CableMedia cs = new CableMedia(uow)
                                {
                                    TypeName = str, TypeDescription = str
                                };
                                //put media in all classes for this one
                                foreach (var item in uow.Query <CableClass>())
                                {
                                    item.CableMedia.Add(cs);
                                }
                                uow.CommitChanges();
                            }
                        }
                        return(true);
                    }
                });
                del.Invoke(media);//**

                //wiredimensions
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst.Where(s => s != ""))
                        {
                            if (!uow.Query <WireDimension>().Any(x => "" + x.Gauge == str))
                            {
                                WireDimension cs = new WireDimension(uow)
                                {
                                    Gauge = str
                                };
                                uow.CommitChanges();
                            }
                        }
                    }
                    return(true);
                });
                del.Invoke(wiredimensions);//**

                //routes
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst
                                 .Where(s => s != ""))
                        {
                            if (!uow.Query <Route>().Any(x => x.Name == str))
                            {
                                Route cs = new Route(uow)
                                {
                                    Name = str
                                };
                                uow.CommitChanges();
                            }
                        }
                    }
                    return(true);
                });
                IAsyncResult routeres = del.BeginInvoke(routes, null, null);//**

                //status
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst
                                 .Where(s => s != ""))
                        {
                            if (!uow.Query <CableStatus>().Any(x => x.StatusName == str))
                            {
                                CableStatus cs = new CableStatus(uow)
                                {
                                    StatusName = str
                                };
                                uow.CommitChanges();
                            }
                        }
                        return(true);
                    }
                });
                del.Invoke(statuses);//**

                //have to wait for this stuff to finish before the next

                //size typ class rel
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        CableClass cclass = null;
                        CableMedia cmedia = uow.Query <CableMedia>()
                                            .FirstOrDefault(x => x.TypeName == "Media");
                        foreach (var str in lst
                                 .Where(s => s != ""))
                        {
                            //pipdelimited str   Capacity||'|'||std_code||'|'||class  as size|type|class
                            var arr     = str.Split('|');
                            string size = arr[0], cls = arr[2], type = "";
                            if (DataConvert.CableTypeDictionary.ContainsKey(arr[1].Trim()))
                            {
                                type = DataConvert.CableTypeDictionary[arr[1].Trim()];
                            }

                            cclass          = uow.Query <CableClass>().FirstOrDefault(x => x.TypeName == cls);
                            CableType ctype = uow.Query <CableType>().FirstOrDefault(x => x.TypeName == type);
                            CableSize csize = uow.Query <CableSize>().FirstOrDefault(x => x.Count.ToString() == size);
                            if (cclass != null)
                            {
                                //add size and tyype to class but mae sur we don't get dupes
                                if (ctype != null && !cclass.CableTypes.Contains(ctype))
                                {
                                    cclass.CableTypes.Add(ctype);
                                }
                                if (csize != null && !cclass.CableSizes.Contains(csize))
                                {
                                    cclass.CableSizes.Add(csize);
                                }
                                uow.CommitChanges();
                            }
                        }
                        //add media
                        if (cmedia != null)
                        {
                            if (!cclass.CableMedia.Contains(cmedia))
                            {
                                cclass.CableMedia.Add(cmedia);
                            }
                        }
                        return(true);
                    }
                });
                del.Invoke(classrelationships);
                NewNetServices.Module.Core.StaticHelperMethods.WriteOut($"TYPES DICTIONARY {CableTypeDictionary.Count} items from {types.Count} total.\n{string.Join(" ", CableTypeDictionary.Select(x => $"\t{x.Key} ->  {x.Value}\t|"))}");
                await Task.FromResult(routeres);
            }
        }
示例#13
0
        public async Task DesignationGroupDefaults()
        {
            using (var odw = new OracleDatabaseWorker(tbOracleConnectionStringText))
            {
                //List<string> cableclass = odw.GetListForDataColumn(@"select distinct class from designationgroups");
                //List<string> cablesizes = odw.GetListForDataColumn(@"SELECT distinct mc.MaxCount  from designationgroups");
                List <string> cablestatuses = new List <string>()
                {
                    "Active"
                };

                List <string> classrelationships = odw.GetListForDataColumn(@"select distinct classsize from
(SELECT   class ||'|'|| MaxCount as classsize from designationgroups where maxcount is not null order by maxcount)"); /// will be size|type|class if size is null 0, if type null then 'null'


                //status
                var del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        foreach (var str in lst
                                 .Where(s => s != ""))
                        {
                            if (!uow.Query <CableStatus>().Any(x => x.StatusName == str))
                            {
                                CableStatus cs = new CableStatus(uow)
                                {
                                    StatusName = str
                                };
                                uow.CommitChanges();
                            }
                        }
                        return(true);
                    }
                });
                IAsyncResult statusres = del.BeginInvoke(cablestatuses, null, null);


                //size typ class rel
                del = new MyDelegate((lst) =>
                {
                    using (var uow = new UnitOfWork(Tsdl))
                    {
                        CableClass cclass = null;
                        CableMedia cmedia = uow.Query <CableMedia>().FirstOrDefault(x => x.TypeName == "Media");
                        foreach (var str in lst
                                 .Where(s => s != ""))
                        {
                            //pipdelimited str
                            var arr = str.Split('|');
                            //making type the same as the class per andyrew
                            cclass          = uow.Query <CableClass>().FirstOrDefault(x => x.TypeName == arr[0]);
                            CableType ctype = uow.Query <CableType>().FirstOrDefault(x => x.TypeName == arr[0]);
                            //create class
                            if (cclass == null)
                            {
                                cclass = new CableClass(uow)
                                {
                                    TypeName = arr[0], TypeDescription = arr[0]
                                };
                                if (cmedia != null)
                                {
                                    cclass.CableMedia.Add(cmedia);
                                }
                                uow.CommitChanges();
                            }
                            //create type
                            if (ctype == null)
                            {
                                ctype = new CableType(uow)
                                {
                                    TypeName = arr[0], TypeDescription = arr[0]
                                };
                                cclass.CableTypes.Add(ctype);
                                uow.CommitChanges();
                            }

                            //have to do his check so that we associate desgroups sizes and classes separate from regular cables
                            CableSize csize = cclass.CableSizes.FirstOrDefault(x => x.Count.ToString() == arr[1]);
                            //create size
                            if (csize == null && int.TryParse(arr[1], out int count))
                            {
                                csize = new CableSize(uow)
                                {
                                    Count = count, Code = "" + count
                                };
                                cclass.CableSizes.Add(csize);
                                uow.CommitChanges();
                            }
                            uow.CommitChanges();
                        }

                        return(true);
                    }
                });
                IAsyncResult relres = del.BeginInvoke(classrelationships, null, null);

                await Task.FromResult(statusres);

                await Task.FromResult(relres);
            }
        }