你会如何设计一个应用程序来运行一台机器? [英] How would you design an application to run a machine?

查看:24
本文介绍了你会如何设计一个应用程序来运行一台机器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你问的是什么类型的机器?一种测量镜片楔形和圆度的机器.

What type of machine you ask? A machine that measures wedge and roundness of lenses.

我已经为这台机器编写了软件并且它正在生产中,但是当他们没有按照正确的顺序做事时,它很脆弱并且容易锁定.我正在努力想出最好的方法来构建它,使其稳定和可维护.

I've already written software for the machine and it is in production, but it is brittle and prone to lock ups when they dont do things in the right order. I'm trying to come up with the best way to architect it so that its stable and maintainable.

这是 20 秒的快速运行.有两种模式,设置和运行.在设置模式下,操作员可以使用控制面板上的 6 个不同的瞬时拨动开关之一手动移动 6 个不同的电机中的任何一个.他们将所有内容都归位,然后将其转到运行模式,装入镜头,然后按 go.机器会自动带入三个指标,找到镜片的边缘,然后旋转主轴,绕着楔子一路测量.

Here's the quick twenty second run down. There are two modes, setup and run. In setup mode the operator can manually move any of the 6 different motors using one of the 6 different momentary toggle switches on the control panel. They get everything homed in, then they turn it to run mode, load a lense, and press go. The machine will automatically bring in the three indicators, find the edge of the lense, and then rotate the spindle and measure all the way around the wedge.

我以一个非常糟糕的非设计结束,它有一个类会引发一个事件,说明开关何时改变了状态,它是哪个开关,以及它的新状态是什么.然后我做了很多 ifs 和东西来确定机器可以做什么.可以想象,这非常非常糟糕.

I ended with a very poor non-design of having a class that raised an event that says when a switch has changed state, which switch it was, and what its new state is. Then I do a lot of ifs and stuff to determine what the machine can do. As you can imagine, this is very very bad.

有没有人有关于如何构建这个的好主意?我有一些我自己的,但我想听听那些可能对此类应用程序开发有更多经验的人.

Does anyone have any good ideas on how to structure this? I have some of my own, but I want to hear some from those that may be a little more experienced with this type of application development.

推荐答案

您需要的是构建一个有限状态机,这是对您遇到的问题进行建模的最佳方式:

What you need is build a finite-state machine, that's the best way to model a problem like the one you have:

http://en.wikipedia.org/wiki/Finite_state_machine

这篇关于你会如何设计一个应用程序来运行一台机器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆