一个C#开发的用于运动控制开发、工控逻辑的运动并发流程控制框架CsGo

大家好,我是宝弟!

今天给大家推荐一个C#开发的用于运动控制开发、工控逻辑的运动并发流程控制框架CsGo,框架基于CSP模型构建,相对于传统多线程模型、状态机模型、类PLC模型,逻辑结构紧凑清晰,开发效率极高,易于维护升级;.

1框架介绍

由于其简洁的设计,开发者可以快速地开发出高效的代码,同时,如果需要对模型进行升级或维护,也会非常方便。

框架是在golang语言的基础上开发的,可以根据需要进行功能的扩展。支持自定义的线程调度,可以根据实际情况选择主UI线程或者其他线程进行调度,以便于逻辑与UI的交互。高精度定时器、调度优先级、逻辑停止、逻辑暂停功能可以更好地控制和管理任务的执行。通过树形的任务调度方式,可以提高任务执行的可靠。即使在单线程的情况下,也能处理大量的任务和IO操作。

2使用方法

CsGo的使用方法很简单,引入类库后即可编写代码:

static async Task Worker(string name, int time = 1000){    await generator.sleep(time);    Log(name);}

A、B、C依次串行

//A->B->Cstatic async Task Worker1(){    await Worker("A");    await Worker("B");    await Worker("C");}

A、B、C全部并行,且依赖同一个strand(隐含参数,所有依赖同一个strand的任务都是线程安全的)

//A//B//Cstatic async Task Worker2(){    generator.children children = new generator.children();    children.go(() => Worker("A"));    children.go(() => Worker("B"));    children.go(() => Worker("C"));    await children.wait_all();}

A执行完后,B、C再并行

//  -->B//  |//A->//  |//  -->Cstatic async Task Worker3(){    await Worker("A");    generator.children children = new generator.children();    children.go(() => Worker("B"));    children.go(() => Worker("C"));    await children.wait_all();}

 资源获取方式 


https://gitee.com/hamasm/CsGo