question

Frenk Gao avatar image
0 Likes"
Frenk Gao asked Frenk Gao commented

SnowProcessor not work and update of SDK Documentation

I am trying to finish Example Module Class- The Snow Processor (SDK-Documentation).

I create a new module named " TheSnowProcessor" and follow the Documentation steps.

But the steps in Documentation is still use the "Adding FlexSim Object Variables Wizards" which has been removed. I must add bound members to a ObjectDataType sub-class manually. I am not sure it is correct.

When I drag a SnowProcessor into model, it seems not work.The value in " flakes" goes correct while the model view with a big black triangle:

Snowflake.h/Snowflake.cpp/ SnowProcessor.h/SnowProcessor.cpp is copyed from the Examples folder.

In Snowflake.cpp, YourModuleNameGoesHere (about line 41) has been replaced with my module name (TheSnowProcessor).

TheSnowProcessor.cpp (module cpp):

#include "TheSnowProcessor.h"
#include "SnowProcessor.h"
#include "Snowflake.h"
visible ObjectDataType* createodtderivative(char* classname)
{
	if (strcmp(classname, "SnowProcessor") == 0) return new SnowProcessor;
	return NULL;
}


visible SimpleDataType* createsdtderivative(char* classname)
{
	if (strcmp(classname, "Snowflake") == 0) return new Snowflake;
	return NULL;
}


visible void dllinitialize()
{


}


visible void dllcleanup()
{


}



What's wrong?

__________________________________________________________________________

I have asking two questions before:

https://answers.flexsim.com/questions/37302/beginoffset-member-function-not-declared-in-mytask.html

https://answers.flexsim.com/questions/37364/how-to-add-bound-members-to-a-objectdatatype-sub-c.html

Would you mind updating the SDK Documentation?

FlexSim 16.0.9
module sdk
snow.png (40.8 KiB)
flakes.png (8.7 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Frenk Gao avatar image Frenk Gao commented ·
0 Likes 0 ·
Frenk Gao avatar image Frenk Gao Frenk Gao commented ·

Update to timeline!

0 Likes 0 ·

1 Answer

·
alan.zhang avatar image
2 Likes"
alan.zhang answered alan.zhang commented

Hi Frenk,

I am not sure what is wrong with your module cpp. It looks fine to me. The black triangle might be due to some issue in the SnowProcessor's OnDraw code.

Attached zip file is the module I made following the example in FlexSim Module SDK (https://bitbucket.org/flexsim/flexsim-module-sdk/downloads/). The example is to make a SnowProcessor that has snow flake flying. I made some changes such that to have random color snow flakes instead of white ones.

Files in the zip include:

  • testmodule: This is the module to be put into FlexSim's Module directory. Once it is loaded, you will see the SnowProcessor under Fixed Resources library. It has the VS2015 Solution which includes all Snow Processor module files.
  • snowflake_testmodule.fsm: a test model for the module.
  • snowprocessor.png: a screen capture of the running test model.
  • snowflake.xlsx: I am curious how each invidual flake is drawn. This Excel file shows how the points in SnowProcessor::buildMesh() used to draw a single flake.

The module is tested working in FlexSim 2016 Update 2.

Below is a screenshot of the module.

You may use my module as a reference to figure out what may be the issue. Hope this is helpful.


· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Frenk Gao avatar image Frenk Gao commented ·

I Copyed your code to my module, it is works well.

So, i think the document example source code has some issue, beacuse of update of FlexSim.

The document may be created in FlexSim 6 or previous.

Thank you for your help! It is helps a lot!

I think you are solve my question, but I want to inform FlexSim developer that the document has some issue.

@anthony.johnson

@Jeff Nordgren

@Ben Wilson

0 Likes 0 ·
alan.zhang avatar image alan.zhang Frenk Gao commented ·

@Frenk Gao, Glad it worked!

I did notice an error in the example document.

In the following part of the document:

Register the SnowProcessor class:

  1. Open your module's main cpp file (called [ModuleName].cpp)
  2. Be sure to#include "SnowProcessor.h"
  3. Insert this code into thecreateodtderivative(notcreatesdtderivative) function (before thereturnstatement):
    if (strcmp(classname, "Snowflake") == 0)
    	return new Snowflake();

The code should be:

if (strcmp(classname, "SnowProcessor") == 0)
	return new SnowProcessor();

But when I looked at your code, you made the change already.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.