Esempio n. 1
0
        /// <summary>
        /// 配置CPU模块
        /// </summary>
        public void ConfigCPUUnits(YZXCPUProject Project)
        {
            int statusL = YZXUDT.GetUDTLength(YZXUDTTypes.UnitStatus);

            UnitStatus = new YZXCPUMemory("UnitStatus", Project.Units.Count * statusL);
            Mermories["UnitStatus"] = UnitStatus;

            Units = new Dictionary <string, YZXUnit>();

            for (int i = 0; i < Project.Units.Count; i++)
            {
                System.Tuple <YZXUnitTypes, YZXUnit> tu = Project.Units[i];

                YZXUnit unit = tu.Item2;
                if (tu.Item1 == YZXUnitTypes.Snap7ClientDB)
                {
                    Snap7ClientDBUnit u = unit as Snap7ClientDBUnit;
                    u.Client.con();
                }
                unit.Init();

                YZXUnitStatus status = (YZXUnitStatus)
                                       UnitStatus.InitUDT(YZXUDTTypes.UnitStatus, this, (i * statusL).ToString());

                status.Unit = unit;

                unit.Status = status;

                Units[unit.Name] = unit;
            }
        }
Esempio n. 2
0
 public void ConfigUnitMemoryMaps(YZXCPUProject Project)
 {
     foreach (YZXUnitMemoryMap map in Project.Maps)
     {
         YZXUnit      unit   = Units[map.Unit];
         YZXCPUMemory memory = Mermories[map.Memory];
         ushort       begin  = map.Begin;
         ushort       length = map.Length;
         MapUnit(unit, memory, begin, length);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 配置CPU内存区域
        /// </summary>
        public void ConfigCPUMermories(YZXCPUProject Project)
        {
            foreach (KeyValuePair <string, int> item in Project.Mermories)
            {
                Mermories[item.Key] = new YZXCPUMemory(item.Key, item.Value);
            }

            int statusL = YZXUDT.GetUDTLength(YZXUDTTypes.CPUStatus);

            CPUStatus = new YZXCPUMemory("CPUStatus", statusL);
            Mermories["CPUStatus"] = CPUStatus;
        }
Esempio n. 4
0
        /// <summary>
        /// 配置任务
        /// </summary>
        public void ConfigTasks(YZXCPUProject Project)
        {
            AddGCTask();

            foreach (System.Tuple <YZXTaskTypes, YZXTask> tt in Project.Tasks)
            {
                YZXTask task = tt.Item2;
                if (tt.Item1 == YZXTaskTypes.IronPython)
                {
                    IronPythonTask ipytask = task as IronPythonTask;
                    ipytask.InitR();
                    ConfigIronPythonTask(ipytask);
                }

                Tasks[task.Name] = task;
            }
        }
Esempio n. 5
0
        public void LoadProject(YZXCPUProject project)
        {
            try
            {
                //S7CPUPath = project.S7CPUPath;
                ConfigCPUMermories(project);
                ConfigCPUUnits(project);
                ConfigUnitMemoryMaps(project);
                ConfigTasks(project);
                //ServerIP = YZXCMessagingNode.ResolveServerIP();
                //ServerIP = project.CPUAddress;

                //StartCPUServer();
                //ConfigCPUServer();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }