Пример #1
0
 /// <summary>隐藏界面</summary>
 public static void HidePanel(string name)
 {
     if (m_panelList.ContainsKey(name))
     {
         m_panelList[name].SetActive(false);
     }
 }
Пример #2
0
        private void RemovePlayerByUserId(uint userId)
        {
            int i = GetPlayerIndexByUserId(userId);

            if (i >= 0)
            {
                m_data.players.RemoveAt(i);
            }

            if (m_mapUserId2Address.ContainsKey(userId))
            {
                m_mapUserId2Address.Remove(userId);
            }
        }
Пример #3
0
 public static StoreInfo GetStoreInfo(int id)
 {
     if (storeList.ContainsKey(id))
     {
         return(storeList[id]);
     }
     return(null);
 }
Пример #4
0
    public static bool HasView(string name)
    {
        if (m_panelList.ContainsKey(name) || m_panelExitList.ContainsKey(name))
        {
            return(true);
        }

        return(false);
    }
Пример #5
0
        internal static void ThreadInit()
        {
            int id = Thread.CurrentThread.ManagedThreadId;

            if (!instanceList.ContainsKey(id))
            {
                instanceList.Add(id, new Instance());
            }
        }
Пример #6
0
        public int Load(object sender, object arg)
        {
            DictionaryEx dic    = arg as DictionaryEx;
            int          module = (int)dic["module"];//  module=1 ,slot=2
            int          thread = (int)dic["slot"];

            if (dic.ContainsKey("module"))
            {
                module = (int)dic["module"];
            }

            if (dic.ContainsKey("thread"))
            {
                thread = (int)dic["thread"];
            }

            m_TestEngine  = new TestEngine(thread);
            dic["engine"] = m_TestEngine; //St
            return(0);
        }
Пример #7
0
 public void SetConfig(DictionaryEx dic)
 {
     dicConfig        = dic;
     txtDatapath.Text = dic[tmMarcos.kConfigLogDir] as string;
     try
     {
         if (dic.ContainsKey(tmMarcos.kConfigStationName))
         {
             textBoxStationName.Text = dic[tmMarcos.kConfigStationName] as string;
         }
         if (dic.ContainsKey(tmMarcos.kConfigScanBarcode))
         {
             cbScanBarCode.Checked = (bool)((int)dic[tmMarcos.kConfigScanBarcode] == 0?false:true);
         }
     }
     catch (Exception)
     {
         cbScanBarCode.Checked = true;
     }
 }
Пример #8
0
        public Color GetUniqueColor(int colorId)
        {
            if (m_mapColor.ContainsKey(colorId))
            {
                return(m_mapColor[colorId]);
            }

            Color c = new Color(random.Rnd(), random.Rnd(), random.Rnd());

            m_mapColor.Add(colorId, c);
            return(c);
        }
Пример #9
0
        void LoadConfig(string file)
        {
            string[] key =
            {
                tmMarcos.kConfigLogDir,
                tmMarcos.kConfigStationName,
                tmMarcos.kConfigLineName,
                "profile_path",
                tmMarcos.kConfigTestFlowPath,
            };
            string[] val =
            {
                "C:\\work",                         //默认路径为C:\\work
                "Unknown Station",
                "Unknown Line",
                Path.Combine(tmEnvironment.AppDir(),"Profile\\Glass_Alsar_test.lua"),
                Path.Combine(tmEnvironment.AppDir(),"CVS"),
            };

            try
            {
                if (!File.Exists(file)) // using default
                {
                    for (int i = 0; i < key.Length; i++)
                    {
                        m_dicConfig[key[i]] = val[i];
                    }
                }
                else
                {
                    m_dicConfig.ReadXmlFile(file);
                    for (int i = 0; i < key.Length; i++)
                    {
                        if (!m_dicConfig.ContainsKey(key[i]))
                        {
                            m_dicConfig[key[i]] = val[i];
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                for (int i = 0; i < key.Length; i++)
                {
                    m_dicConfig[key[i]] = val[i];
                }
            }
            finally
            {
            }
        }
Пример #10
0
        public static void CreateView(string resPath, string resDefaultPath, EntityObject entity, Transform parent = null)
        {
            ViewObject obj = null;

            //
            string recycleType  = resPath;
            bool   userRecycler = true;

            obj = mRecycler.Pop(recycleType) as ViewObject;
            if (obj == null)
            {
                userRecycler = false;
                //TODO
                obj = InstanceViewFromPrefab(recycleType, resDefaultPath);
            }
            else
            {
                if (!obj.gameObject.activeSelf)
                {
                    obj.gameObject.SetActive(true);
                }

                if (parent != null)
                {
                    obj.transform.SetParent(parent, false);
                }
                else
                {
                    obj.transform.SetParent(mViewRoot, false);
                }

                obj.CreateInFactory(entity, recycleType);

                if (EnableLog && LDebugger.EnableLog)
                {
                    LDebugger.Log(LOG_TAG, "CreateView() {0}:{1}->{2}:{3},UseRecycler :{4}",
                                  entity.GetType().Name,
                                  entity.GetHashCode(),
                                  obj.GetRecycleType(),
                                  obj.GetInstanceID(),
                                  userRecycler);
                }
                if (mObjectsMap.ContainsKey(entity))
                {
                    LDebugger.LogError(LOG_TAG, "CreateView() 不应该存在重复的映射");
                }
                mObjectsMap[entity] = obj;
            }
        }
Пример #11
0
        public static void CreateView(string resPath, string resDefaultPath, EntityObject entity, Transform parent = null)
        {
            ViewObject viewObj     = null;
            string     recycleType = resPath;
            bool       useRecycler = true;

            viewObj = m_recycler.Pop(recycleType) as ViewObject;
            if (viewObj == null)
            {
                useRecycler = false;
                viewObj     = InstanceViewFromPrefab(recycleType, resDefaultPath);
            }

            if (viewObj == null)
            {
                return;
            }

            if (!viewObj.gameObject.activeSelf)
            {
                viewObj.gameObject.SetActive(true);
            }

            viewObj.transform.SetParent(parent != null ? parent : m_viewRoot, false);

            viewObj.CreateInFactory(entity, recycleType);

            if (EnableLog && Debugger.EnableLog)
            {
                Debugger.Log(LOG_TAG, "CreateView() {0}:{1} -> {2}:{3}, UseRecycler:{4}",
                             entity.GetType().Name, entity.GetHashCode(),
                             viewObj.GetRecycleType(), viewObj.GetInstanceID(),
                             useRecycler);
            }

            if (m_objMap.ContainsKey(entity))
            {
                Debugger.LogError(LOG_TAG, "CreateView() 不应该存在重复的映射!");
            }

            m_objMap[entity] = viewObj;
        }
Пример #12
0
            private static IReadOnlyDictionary <string, TEnum> GetNameValuesCore(bool ignoreCase)
            {
#if NET45_OR_GREATER || TARGETS_NETSTANDARD || TARGETS_NETCOREAPP
                var result = new Dictionary <string, TEnum>(ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
#else
                var result = new DictionaryEx <string, TEnum>(ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
#endif

                var names  = Enum.GetNames(typeof(TEnum));
                var values = GetValuesCore();
                for (var i = 0; i < names.Length; i++)
                {
                    // DONTTOUCH: case may be ignored
                    if (result.ContainsKey(names[i]))
                    {
                        continue;
                    }

                    result.Add(names[i], values[i]);
                }

                return(result);
            }
Пример #13
0
            private static IReadOnlyDictionary <string, TEnum> GetNameValuesCore(bool ignoreCase)
            {
                var result =
#if LESSTHAN_NET45
                    new DictionaryEx <string, TEnum>(ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
#else
                    new Dictionary <string, TEnum>(ignoreCase ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal);
#endif

                var names  = Enum.GetNames(typeof(TEnum));
                var values = (TEnum[])Enum.GetValues(typeof(TEnum));
                for (var i = 0; i < names.Length; i++)
                {
                    // DONTTOUCH: case may be ignored
                    if (result.ContainsKey(names[i]))
                    {
                        continue;
                    }

                    result.Add(names[i], values[i]);
                }

                return(result);
            }
Пример #14
0
 public bool ContainsKey(TKey key)
 {
     // key could  be null
     return(key == null ? _hasNull : _wrapped.ContainsKey(key));
 }
Пример #15
0
        static void hashtable_rehash2_benchmark_impl()
        {
            int kHeaderFieldSize = header_fields.Length;

#if DEBUG
            int kRepeatTimes = 200;
#else
            int kRepeatTimes = (kIterations / kHeaderFieldSize / 2);
#endif

            String[] field_str = new String[kHeaderFieldSize];
            String[] index_str = new String[kHeaderFieldSize];
            for (int i = 0; i < kHeaderFieldSize; ++i)
            {
#if NO_STRING_INTERNING
                field_str[i] = String.Format("{0}", header_fields[i].ToCharArray());
                index_str[i] = String.Format("{0}", i);
#else
                field_str[i] = String.Intern(header_fields[i]);
                index_str[i] = String.Intern(String.Format("{0}", i));
#endif
            }

            {
                long      checksum  = 0;
                int       buckets   = 128;
                double    totalTime = 0.0;
                Stopwatch sw        = new Stopwatch();

                sw.Restart();
                for (int i = 0; i < kRepeatTimes; ++i)
                {
                    DictionaryEx <String, String> dict = new DictionaryEx <String, String>();
                    for (int j = 0; j < kHeaderFieldSize; ++j)
                    {
                        if (!dict.ContainsKey(field_str[j]))
                        {
                            dict.Add(field_str[j], index_str[j]);
                        }
                    }
                    checksum += dict.Count();
                    checksum += dict.BucketCount;

                    buckets = 128;
                    dict.Resize(buckets);
                    checksum += dict.BucketCount;

                    for (int j = 0; j < 7; ++j)
                    {
                        buckets *= 2;
                        dict.Resize(buckets);
                        checksum += dict.BucketCount;
                    }
                }
                sw.Stop();

                totalTime += sw.Elapsed.TotalMilliseconds;

                //Console.Write("-------------------------------------------------------------------------\n");
                Console.Write("  {0,-28}  ", "DictionaryEx<String, String>");
                Console.Write("sum = {0,-10:g}  time: {1,8:f} ms\n", checksum, totalTime);
                //Console.Write("-------------------------------------------------------------------------\n");
                Console.Write("\n");
            }
        }
Пример #16
0
        public void Init()
        {
            try
            {
                m_object[0].CloseSerial();
                if (mConfigInfo.ContainsKey(tmMarcos.kDUT1Config))
                {
                    m_object[0].m_ComPort.Setting = mConfigInfo[tmMarcos.kDUT1Config].ToString();
                }
                else
                {
                    mConfigInfo[tmMarcos.kDUT1Config] = "38400,N,8,1";
                }
                if (mConfigInfo[tmMarcos.kDUT1Com] != null)
                {
                    m_object[0].m_ComPort.PortName = mConfigInfo[tmMarcos.kDUT1Com].ToString();
                }
                m_object[0].m_ComPort.Open();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Open DUTCOM1 Fail " + e.Message + "(E0005)");
            }

            try
            {
                m_object[1].CloseSerial();
                if (mConfigInfo.ContainsKey(tmMarcos.kDUT2Config))
                {
                    m_object[1].m_ComPort.Setting = mConfigInfo[tmMarcos.kDUT2Config].ToString();
                }
                else
                {
                    mConfigInfo[tmMarcos.kDUT2Config] = "38400,N,8,1";
                }
                if (mConfigInfo[tmMarcos.kDUT2Com] != null)
                {
                    m_object[1].m_ComPort.PortName = mConfigInfo[tmMarcos.kDUT2Com].ToString();
                }
                m_object[1].m_ComPort.Open();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Open DUTCOM2 Fail " + e.Message + "(E0005)");
            }

            try
            {
                m_object[2].CloseSerial();
                if (mConfigInfo.ContainsKey(tmMarcos.kDUT3Config))
                {
                    m_object[2].m_ComPort.Setting = mConfigInfo[tmMarcos.kDUT3Config].ToString();
                }
                else
                {
                    mConfigInfo[tmMarcos.kDUT3Config] = "38400,N,8,1";
                }
                if (mConfigInfo[tmMarcos.kDUT3Com] != null)
                {
                    m_object[2].m_ComPort.PortName = mConfigInfo[tmMarcos.kDUT3Com].ToString();
                }
                m_object[2].m_ComPort.Open();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Open DUTCOM3 Fail " + e.Message + "(E0005)");
            }

            try
            {
                m_object[3].CloseSerial();
                if (mConfigInfo.ContainsKey(tmMarcos.kDUT4Config))
                {
                    m_object[3].m_ComPort.Setting = mConfigInfo[tmMarcos.kDUT4Config].ToString();
                }
                else
                {
                    mConfigInfo[tmMarcos.kDUT4Config] = "38400,N,8,1";
                }
                if (mConfigInfo[tmMarcos.kDUT4Com] != null)
                {
                    m_object[3].m_ComPort.PortName = mConfigInfo[tmMarcos.kDUT4Com].ToString();
                }
                m_object[3].m_ComPort.Open();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Open DUTCOM4 Fail " + e.Message + "(E0005)");
            }

            try
            {
                m_object[4].CloseSerial();
                if (mConfigInfo.ContainsKey(tmMarcos.kDUT5Config))
                {
                    m_object[4].m_ComPort.Setting = mConfigInfo[tmMarcos.kDUT5Config].ToString();
                }
                else
                {
                    mConfigInfo[tmMarcos.kDUT5Config] = "38400,N,8,1";
                }
                if (mConfigInfo[tmMarcos.kDUT5Com] != null)
                {
                    m_object[4].m_ComPort.PortName = mConfigInfo[tmMarcos.kDUT5Com].ToString();
                }
                m_object[4].m_ComPort.Open();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Open DUTCOM5 Fail " + e.Message + "(E0005)");
            }

            try
            {
                m_object[5].CloseSerial();
                if (mConfigInfo.ContainsKey(tmMarcos.kDUT6Config))
                {
                    m_object[5].m_ComPort.Setting = mConfigInfo[tmMarcos.kDUT6Config].ToString();
                }
                else
                {
                    mConfigInfo[tmMarcos.kDUT6Config] = "38400,N,8,1";
                }
                if (mConfigInfo[tmMarcos.kDUT6Com] != null)
                {
                    m_object[5].m_ComPort.PortName = mConfigInfo[tmMarcos.kDUT6Com].ToString();
                }
                m_object[5].m_ComPort.Open();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Open DUTCOM6 Fail " + e.Message + "(E0005)");
            }
        }
Пример #17
0
        /// <summary>
        /// Expands the current collection of obscuring <see cref="Graph"/> nodes with all neighbors
        /// of the specified node, within maximum world distance from the source node.</summary>
        /// <param name="node">
        /// The <see cref="Graph"/> node whose neighbors to examine.</param>
        /// <remarks><para>
        /// <b>FindObscuringNodes</b> recursively visits all directly connected nodes, and adds them
        /// to an internal collection of obscuring nodes if they are opaque. Nodes which are fully
        /// obscured by other obscuring nodes are removed from the collection.
        /// </para><para>
        /// <b>FindObscuringNodes</b> never revisits nodes that were already examined. All visited
        /// nodes are added to <see cref="NodeArcs"/> for later processing by <see
        /// cref="FindVisibleNodes"/>.</para></remarks>

        private void FindObscuringNodes(T node)
        {
            // get valid neighbors of current node
            IList <T> neighbors = Graph.GetNeighbors(node);

            // recurse into all valid neighbors
            for (int i = 0; i < neighbors.Count; i++)
            {
                T neighbor = neighbors[i];

                // skip source and previously visited nodes
                if (ComparerCache <T> .EqualityComparer.Equals(_source, neighbor) ||
                    _nodeArcs.ContainsKey(neighbor))
                {
                    continue;
                }

                // compute tangential arc and source distance
                NodeArc arc = CreateNodeArc(neighbor);

                // skip nodes beyond maximum distance
                if (_distance > 0 && arc.Distance > _distance)
                {
                    continue;
                }

                // record visited node with tangential arc
                _nodeArcs.Add(neighbor, arc);

                // nothing else to do for transparent nodes
                if (!_isOpaque(neighbor))
                {
                    goto nextNeighbor;
                }

                /*
                 * Try adding current opaque node to list of all obscuring nodes recorded so far.
                 *
                 * If any single recorded node completely obscures the current node, we skip it.
                 * If the current node completely obscures any recorded nodes, we delete those.
                 *
                 * We also clear the VisiblityFraction for all completely obscured nodes (current
                 * or recorded) so we won't waste time testing them again in FindVisibleNodes.
                 */

                foreach (var pair in _obscuringNodes)
                {
                    int result = arc.IsObscured(pair.Value);

                    if (result < 0)
                    {
                        arc._visibleFraction = 0;
                        goto nextNeighbor;
                    }
                    if (result > 0)
                    {
                        pair.Value._visibleFraction = 0;
                        _removeNodes.Add(pair.Key);
                    }
                }

                // remove obscuring nodes that were themselves obscured
                for (int j = 0; j < _removeNodes.Count; j++)
                {
                    _obscuringNodes.Remove(_removeNodes[j]);
                }
                _removeNodes.Clear();

                // add neighbor to obscuring nodes
                _obscuringNodes.Add(neighbor, arc);

nextNeighbor:
                FindObscuringNodes(neighbor);
            }
        }
Пример #18
0
        public GameRecord GetGameRecordByName(string name)
        {
            try
            {
                if (name == null || name.Length == 0)
                {
                    return(null);
                }

                if (!mRecordSet.ContainsKey(name))
                {
                    return(null);
                }
                return(mRecordSet[name]);
            }
            catch (Exception ex)
            {
                LogSystem.Log("Exception:", ex.ToString());
                return(null);
            }
        }
Пример #19
0
        void LoadConfig(string file)
        {
            string[] key =
            {
                tmMarcos.kConfigLogDir,
                tmMarcos.kConfigStationName,
                tmMarcos.kConfigLineName,
                "profile_path",
                tmMarcos.kConfigTestFlowPath,
            };
            string[] val =
            {
                "C:\\work",                         //默认路径为C:\\work
                "Unknown Station",
                "Unknown Line",
                Path.Combine(tmEnvironment.AppDir(),"Profile\\Glass_Alsar_test.lua"),
                Path.Combine(tmEnvironment.AppDir(),"CVS"),
            };

            string[] UUTkey =
            {
                tmMarcos.kUUTEnable0,
                tmMarcos.kUUTEnable1,
                tmMarcos.kUUTEnable2,
                tmMarcos.kUUTEnable3,
                tmMarcos.kUUTEnable4,
                tmMarcos.kUUTEnable5,
            };
            bool[] UUTval =
            {
                true,
                false,
                false,
                false,
                false,
                false,
            };
            try
            {
                if (!File.Exists(file)) // using default
                {
                    for (int i = 0; i < key.Length; i++)
                    {
                        m_dicConfig[key[i]] = val[i];
                    }
                    for (int i = 0; i < UUTkey.Length; i++)
                    {
                        m_dicConfig[UUTkey[i]] = UUTval[i];
                    }
                }
                else
                {
                    m_dicConfig.ReadXmlFile(file);
                    for (int i = 0; i < UUTkey.Length; i++)
                    {
                        m_dicConfig[UUTkey[i]] = UUTval[i];
                    }
                    for (int i = 0; i < key.Length; i++)
                    {
                        if (!m_dicConfig.ContainsKey(key[i]))
                        {
                            m_dicConfig[key[i]] = val[i];
                        }
                    }
                }
                //   System.Windows.Forms.MessageBox.Show("加载配置档案!");
                string   readText = File.ReadAllText("C://1.txt");
                string[] a        = readText.Split(',');
                m_frmState.txtFail.Text         = a[1];
                m_frmState.txtPass.Text         = a[0];
                m_frmState.textBoxPassRate.Text = a[2];
                m_frmState.textBoxFailRate.Text = a[3];
            }
            catch (System.Exception e)
            {
                for (int i = 0; i < key.Length; i++)
                {
                    m_dicConfig[key[i]] = val[i];
                }
                for (int i = 0; i < UUTkey.Length; i++)
                {
                    m_dicConfig[UUTkey[i]] = UUTval[i];
                }
            }
            finally
            {
            }
        }
Пример #20
0
        static void dictionary_rehash2_benchmark()
        {
            Console.Write("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
            Console.Write("  dictionary_rehash2_benchmark()\n");
            Console.Write("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n");
            Console.Write("\n");

            int kHeaderFieldSize = header_fields.Length;

#if DEBUG
            int kRepeatTimes = 200;
#else
            int kRepeatTimes = (kIterations / kHeaderFieldSize / 2);
#endif

            string[] field_str = new string[kHeaderFieldSize];
            string[] index_str = new string[kHeaderFieldSize];
            for (int i = 0; i < kHeaderFieldSize; ++i)
            {
                field_str[i] = header_fields[i];
                index_str[i] = string.Format("{0}", i);
            }

            {
                long      checksum  = 0;
                int       buckets   = 128;
                double    totalTime = 0.0;
                Stopwatch sw        = new Stopwatch();

                sw.Restart();
                for (int i = 0; i < kRepeatTimes; ++i)
                {
                    DictionaryEx <string, string> dict = new DictionaryEx <string, string>();
                    for (int j = 0; j < kHeaderFieldSize; ++j)
                    {
                        if (!dict.ContainsKey(field_str[j]))
                        {
                            dict.Add(field_str[j], index_str[j]);
                        }
                    }
                    checksum += dict.Count();
                    checksum += dict.BucketCount;

                    buckets = 128;
                    dict.Resize(buckets);
                    checksum += dict.BucketCount;

                    for (int j = 0; j < 7; ++j)
                    {
                        buckets *= 2;
                        dict.Resize(buckets);
                        checksum += dict.BucketCount;
                    }
                }
                sw.Stop();

                totalTime += sw.Elapsed.TotalMilliseconds;

                Console.Write("-------------------------------------------------------------------------\n");
                Console.Write(" {0,-28}  ", "DictionaryEx<string, string>");
                Console.Write("sum = {0,-10:g}  time: {1,8:f} ms\n", checksum, totalTime);
                Console.Write("-------------------------------------------------------------------------\n");
                Console.Write("\n");
            }
        }