Exemplo n.º 1
0
        /// <summary>
        /// Gets the variance as a sparse list.
        /// </summary>
        /// <returns>The variance of this distribution.</returns>
        public ISparseList <double> GetVariance()
        {
            ISparseList <double> result = SparseList <double> .Constant(Count, CommonValue.GetVariance());

            var sen = GetSparseEnumerator();

            while (sen.MoveNext())
            {
                result[sen.CurrentIndex] = sen.Current.GetVariance();
            }

            return(result);
        }
Exemplo n.º 2
0
        public List <CommonValue> QueryCommonValues(MachineResults mach)
        {
            using (var cmd = _db.CreateCommand()) {
                cmd.CommandText = "SELECT ExecDateTime,Number,Value"
                                  + " FROM " + dbo + "CommonValues "
                                  + " WHERE ExecDateTime >= @start AND ExecDateTime <= @end AND DeviceID = @dev";
                var param = cmd.CreateParameter();
                param.ParameterName = "@start";
                param.DbType        = DbType.DateTime;
                param.Value         = mach.StartDateTimeLocal;
                cmd.Parameters.Add(param);
                param = cmd.CreateParameter();
                param.ParameterName = "@end";
                param.DbType        = DbType.DateTime;
                param.Value         = mach.EndDateTimeLocal;
                cmd.Parameters.Add(param);
                param = cmd.CreateParameter();
                param.ParameterName = "@dev";
                param.DbType        = DbType.Int64;
                param.Value         = mach.DeviceID;
                cmd.Parameters.Add(param);

                var ret = new List <CommonValue>();

                using (var reader = cmd.ExecuteReader()) {
                    while (reader.Read())
                    {
                        var v = new CommonValue();
                        v.ParentMachineResults = mach;
                        var execLocal = DateTime.SpecifyKind(reader.GetDateTime(0), DateTimeKind.Local);
                        v.ExecDateTimeUTC = execLocal.ToUniversalTime();
                        v.Number          = reader.GetInt32(1);
                        v.Value           = reader.GetValue(2).ToString();
                        ret.Add(v);
                    }
                }

                return(ret);
            }
        }
 /// <summary>
 /// Sets this sparse Gamma list to be a uniform distribution
 /// </summary>
 public void SetToUniform()
 {
     CommonValue.SetToUniform();
     SparseValues.Clear();
 }
Exemplo n.º 4
0
    public static IEnumerator LoadStageScene(string stageName, bool bAdditive)
    {
        if (!m_isLoading)
        {//防止重复加载;
            m_isLoading = true;

            Messenger.Broadcast(MessangerEventDef.StartLoadStage, MessengerMode.DONT_REQUIRE_LISTENER);
            yield return(null);  //Waiting two frame

            yield return(null);

            //IEnumerator itor = LoadEmpty();
            //while (itor.MoveNext())
            //{
            //    yield return null;
            //}

            if (CommonValue.ClearFontCB != null)
            {
                CommonValue.ClearFontCB();//Clear dynamicFont cache
            }

            AsyncOperation async = Resources.UnloadUnusedAssets();
            while (!async.isDone)
            {
                yield return(null);
            }

            IEnumerator itor = null;
            itor = m_sceneAssetLoader.LoadAssetSync(stageName, false, false, DownLoadOrderType.AfterRunning, true);
            while (itor.MoveNext())
            {
                yield return(null);
            }

            AssetBundle sceneBundle = m_sceneAssetLoader.GetMainAssetBundle(stageName);
            if (sceneBundle != null)
            {
                AsyncOperation asyncOp = null;
                if (bAdditive)
                {
                    asyncOp = Application.LoadLevelAdditiveAsync(stageName);
                }
                else
                {
                    asyncOp = Application.LoadLevelAsync(stageName);
                }

                if (asyncOp != null)
                {
                    while (!asyncOp.isDone)
                    {
                        yield return(null);
                    }
                }
                else
                {
                    Debug.LogError("scene level load error: " + stageName);
                }

                m_sceneAssetLoader.UnloadAssetBundle(stageName);
                m_sceneAssetLoader.ReleaseAsset(stageName, null, true);
            }

            m_isLoading = false;
        }
    }
Exemplo n.º 5
0
        IEnumerator LoadWndAsset(string wndName, bool bResident, AssetBundleConfig config)
        {
            IEnumerator itor = null;

            SortedDictionary <int, List <DependencyAsset> > prefabData = config.GetConfig(wndName);

            if (prefabData != null)
            {
                foreach (KeyValuePair <int, List <DependencyAsset> > kvp in prefabData)
                {
                    foreach (DependencyAsset dasset in kvp.Value)
                    {
                        if (m_AssetLoaderMap.ContainsKey(dasset.AssetType))
                        {
                            itor = m_AssetLoaderMap[dasset.AssetType].LoadAssetSync(dasset.AssetName, bResident, false, DownLoadOrderType.AfterRunning, true);
                            while (itor.MoveNext())
                            {
                                yield return(null);
                            }

                            //删除美术图集压缩包(临时解决方案)
                            if (CommonValue.PhoneOS == Phone_OS.Ios)
                            {
                                if (dasset.AssetName.Equals(wndName))
                                {
                                    m_AssetLoaderMap[dasset.AssetType].GetMainAsset(dasset.AssetName);
                                    m_AssetLoaderMap[dasset.AssetType].UnloadAssetBundle(dasset.AssetName);
                                }
                                else
                                {
                                    if (dasset.AssetType == AssetBundleType.Pre)
                                    {
                                        GameObject obj       = m_AssetLoaderMap[dasset.AssetType].GetMainAsset(dasset.AssetName) as GameObject;
                                        Material   spriteMat = CommonValue.GetAtlasMatCB(obj);
                                        if (spriteMat != null)
                                        {
                                            string objPartName = dasset.AssetName.Substring(3);

                                            Material mat      = (Material)m_AssetLoaderMap[AssetBundleType.Material].GetMainAsset("m_" + objPartName);
                                            Texture  mainTex  = (Texture)m_AssetLoaderMap[AssetBundleType.Texture].GetMainAsset("t_" + objPartName);
                                            Texture  alphaTex = (Texture)m_AssetLoaderMap[AssetBundleType.Texture].GetMainAsset("t_" + objPartName + "_a");
                                            if (mat != null)
                                            {
                                                if (mainTex != null)
                                                {
                                                    if (alphaTex != null)
                                                    {
                                                        spriteMat = mat;
                                                        spriteMat.SetTexture("_MainTex", mainTex);
                                                        spriteMat.SetTexture("_AlphaTex", alphaTex);

                                                        m_AssetLoaderMap[AssetBundleType.Material].UnloadAssetBundle("m_" + objPartName);
                                                        m_AssetLoaderMap[AssetBundleType.Texture].UnloadAssetBundle("t_" + objPartName);
                                                        m_AssetLoaderMap[AssetBundleType.Texture].UnloadAssetBundle("t_" + objPartName + "_a");
                                                    }
                                                    else
                                                    {
                                                        Debug.LogWarning("==LoadWndAsset==" + objPartName + ",alphaTex" + alphaTex);
                                                    }
                                                }
                                                else
                                                {
                                                    Debug.LogWarning("==LoadWndAsset==" + objPartName + ",mainTex" + mainTex);
                                                }
                                            }
                                            else
                                            {
                                                Debug.LogWarning("==LoadWndAsset==" + objPartName + ",mat" + mat);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }