Ejemplo n.º 1
0
        /// <summary> 深复制成指定名称的关键字 isDisposeOld 是否清楚原有镜像文件 </summary>
        public T ToTableKey <T>(SimKeyType simType = SimKeyType.EclipseAndSimON, bool isDisposeOld = true) where T : TableKey
        {
            T tb = KeyConfigerFactroy.Instance.CreateKey <T>(typeof(T).Name, simType) as T;

            tb.BuildTableEntity(this.z, this.x, this.y, MmfPath);

            // Todo :复制数据
            for (int ix = 0; ix < this.x; ix++)
            {
                for (int iy = 0; iy < this.y; iy++)
                {
                    for (int iz = 0; iz < this.z; iz++)
                    {
                        //  对值执行func操作
                        tb.Tables[iz].Set(iy, ix, this.Tables[iz].Get(iy, ix).ToString().ToDouble());
                    }
                }
            }

            if (isDisposeOld)
            {
                this.Close();

                this.Dispose();
            }

            return(tb);
        }
Ejemplo n.º 2
0
        /// <summary> 创建关键字方法 </summary>
        public bool IsRegister(string keyName, SimKeyType simType = SimKeyType.Eclipse)
        {
            if (simType == SimKeyType.Eclipse)
            {
                return(KeyConfigerFactroy.Instance.EclipseKeyFactory.IsRegisterKey(keyName) || KeyConfigerFactroy.Instance.EclipseKeyFactory.IsRegisterKey(keyName));
            }
            else if (simType == SimKeyType.SimON)
            {
                return(KeyConfigerFactroy.Instance.EclipseKeyFactory.IsRegisterKey(keyName) || KeyConfigerFactroy.Instance.EclipseKeyFactory.IsRegisterKey(keyName));
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// <summary> 利用数模文件异步创建指定大小栈的内存模型 </summary>
        public INCLUDE ThreadLoadFromFile(INCLUDE include, string pfilePath, SimKeyType keyType = SimKeyType.Eclipse, int stactSize = 4194304)
        {
            include.FileName = Path.GetFileName(pfilePath);

            include.FilePath = pfilePath;

            if (include.BaseFile == null)
            {
                if (keyType == SimKeyType.Eclipse)
                {
                    EclipseData ecl = new EclipseData();
                    include.BaseFile = ecl;
                }
                else if (keyType == SimKeyType.SimON)
                {
                    SimONData simon = new SimONData();
                    include.BaseFile = simon;
                }
            }


            Thread thread = new Thread(() => include.ReadFromStream(), stactSize);// 4mb栈

            thread.Start();

            while (true)
            {
                if (thread.ThreadState == ThreadState.Stopped)
                {
                    break;
                }
            }


            return(include);
        }
Ejemplo n.º 4
0
        /// <summary> 创建关键字方法 </summary>
        public BaseKey CreateKey <T>(string keyName, SimKeyType simType = SimKeyType.Eclipse) where T : BaseKey
        {
            if (simType == SimKeyType.Eclipse)
            {
                //  如果是Eclipse注册关键字 直接创建
                if (_eclipseKeyFactory.IsRegisterKey(keyName))
                {
                    return(_eclipseKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  不是Eclipse注册关键字 在公用关键字中找
                if (_publicKeyFactory.IsRegisterKey(keyName))
                {
                    return(_publicKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  如果都不是走后面UnkownKey
            }
            else if (simType == SimKeyType.SimON)
            {
                //  如果是SimON注册关键字 直接创建
                if (_simONKeyFactory.IsRegisterKey(keyName))
                {
                    return(_simONKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  不是Eclipse注册关键字 在公用关键字中找
                if (_publicKeyFactory.IsRegisterKey(keyName))
                {
                    return(_publicKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  如果是Eclipse注册关键字 直接创建
                if (_eclipseKeyFactory.IsRegisterKey(keyName))
                {
                    return(_eclipseKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  如果都不是走后面UnkownKey
            }
            else if (simType == SimKeyType.EclipseAndSimON)
            {
                //  如果是Eclipse注册关键字 直接创建
                if (_eclipseKeyFactory.IsRegisterKey(keyName))
                {
                    return(_eclipseKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  如果是SimON注册关键字 直接创建
                if (_simONKeyFactory.IsRegisterKey(keyName))
                {
                    return(_simONKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }

                //  不是Eclipse注册关键字 在公用关键字中找
                if (_publicKeyFactory.IsRegisterKey(keyName))
                {
                    return(_publicKeyFactory.CreateKey <BaseKey>(keyName) as T);
                }
            }

            UnkownKey unkownKey = new UnkownKey(KeyChecker.FormatKey(keyName));

            return(unkownKey);
        }
Ejemplo n.º 5
0
        /// <summary> 读取关键字内容 (具体关键字读取方法不同)  return  用于关键字传递 </summary>
        public virtual BaseKey ReadKeyLine(StreamReader reader)
        {
            string tempStr = string.Empty;

            #region - 读取数据 -

            while (!reader.EndOfStream)
            {
                // HTodo  :读取数据要处理的方法 一般用来截取前面空格判断是否解析成关键字
                tempStr = this.eachLineCmdHandler(reader.ReadLine());

                try
                {
                    // HTodo  :当前关键字用来判断文本是否为关键字的方法
                    if (this.IsKeyChar(tempStr))
                    {
                        #region - 交接关键字 -

                        // Todo :没有找到主文件默认Eclipse关键字
                        SimKeyType typesim = this.baseFile == null ? SimKeyType.Eclipse : this.baseFile.SimKeyType;

                        BaseKey newKey = KeyConfigerFactroy.Instance.CreateKey <BaseKey>(tempStr, typesim);

                        LogProviderHandler.Instance.OnRunLog("", "正在读取关键字 - " + newKey.Name);

                        BaseKey perTempKey = this;

                        if (this._builderHandler != null)
                        {
                            // Todo :当碰到新关键字 触发本节点构建方法
                            BaseKey temp = this._builderHandler.Invoke(this, newKey);

                            if (temp != null)
                            {
                                perTempKey = temp;
                            }

                            if (this.baseFile != null && this is IProductTime)
                            {
                                // HTodo  :将读取到的生产信息记录到主文件中,用于解析TSTEP
                                IProductTime p = this as IProductTime;
                                this.baseFile.ReadTempTime = p.DateTime;
                            }
                        }

                        if (newKey._createrHandler != null)
                        {
                            // Todo :触发新关键字构建节点结构的方法
                            newKey._createrHandler.Invoke(perTempKey, newKey);
                        }


                        // Todo :读到未解析关键字触发事件
                        if (newKey is UnkownKey)
                        {
                            // Todo :触发事件
                            if (newKey.BaseFile != null && newKey.BaseFile.OnUnkownKey != null)
                            {
                                newKey.BaseFile.OnUnkownKey(newKey.BaseFile, newKey);
                            }
                        }


                        // Todo :开始读取新关键字
                        newKey.ReadKeyLine(reader);

                        #endregion
                    }
                    else
                    {
                        #region - 记录数据 -

                        if (tempStr.IsNotExcepLine())
                        {
                            if (this.ReadNewLineHandler == null)
                            {
                                // Todo :当前关键字没有实时读取方法
                                this.Lines.Add(tempStr);
                            }
                            else
                            {
                                // Todo :当前关键字实现实时读取方法
                                this.ReadNewLineHandler(tempStr);
                            }
                        }

                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    LogProviderHandler.Instance.OnErrLog("读取关键字" + this.GetType().Name + "错误!", ex);
                }
                finally
                {
                }
            }

            #endregion

            return(this);
        }
Ejemplo n.º 6
0
        /// <summary> 利用数模文件异步创建指定大小栈的内存模型 </summary>
        public INCLUDE ThreadLoadFromFile(string pfilePath, SimKeyType keyType = SimKeyType.Eclipse, int stactSize = 4194304)
        {
            INCLUDE include = new INCLUDE("INCLUDE");

            return(ThreadLoadFromFile(include, pfilePath, keyType, stactSize));
        }