允许用户输入用于评估遥测数据的方程
我目前已将传感器数据转储到数据库中。这是原始数据,需要对其应用方程式才能使其对最终用户有意义。我遇到的问题是,我还不知道大部分公式,并且还希望程序足够灵活,以便当将新传感器添加到系统中时,用户将能够输入校准方程能够将原始数据转换成有用的东西。
我从未尝试过让用户输入方程式来操作数据。我将不胜感激任何可能有帮助的意见。 我应该朝哪个方向看,我应该尝试 lambda 表达式树、评估方程并使用 CodeDom 编译它,还是朝另一个方向看? 我从来没有对 lambda 表达式树或 CodeDom 做过太多事情,并且像往常一样,并且日程安排相当紧张,因此学习曲线确实很重要。稍后我将有机会回去并使其变得更好,他们现在只需要它启动并运行。
感谢您的任何意见。
I currently have sensor data being dumped into a database. This is raw data, and needs an equation applied to it in order for it to make any sense to the end users. The problem I have, is that I do not know most of the formulas yet, and would also like the program to be flexible enough that when a new sensor is added to the system, the user would be able to enter in the calibration equation that would be able to convert the raw data into something useful.
I have never worked with letting a user enter in an equation to manipulate data. I would appreciate any input that might help. What direction should I be looking, should I be trying out lambda expression trees, evaluating the equation and compiling it using CodeDom, or looking in another direction? I have never done much with either lambda expression trees or CodeDom, and like always and on a fairly tight schedule, so the learning curve does count. I will have the opportunity to go back and make it better at a later date, they just need it up and running for now.
Thanks for any input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我强烈推荐 FLEE 进行表达式解析/评估。它有一个自定义的 IL 编译器,可以生成快速的 IL,并且不会出现 CodeDOM 所存在的内存问题。
它还具有易于编码和扩展的理想属性。
I highly recommend FLEE for expression parsing/evaluation. It has a custom IL compiler that emits fast IL that doesn't have the memory problems that CodeDOM has.
It also has the desirable attribute of being easy to code with and extend.
我认为你需要看看什么对你有用。我也想到了这两个,结果发现你提到了它们。我认为另一种选择是允许存储一些主要公式的参数(即三次、二次、指数、对数……)并选择一个作为要使用的公式。
我个人会使用表达树,因为它是最干净的。 CodeDom 的一个问题是编译代码导致的内存泄漏,尤其是当用户多次更改代码并构建公式时。一种解决方案是将编译后的代码加载到单独的 AppDomain 中,然后卸载整个 AppDomain。
I think you need to see what works for you. I also thought of the two only to find out you have mentioned them. I think the other alternative is to allow for parameters of a few major formulae to be stored (i.e. cubic, quadratic, exponential, log, ...) and one selected as the one to be used.
I would personally use the expression trees because it is the cleanest. One problem with CodeDom is the memory leak caused by compiling code especially if the user changes the code and builds the formula multiple times. One solution would be to load the compiled code in a separate AppDomain and then unload the whole appdomain.