I added a custom event to the SnowProcessor. You can now listen to the OnItemDusted event, which fires just after the item is received. Here are the steps to do this:
First, I added a node called onItemDusted to the SnowProcessor class. Adding events is easiest if you name the event onMyEvent, lower case "on", and CamelCase after that. I also added overrides for bindEvents() and getEventInfoObject():
class SnowProcessor : public Processor
{
protected:
//...
// events
TreeNode* onItemDusted = nullptr;
void bindEvents() override;
TreeNode* getEventInfoObject(const char* eventName) override;
public:
// ...
};
Next, I implemented bindEvents and getEventInfoObject():
void SnowProcessor::bindEvents()
{
__super::bindEvents();
bindEvent(ItemDusted);
}
TreeNode* SnowProcessor::getEventInfoObject(const char* eventName)
{
auto eventFolder = eventfunctions(classobject(holder))->find("eventInfo");
if (eventFolder) {
auto info = eventFolder->find(eventName);
if (info) {
return info;
}
}
return __super::getEventInfoObject(eventName);
}
The bindEvents() function is fairly straightforward. You just need to call the bindEvent() macro, passing in the name of your node, but without the "on" at the beginning. You probably want to bind all the parent's events as well.
The getEventInfoObject() function is a little more interesting, but not much. The basic idea is that you want to tell FlexSim where it can find the EventInfo object for the event name. We'll assume that there's a node called eventInfo in the eventfunctions of the SnowProcessor class. We usually put EventInfo objects inside eventfunctions, because the eventfunctions node is not copied when you create an instance of your class. If you don't find the event in this object's folder, be sure to pass this call up to the parent. I'll cover making the Event Info object later.
As a last step in the dll, you probably want to fire your event. Things that listen to your event respond when the event is fired. To do that, I overrode the onItemReceived() method:
double SnowProcessor::onReceive(treenode item, int port)
{
double result = __super::onReceive(item, port);
FIRE_SDT_EVENT(onItemDusted, item);
return result;
}
The important part is using the FIRE_SDT_EVENT() macro. You pass in the node for the event you want to fire, and any important parameters you want.
Once that's done, all you need to do is add the Event Info object in the tree. Here's how I did it:

I added an eventfunctions node inside the behaviour node. I added the eventInfo folder inside that, and added the OnItemDusted event info object inside that node. Note that the name should match the name of your node, but begin with "On" instead of "on".
Once I had done all of that, I could listen to the event.
I also saw that you had questions about inheriting from FlexSimEvent. That class can be used to create a scheduled event (something you could see in the event list) or for listening to an existing event. The second case is something you'd only do if you are making an object that can listen to other objects. If you need coaching on that topic, I can help you out there as well.
SnowProcessor.h.txtSnowProcessor.cpp.txtSnow.t.txt