MainToolbar View

Button Click Event handle àMainToolbar.xaml.cs OnConnect() functionàService.Messenger.Send(new NewConnectionEventArgs())

MainToolbar Viewmodel

_messenger.Register<NewConnectionEventArgs>(this, OnOpenNewConnetionWindow)à OnOpenNewConnetionWindow àPopupWindowShowupàNewConnectControlàbtnConnect_Clickà

……

主要写四个部分如何实现(流程等)

1. 程序启动

Shell (GetView top,main status, LoadWindowIcon etc.)à

MCLSPlugin(Constructor, Register IoC objects new ViewModels; new UI components

MainViewModel(Constructor, new MainToolBarViewModel; ControlPanelViewModel(including ChannelViewModel); )à

MCLSUI(Constructor, new MainToolbar; MainUI(including FrontPanel); StatusBar)

2. 链接硬件,显示状态

MainToolbar(Click Connect Button)à

MainToolbarVM(OnOpenNewConnectionWindow, Refresh available COM ports, new an instance of NewConnectControl, wait for user input)à

NewConnectControl(Click Connect Button, Get user input port number then Send Message Call MainToolBar.xaml.cs OnConnect function )à

MainToolBar OnConnect(DeviceConnectingEventArgs e) (open device and start monitoring port, update data to ControlPanelViewModel, trigger Controlpanel set default value)

3. 通过软件更改设备的运行状态

Click on one channel (FrontPanel Binding ChannelClickCommand)à

ControlPanelViewModel(OnClickChannel, set property SelectChannelViewModel)à

ChannelViewModel(set IsSelected property, Binding with FrontPanel get/or set other properties,and update UI)

4. 多语言支持

------------------------------MCLS-----------------------------------------

Maintoolbar (Click Options Button)à

Maintoolbar VM (New Option Window, set some properties, Open)à

-----------------------------Share library---------------------------------

OptionWindow (Binding OptionModel View element, Create instance by ViewType[LocalizationOption, ManufacturerDefaultView])à

LocalizationOption(via LocalizationService to Query status or do some operation, SupportLanguages,CurrentLanguage Add handler to SelectionChanged event)à

LocalizationService(main class of process multi-language support, maintain a group of SupportLanguage Class, notify binding target current language has changed.)à

SupportLanguage(Control load/unload XML file, lookup keys in built-in dictionary feedback actual value)

====================================================================================

IMessenger 用于在程序的各个模块中发送命令进行通信。

ILocalizationService 用于Support多语言环境

Unity

控制反转(Inverse of control): 某一接口具体实现类的选择控制权(控制)从调用类中移除,转交给第三方决定(反转)。依赖对象的获取被反转了。目的是削减计算机程序的耦合问题。解除合作对象之间引用的耦合。

依赖注入(Dependency Injection):由容器来帮忙创建及注入依赖对象,对象只是被动的接受依赖对象。

由IoC容器帮对象找相应的依赖对象并注入,而不是由对象主动去找。

MVVM Light

Register<TMessage>(Object, Action<TMessage>)

Registers a recipient for a type of message TMessage. The action parameter will be executed when a corresponding message is sent.

Registering a recipient does not create a hard reference to it, so if this recipient is deleted, no memory leak is caused.

Shared Library

PoolingService 用于向设备轮询当前值或者Monitor其他对象等。

DataService 用于控制硬件开启、关闭,以及获取数据。

LocalizationService 用于多种语言的Support

WPF引入的一个新的概念,嵌套消息泵,就是在一个While(GetMessage(...))内部又启动了一个While(GetMessage(...))。

Dispacher

每调用一次Invoke和BeginInvoke,即向Dispatcher中加入了一个任务,并且发送消息通知Render(呈现)线程更新界面显示。

AR:

1. 研究PoolingService的作用?什么时候用?

2. Unity的ServiceLocator究竟起什么作用,如何使用?

3. MCLS在轮询data(轮询线程)如何避免与 SetValue(主线程)冲突?

4. XAML DataTemplate,relative binding代表什么含义,学习。

5. 使用串口通讯工具向MCLS发送、接收命令。

【DataService】

Initial:

生成SerialQueue存放task的集合 。

启动另一个线程按顺序执行SerialQueue中的每个Task,确保一次只有一个task被执行。

SetValue所起到的作用只是向SerialQueue中添加任务,交由其他线程执行后获取返回值。因此不会与其他的task产生冲突。

参考TryGetDeviceValue之流程:

1. New a delegate to call get device value API

2. Add new job into task queue.

3. Let queue process thread execute.

4. Wait and get result from last job.

【PoolingService】

1. 向宿主程序集当中不断发送GetDeviceValueArgs类型的消息(通过MVVM的Messenger传递)

2. 驱动ControlPanelViewModel的OnPooling,将当前的设备状态(选中那个channel、系统是否被enable、channel的实际value)同步到前台界面显示。

【ServiceLocator】

Service Locator模式想要解决的问题是解耦合服务提供者和用户,用户无需直接访问具体的服务提供者类。

服务定位器模式的优缺点

服务定位器模式在带来解耦和、可维护性、动态升级服务等好处的同时,也带来一些不好的方面,比如

1、由于用户无法确切知道服务提供者的真实情况,那么如果出现错误,难以定位

2、集中式、单例的注册机是并行计算、系统扩展的瓶颈

3、由于需要集成全局的服务注册代码,执行单元测试也会麻烦些

4、注册机隐藏了类的依赖关系,使得本来在编译期可以暴露的问题,在运行时才发生

MCLS程序中不需要给每个ViewModel传入container,然后再调用container的Resolve方法。例如:

_localService = container.Resolve<ILocalizationService>();

等价于

ServiceLocator.Current.GetInstance<ILocalizationService>();

【XAML Data Template】

MCLS Notes的更多相关文章

  1. ASP.NET Core 1.1.0 Release Notes

    ASP.NET Core 1.1.0 Release Notes We are pleased to announce the release of ASP.NET Core 1.1.0! Antif ...

  2. Android Weekly Notes Issue #237

    Android Weekly Issue #237 December 25th, 2016 Android Weekly Issue #237 这是本年的最后一篇issue, 感谢大家. 本期内容包括 ...

  3. Android Weekly Notes Issue #230

    Android Weekly Notes Issue #230 November 6th, 2016 Android Weekly Issue #230. Android Weekly笔记, 本期内容 ...

  4. Android Weekly Notes Issue #229

    Android Weekly Issue #229 October 30th, 2016 Android Weekly Issue #229 Android Weekly笔记, 本期内容包括: 性能库 ...

  5. Android Weekly Notes Issue #227

    Android Weekly Issue #227 October 16th, 2016 Android Weekly Issue #227. 本期内容包括: Google的Mobile Vision ...

  6. Android Weekly Notes Issue #221

    Android Weekly Issue #221 September 4th, 2016 Android Weekly Issue #221 ARTICLES & TUTORIALS And ...

  7. Android Weekly Notes Issue #219

    Android Weekly Issue #219 August 21st, 2016 Android Weekly Issue #219 ARTICLES & TUTORIALS Andro ...

  8. MAGIC XPA最新版本Magic xpa 2.4c Release Notes

    New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Ta ...

  9. Magic xpa 2.5发布 Magic xpa 2.5 Release Notes

    Magic xpa 2.5發佈 Magic xpa 2.5 Release Notes Magic xpa 2.5 Release NotesNew Features, Feature Enhance ...

随机推荐

  1. Linux 内核class_simple 接口

    class_simple 接口意图是易于使用, 以至于没人会抱怨没有暴露至少一个包含设备的被 分配的号的属性. 使用这个接口只不过是一对函数调用, 没有通常的和 Linux 设备模型 关联的样板. 第 ...

  2. lnmp一键安装,安装php时失败

    查看安装日志 直接cd进入根目录报错内容:configure: error: mcrypt.h not found. Please reinstall libmcrypt 解决办法如下#使用wget可 ...

  3. 0015 行高那些事:line-height

    目标 理解 能说出 行高 和 高度 三种关系 能简单理解为什么行高等于高度单行文字会垂直居中 应用 使用行高实现单行文字垂直居中 能会测量行高 3.1 行高测量 行高的测量方法: 3.2 单行文本垂直 ...

  4. 通过9个Linux-0.11实验学习操作系统

    简介 2019年秋,我自学了一下哈工大的操作系统课程,感觉其设计的教程和实验作为操作系统入门是个不错的选择(虽然是基于较老的Linux-0.11写的).实验大致覆盖了操作系统中的核心概念,例如启动.中 ...

  5. RabbitMQ、Kafka、RocketMQ的优劣势

    今天我们一起来探讨: 全量的消息队列究竟有哪些? Kafka.RocketMQ.RabbitMQ的优劣势比较 以及消息队列的选型 最全MQ消息队列有哪些 那么目前在业界有哪些比较知名的消息引擎呢?如下 ...

  6. 使用app-inspector时报错connect ECONNREFUSED 127.0.0.1:8001的解决方案

    在使用 app-inspector -u udid时,报错如图所示 输入如下命令即可解决 npm config set proxy null 再次启动app-inspector即可成功

  7. 【阿里云IoT+YF3300】10.快速开发188协议设备驱动

    188协议的全称为CJ-T188-2004 <户用计量仪表数据传输技术条件>,是针对水表.燃气表.热量表和其他集中采集的一个国家行业标准协议. YFIOs就是YFSoft I/O Serv ...

  8. 20191031-6beta week 1/2 Scrum立会报告+燃尽图 04

    此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9914 git地址:https://e.coding.net/Eustia/ ...

  9. 【python小随笔】celery异步任务与调用返回值

    s1.py(配置任务文件) from celery import Celery import time my_task = Celery("tasks", broker=" ...

  10. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...