Exemple #1
0
        public void AddGCTask()
        {
            CSharpTask gctask = new CSharpTask();

            gctask.Name             = "GC";
            gctask.RunOneTimeAction = GCRun;

            gctask.RunType = YZXTaskRunType.TIMER;
            gctask.Tick    = 105;

            Tasks["GC"] = gctask;
        }
Exemple #2
0
        /// <summary>
        /// 映射模块到内存区域
        /// 同时添加读任务
        /// </summary>
        /// <param name="unit">模块</param>
        /// <param name="mermory">内存区域</param>
        /// <param name="begin">起始位置</param>
        /// <param name="end">结束位置</param>
        public void MapReadUnit(
            YZXUnit unit,
            YZXCPUMemory mermory,
            ushort begin,
            ushort length)
        {
            int end = begin + length - 1;

            mermory.Map(begin, length, unit);

            Action      init = (() => { });
            Func <bool> run  = (() =>
            {
                try
                {
                    //从模块内读取所有数据
                    List <bool> bits = unit.UpdateBits();

                    //将读取到的数据更新到内存区域
                    mermory.UpdateBits(begin, end, bits);

                    return(true);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return(false);
                }
            });

            Action reset = (() => { });

            CSharpTask task = new CSharpTask(init, run, reset);

            task.Name = string.Format("{0}-[{1},{2}]-{3}",
                                      mermory.Name, begin, end, unit.Name);

            Tasks[task.Name] = task;
        }