设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2574|回复: 0

flexsim的二次开发

[复制链接]
发表于 2009-12-29 10:06:30 | 显示全部楼层 |阅读模式
本人英语不是很好,有人知道下面的内容的具体意思吗?能不能给我讲讲吗?


This article explains how to implement a dll using Flexsim.

To build a Flexsim DLL, you first need to start with a Visual Studio DLL project. Attached is an example project (for Visual Studio 2008) that you can start from:

DLL Maker.zip

If you have Visual Studio 2005 Standard or Professional, a Visual Studio New Project Wizard was created by Heidi Johnson for this VS version. This wizard integrates seamlessly into Visual Studio's user interface and lets you quickly create a Flexsim DLL project:

FlexsimWizardsSetup.zip

Included with the above mentioned projects are two essential c++ header files, namely flexsimfuncs.h and flexsimdefs.h. Over time and as new versions of Flexsim are released, these files may need to be changed to access new functionality that is made available by Flexsim in newer versions (as well as to better access functionality that is already available). It has been decided among Flexsim and its advanced users that the maintenance and improvement of these files (mainly flexsimfuncs.h and flexsimdefs.h) will be done through an open source project hosted by Google Code. The project can be found at code.google.com/p/flexsim-dll-project/. Refer to this site if you would like to contribute to development. The latest version of flexsimfuncs.h is available at: flexsim-dll-project.googlecode.com/svn/trunk/DLL%20Maker/FlexsimFuncs.h. The latest version of flexsimdefs.h is available at: flexsim-dll-project.googlecode.com/svn/trunk/DLL%20Maker/FlexsimDefs.h.

Implementing the DLL to connect with Flexsim
There are multiple steps involved with implementing the DLL so that it properly connects with Flexsim. The DLL's purpose is to implement functions that will supplant functions normally called on flexscript/c++ toggled nodes in your model. The advantage of this is two-fold. First, and probably most important, it gives you the advantages of C++, including speed and ultimate flexibility, without the need for the modeler to compile every time they open the model. Second, it allows you to hide your code if you would like to protect certain intellectual property.

First, you'll want to implement the appropriate function on the dll side. An example function is provided in the DLL Maker project:

Code:
#include "FlexsimDefs.h" visible double mydllfunction1(FLEXSIMINTERFACE){    pt("This will print to the Output Console");pr();    return 0;}
In order to connect a Flexsim node's execution to this function, the function must have the appropriate declaration. First you should include flexsimdefs.h. This defines certain macros as well as declares the Flexsim commands, so you can have access to those commands. Then the declaration should be as follows:
visible double the_function_name(FLEXSIMINTERFACE)

Once you've declared the function appropriately, you can access parameters and write code just like you would write code in a trigger or other code piece in Flexsim. For example, you can use parnode, parval, msgsendingobject and msgparam for message triggers, etc. For the most part you can just copy the code straight from a c++/flexscript code field into the function (although there are a few caveats that are explained later).

Once you've defined the function on the dll side, you need to go into Flexsim and define how the node connects to the dll. If you, for example, want to have a message trigger call a dll function, go to the code field of that trigger and press the "DLL" radio button at the bottom of the code field. You should get a message saying something like "Would you like to format the code for dll linking." Click OK. This will toggle the trigger for dll connection and change the code to be the a default format. When Flexsim executes a dll toggled node, it looks for two quote-enclosed texts, and ignores the rest of the field. This lets you define template code with the /** and /**/ syntax, so that the template window will give useful information, while still letting you define the dll-linking information properly.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2024-6-1 17:00 , Processed in 0.011803 second(s), 15 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表