GH Bladed 软件使用学习笔记(2)
来源:互联网 发布:spss信度分析 输入数据 编辑:程序博客网 时间:2024/06/14 16:00
主要介绍外部控制器的的通讯
/*外部控制器的自定义有两种实现方式:.EXE和.DLL编译成可执行文件(.EXE)的外部控制器与Bladed模拟数据之间通过共享的二进制文件来进行信息交换,二进制文件由多个4字节记录组成。文件中的4字节记录应该写入或者读取4字节(单精度)的整数,实数(浮点数)或者4个字节的字符组。这个想通过python生成exe来实现,毕竟python深度学习机器学习的开源库能够利用到风机上真是让人遐想万分,先mark,以后再做。以DLL动态链接库形式编译的,所有数组单元以实数传递,软件安装的里面有一个使用c++编写DLL完成外部控制器的demo,代码难度不大,仔细看一下,要点就是要注意指导使用手册里面的数据交换的表点存储的位置和数据格式。*/#include <string.h>#define NINT(a) ((a) >= 0.0 ? (int)((a)+0.5) : (int)((a)-0.5))float *SwapArray;float GetSwapValue(int Index) { return(SwapArray[Index-1]); }void SetSwapValue(int Index, float Val) { SwapArray[Index-1] = Val; }extern "C" void __declspec(dllexport) __cdecl DISCON (float *avrSwap, int *aviFail, char *accInfile, char *avcOutname, char *avcMsg){ int iStatus; static float rPitchDemand; SwapArray = avrSwap; //Store the pointer //Make sure there's a C string terminator accInfile[NINT(avrSwap[49])] = '\0'; avcOutname[NINT(avrSwap[50])] = '\0'; avcMsg[0] = '\0'; iStatus = NINT (avrSwap[0]); //Initialise if (iStatus == 0) { //Initialise pitch demand to current pitch angle rPitchDemand = GetSwapValue(4); //This is also where you could read in any user-defined data from accInFile } //Return demanded variables //Note: previous values can be used before they updated, to simulate a one-sample delay if (NINT(GetSwapValue(10)) == 0) { SetSwapValue(42, rPitchDemand); SetSwapValue(43, rPitchDemand); SetSwapValue(44, rPitchDemand); SetSwapValue(45, rPitchDemand); } else { strcpy(avcMsg,"This simple DLL needs pitch position actuator"); *aviFail = -1; } //Main calculation if (*aviFail >= 0) { //Just a 1-degree step change in pitch position demand at 10 seconds static int iDone; if (iStatus == 0) iDone = 0; if (GetSwapValue(2) >= 10.0 && iDone == 0) { rPitchDemand += 0.017453F; iDone = 1; } //Logging output strcpy(avcOutname,"Pitch demand:A;"); SetSwapValue(NINT(GetSwapValue(63)),rPitchDemand); SetSwapValue(65,1.0F); }}
附录:表点excel
1 0
- GH Bladed 软件使用学习笔记(2)
- GH Bladed 软件使用学习笔记(1)
- GH Bladed 软件使用学习笔记(3)
- gh-ost简单使用
- gh
- gh
- gh
- gh
- rhino软件上Grasshopper 中的快捷键(用gh的同学不妨了解一下)
- 软件测试学习笔记(2):软件测试的分类
- 【学习笔记】熟练使用R软件
- ABB机器人学习笔记1-软件使用
- R软件学习笔记-2
- EDA软件_Cadence软件使用教程视频学习笔记
- 《软件调试的艺术》学习笔记——GDB使用技巧摘要(2)
- 软件测试实验学习笔记系列2 -- lint,splint的使用
- 软件架构学习笔记(一)
- 软件测试学习笔记(1)
- Esper系列(九)NamedWindow语法create、Insert、select
- 第8章:TTCN-3数据类型
- Esper系列(十)NamedWindow语法delete、Select+Delete、Update
- Esper系列(十一)NamedWindow语法Merge、Queries、Indexing、Dropping
- Esper系列(十二)Variables and Constants
- GH Bladed 软件使用学习笔记(2)
- Esper系列(十三)Splitting and Duplicating Streams
- Esper系列(十四)Contained-Event Selection
- Android源码解析Handler系列第(一)篇 --- Message全局池
- Docker系列(六)路由打通网络示例
- 【Java】interrupt、interrupted和isInterrupted的区别
- Docker系列(七)Shipyard安装及介绍
- KNN算法R实现
- 如何修改tomcat项目的图标