MES系统概述

MES系统是一套面向制造企业车间执行层的生产信息化管理系统。为企业提供包括制造数据管理、计划排成管理、生产调度管理、库存管理、质量管理、人力资源管理、工作中心/设备管理、工具工装管理、采购管理、成本管理、项目看板管理、生产过程控制、底层数据集成分析、上层数据集成分解等管理模块,为企业打造一个扎实、可靠、全面、可行的制造协同管理平台

系统架构

c  mes 系统架构 mes模块架构图_Image

c  mes 系统架构 mes模块架构图_c  mes 系统架构_02

 项目代码

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zhaoxi.MES.Frame.Models;

namespace Zhaoxi.MES.Frame.ViewModels
{
    public class DeviceViewModel
    {
        public bool MonitorState { get; set; }

        public List<DeviceItemModel> DeviceList { get; set; }

        public DeviceViewModel()
        {
            DeviceList = new List<DeviceItemModel>();

            App.MqttMessageReceived += App_MqttMessageReceived;

            DeviceItemModel dim = new DeviceItemModel();
            // 网络图片
            dim.Image = "pack://application:,,,/Zhaoxi.MES.Frame;component/Assets/Images/Device/d_1.png";
            dim.LightType = Controls.LightState.Fault;
            dim.Title = "加工中心";
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "运行状态", PropValue = "故障" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "工作模式", PropValue = "AUTO" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "进给倍率", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "主轴转速", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "主轴负载", PropValue = "0 r/min" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "程序编号", PropValue = "7014" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "机床坐标-X", PropValue = "-500 mm" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "机床坐标-Y", PropValue = "-120.002 mm" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "机床坐标-Z", PropValue = "-1.525 mm" });
            DeviceList.Add(dim);

            dim = new DeviceItemModel();
            dim.Image = "pack://application:,,,/Zhaoxi.MES.Frame;component/Assets/Images/Device/d_2.png";
            dim.LightType = Controls.LightState.Warning;
            dim.Title = "电火花";
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "L编号", PropValue = "31" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "N编号", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "B编号", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "停止编号", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "程序错误", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "运行错误", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "顺序错误", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "启动ON时间", PropValue = "0时:0分:0秒" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "加工ON时间", PropValue = "0时:0分:0秒" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "E条件编号", PropValue = "909002" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "设备机械坐标", PropValue = "暂无" });
            DeviceList.Add(dim);

            dim = new DeviceItemModel();
            dim.Image = "pack://application:,,,/Zhaoxi.MES.Frame;component/Assets/Images/Device/d_3.png";
            dim.LightType = Controls.LightState.Run;
            dim.Title = "机器臂";
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "运行状态", PropValue = "运行" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "工作模式", PropValue = "手动" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J1", PropValue = "-97.979°" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J2", PropValue = "-31.493°" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J3", PropValue = "-24.517°" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J4", PropValue = "-0.032°" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J5", PropValue = "-34.038°" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J6", PropValue = "-8.532°" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "关节轴J7", PropValue = "3182.790°" });
            DeviceList.Add(dim);

            dim = new DeviceItemModel();
            dim.Image = "pack://application:,,,/Zhaoxi.MES.Frame;component/Assets/Images/Device/d_4.png";
            dim.LightType = Controls.LightState.None;
            dim.Title = "三坐标";
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "运行状态", PropValue = "运行" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "工作模式", PropValue = "手动" });
            DeviceList.Add(dim);


            dim = new DeviceItemModel();
            dim.Image = "pack://application:,,,/Zhaoxi.MES.Frame;component/Assets/Images/Device/d_5.png";
            dim.LightType = Controls.LightState.Run;
            dim.Title = "线切割";
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "运行状态", PropValue = "运行" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "工作模式", PropValue = "自动" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "停止编号", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "程序错误", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "运行错误", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "顺序错误", PropValue = "0" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "启动设定为ON的时间", PropValue = "0时:0分:0秒" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "加工设定为ON的时间", PropValue = "0时:0分:0秒" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "加工条件(E条件)编号", PropValue = "909002" });
            dim.Properties.Add(new DevicePropertyItemModel { PropName = "设备机械坐标", PropValue = "暂无" });
            DeviceList.Add(dim);
        }

        // 如果小伙伴对事件委托不理解    加强 一下C#基础
        private void App_MqttMessageReceived(object? sender, string e)
        {
            // 演示
            DeviceList[0].Properties[3].PropValue = e;
            //Debug.WriteLine(e);

            // 真实对接    作业 
            //e  就是一个Json字符串  反序列化 -》 对象 

        }
    }
}

 

 

using System;
using System.Collections.Generic;
using System.DirectoryServices.ActiveDirectory;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zhaoxi.MES.Frame.Models;
using Zhaoxi.MES.Frame.Base;
using System.Collections.ObjectModel;
using System.Reflection;

namespace Zhaoxi.MES.Frame.ViewModels
{
    public class MainViewModel:NotifyBase
    {
        // 菜单 集合
        public List<MenuItemModel> TreeList { get; set; }
        // 页面 集合
        public ObservableCollection<PageItemModel> Pages { get; set; }
            = new ObservableCollection<PageItemModel>();

        public MainViewModel()
        {
            #region 菜单初始化
            TreeList = new List<MenuItemModel>();
            {
                MenuItemModel tim = new MenuItemModel();
                tim.Header = "工艺设计";
                //  XAML里使用
                tim.IconCode = "\ue610"; // 字体图标编码,阿里的Iconfont平台打包的图标库
                TreeList.Add(tim);
                tim.Children.Add(new MenuItemModel
                {
                    Header = "加工工艺",
                    TargetView = "BlankPage",
                    OpenViewCommand = new Command<MenuItemModel>(OpenView)
                });
                tim.Children.Add(new MenuItemModel
                {
                    Header = "EBOM",
                    TargetView = "BlankPage",
                    OpenViewCommand = new Command<MenuItemModel>(OpenView)
                });
                tim.Children.Add(new MenuItemModel
                {
                    Header = "设备看板",
                    TargetView = "DevicePage",
                    OpenViewCommand = new Command<MenuItemModel>(OpenView)
                });

                tim.Children.Add(new MenuItemModel
                {
                    Header = "PBOM",
                    TargetView = "PBomPage",
                    OpenViewCommand = new Command<MenuItemModel>(OpenView)
                });
                MenuItemModel subMenu = new MenuItemModel();
                subMenu.Header = "二级菜单";
                subMenu.Children.Add(
                    new MenuItemModel
                    {
                        Header = "三级菜单"
                    }
                   );
                tim.Children.Add(subMenu);
            }
            #endregion

            #region 测试  页面初始
            // 所有数据集合都可以 VM中进行控件 (增加和删除)
            //Pages = new ObservableCollection<PageItemModel>();
            //Pages.Add("AAAA");
            //Pages.Add("BBBB");
            //Pages.Add("CCCC");
            //Pages.Add("DDDD");
            #endregion
        }

        private void OpenView(MenuItemModel menu)
        {
            // 两个问题:
            // 1、每点击一次都会有一个新的页面!  解决方案:从集合中判断是否存在
            // 2、新打开一个页面后,不能马上显示 

            //MenuItemModel mim = menu as MenuItemModel;
            // 需要进行页面的打开 
            //Pages.Add("EEEE");

            var page = Pages.ToList().FirstOrDefault(p => p.Header == menu.Header);

            if (page == null)
            {
                Type type = Assembly.GetExecutingAssembly().
                    GetType("Zhaoxi.MES.Frame.Views.Pages." + menu.TargetView);
                object p = Activator.CreateInstance(type);

                Pages.Add(new PageItemModel
                {
                    Header = menu.Header,
                    PageView = p,
                    IsSelected = true,
                    CloseTabCommand = new Command<PageItemModel>(ClosePage)
                });
            }
            else
                page.IsSelected = true;
        }

        private void ClosePage(PageItemModel menu)
        {
            Pages.Remove(menu);
        }
    }
}