ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
HELP ME TO CONTROL FLEXSIM REMOTELY
hi, everybody
if i wanna make a mini-software to control flexsim remotely, what kind of suggestion all of you can give me? this software should have these functions such as new model, adding rack, and so on. acturally, i'd like to know whether VB can do this? All of the commands and functions in flexsim are written in c++. if vb can't do that.how about MFC in c++? i have seen Anthony Johnson's post:http://www.flexsim.com/community/for...read.php?t=382 ,it did help me a lot.But when i try to add those .h and .cpp files in my MFC project, it doesn't work.what can i do? And my flexsim version is 3.0.i know it's very old, but my boss will not update it unless i can do thing well,so the dll maker does not fit me very well. maybe my question has a little silly, please help me.thanks in advance!
__________________
Harry Qin |
#2
|
|||
|
|||
Hi,
The .cpp and .h files you are referring to are used to develop your own DLL files that can be used in Flexsim and not for controlled Flexsim from your own application. To be able to control Flexsim remotely you may want to check this topic http://www.flexsim.com/community/for...read.php?t=386. I think it will not work in version 3, you need to upgrade your license. Lars-Olof |
#3
|
|||
|
|||
hi Lars-Olof,
thanks for your reply.I have also seen the topic which you remention. But it looks like that the VBS can only do a few commands to control the flexsim in its application, such as open model,compile,getnodenum,ect.about 21 commands.i didn't see the createinstance, createcopy and others commands. As the dll maker,how about making a MFC application in VS to get .exe file.And i think it can also work in MFC if i add the .h and .cpp file in. (Obviously i have to reedit some code, i just change the fomart from MFC DLL to FMC APPLICATION). I mean how can make a connection successfully between my own application and flexsim?How can i use the commands and functions in my own application which belong to flexsim and have been defined and declared in dll maker. I know the 3.0 is so obsolete,but we cann't update it in few days.a couple of months will be fine.But i have to get a mothed about connecting the flexsim, even not finishing the application now.So, can you or anybody give me a useful mothed about what i mentioned? honestly,thanks a lot.
__________________
Harry Qin |
#4
|
|||
|
|||
Hi,
Again the .cpp and .h you are referring to is only for creating your own DLL in version 4 or later of Flexsim. The DLL you have created must be called from Flexsim to work. The only way to remotely controlling Flexsim is by the link in my last post or through the COM Object. As you already know the COM object does not work for version 3. You must upgrade Flexsim first. If I have missed something I hope Flexsim or someone else can put you in the right direction. Lars-Olof |
The Following 2 Users Say Thank You to Lars-Olof Leven For This Useful Post: | ||
harry qin (04-21-2010) |
#5
|
||||
|
||||
The COM object's 21 methods should be enough for anything you need to do. You can use the ExecuteString() or the NodeFunction() methods to call custom flexscript code, which allows you access to essentially any flexscript command you need.
As Lars Olof mentioned, I believe this is only accessible to v4 and later. You can try it on v3, but there's no guarantee. Version 3 unfortunately had very few options for controlling Flexsim remotely. These have been improved significantly over the past two versions. I don't think the commandlineparam() function was available in v3 (although try it), but it is in v4 and v5, which allows you to call Flexsim from the command line, passing parameters, and then getting those parameters in the model. |
The Following 2 Users Say Thank You to Anthony Johnson For This Useful Post: | ||
Lars-Olof Leven (04-21-2010) |
#6
|
|||
|
|||
Hi Lars-Olof,
Thanks for your atention again.I totally understand what you mean and know the dll are used in the flexsim model only.Maybe I am not english natural speaker, I don't think I state my idea clearly. And to Anthony, thanks for you answer,that's definitely what i want.I have tried the method on 3.0.It does not work indeed.So I think maybe i have to do this job on flexsim 4.52.OK, I will check whether it can createinstance(add rack, conveyor.ect) or not before i raise new question. Thanks all you guys helping a green hand.^_^
__________________
Harry Qin |
#7
|
|||
|
|||
hi everyone,
it's me again.i have updated my version to v4.5.now i can use the COM mothod.however, after several days' struggle, i totally have no idea what to do.How to call custom flexscript code using ExecuteString() or the NodeFunction()? Yeah,I am a little good at VB code instead of C++.So if i wanna do the application in VB,before using the FlexsimAXApp,should i define(or dim) the command in VB. i mean.I don't think the computer understand the command before definition.Then how to define it? for example,i wanna the executestring() calling the createinstance command, what can i do? If VB doesn't work,i will use C++ doing it.the same thing is how to define the command in it."#prgram comment(lib,”FlexsimAXDLL.lib”)" isn't enough. Or anybody can give me an example about creating an object in one of two methods hat i mentioned.Or should i have the headfile(FlexsimAXDLL.h) when i call the class in dll? Reply my thread in any comment on it.thanks very much.Just as Lars Olof said , i need someone puting me on the right direction. Thanks very much. P.S. I mean, it's easy to call class flexsimaxapp in VB,but i can't define the commands(functions) in VB such as createcopy, createinstance and so on.On the contrary, i can define the functions in c++,but all the sub(compile,go,reset...) and event(OnExperimentEnd, OnUserNotify,...) are covered in the class flexsimaxapp.I don't know how to call them.how to call a class's sub in the dll FlexsimAXDLL.dll. Or should i have the headfile flexsimaxapp.h when i call the class in dll?
__________________
Harry Qin Last edited by harry qin; 04-25-2010 at 11:41 AM. |
#8
|
|||
|
|||
Can anybody give me a tip? I am a little anxious.How can I call custom flexsript code in VB?For example, how can I create a rack using FlexsimAXApp?
THANK YOU! THANK YO THANK YOU THANK YOU! VB code: Private WithEvents FlexsimApp As FlexsimAXApp Private Sub Command1_Click() Set FlexsimApp = New FlexsimAXApp Call FlexsimApp.StartApplication(True) Call FlexsimApp.OpenModel("\development.fsm") Call FlexsimApp.ExecuteString(createinstance(Node("/Source"), model())) End Sub Obviously the command createinstance doesn't work.And was given a error which says the "node" isn't defined yet!
__________________
Harry Qin |
#9
|
||||
|
||||
Quote:
Call FlexsimApp.ExecuteString(createinstance(node("/Source", library()), model())) -> node("/Source", library()) -> createinstance(node(..), model()) Last edited by Carsten Seehafer; 04-26-2010 at 07:48 AM. Reason: syntax of createinstance :) |
#10
|
|||
|
|||
thanks Carsten,but I don't think it's the error's reason.There is no difference with "N" and "n" in VB code.It will change from n to N automatically
__________________
Harry Qin |
#11
|
|||
|
|||
Hi,
I think the problem is that you are not passing a string to ExecuteString. You are passing createinstance(node("/Source"), model()) you should pass something like this "createinstance(node("/Source"), model())". What I would do is to create a variable called like flexsimStr and assign createinstance(node("/Source"), model()) to flexsimStr, then I would use flexsimStr in the ExecuteString. I have not tested this, but something like this I have in mind. Code:
Dim flexsimStr as String flexsimStr="createinstance(node( ""/Source"" ),model))" Call FlexsimApp.ExecuteString(flexsimStr) Last edited by Lars-Olof Leven; 04-26-2010 at 09:21 AM. Reason: Added code example |
The Following User Says Thank You to Lars-Olof Leven For This Useful Post: | ||
harry qin (04-26-2010) |
#12
|
|||
|
|||
hi,Lars-Olof ,thanks.But it doesn't also work.I don't know why.I just thought whether should i define the commands such as node(),model() and library() in advance.Do you have any other suggestion?
__________________
Harry Qin |
#13
|
|||
|
|||
I helped Harry to solve his issue, now he has something that he can work with.
Lars-Olof |
The Following 4 Users Say Thank You to Lars-Olof Leven For This Useful Post: | ||
Tom David (04-26-2010) |
#14
|
|||
|
|||
Yeah,I can do my program because of Lars-Olof's help.Thank him again.Now I upload my project if any other person need this file.Ofcourse it's VB file.But there are some bug in my code.For example,I wanna change the rack's location and size which the data is saved in access database.But the code doesn't work.The conveyor's 3D texture cann't also changed when i use the "setnodestr" and "setnodenum" command. I don't know whether should I continue this thread or post a new one.Anyone can help me?
Thanks in advance! Or,simply,can I change the size in next code? flexsimStr3 = "node(""/project/library/Rack>behaviour/eventfunctions/BasicRefreshTable"",main)" Call FlexsimApp.NodeFunction(flexsimStr3, Current, 3,4, 1.7, 2.5, Null, Null, Null, Null) this will get an error which said the null value is wrong. when i use these code to change the 3D texture next. flexsimStr2 = "node(""/Conveyor1/visual/imageobject"",model())" flexsimStr3 = "fs3d\chainconveyor.bmp" Call FlexsimApp.SetNodeStr(flexsimStr2, flexsimStr3) this also doesn't work.
__________________
Harry Qin |
#15
|
|||
|
|||
Hi,
I do not think VB has NULL, try to remove them or replace them with 0. Does node("/Conveyor1/visual/imageobject",model()) work in Flexsim? Try to use this: node("/Conveyor1>visual/imageobject",model()) Have the code work first in Flexsim before you add it to your VB code. Lars-Olof |
The Following 2 Users Say Thank You to Lars-Olof Leven For This Useful Post: | ||
Phil BoBo (04-29-2010) |
#16
|
|||
|
|||
Hi Harry,
What I can understand how SetNodeStr works is that you need to pass 2 strings. First string is the path to the node and the second is the string you want to write to the node. I think the code should look something like this: Code:
flexsimStr2 = "/Conveyor1>visual/imageobject" flexsimStr3 = "fs3d\chainconveyor.bmp" Call FlexsimApp.SetNodeStr(flexsimStr2, flexsimStr3) |
#17
|
|||
|
|||
it's also Lars-Olof helping me to solve the problem.Yeah,the nodefunction's first para should be string type instead of node type.The code to change 3D texture as follows:
Code:
flexsimStr2 = "/Conveyor1>visual/imageobject" flexsimStr3 = "fs3d\chainconveyor.bmp" Call FlexsimApp.SetNodeStr(flexsimStr2, flexsimStr3) Code:
rackNode = FlexsimApp.ExecuteString("last(model())") functionStr = "MAIN:/project/library/Rack>behaviour/eventfunctions/BasicRefreshTable" Call FlexsimApp.NodeFunction(functionStr, rackNode, 3, 3, 1, 2, 0, 0, 0, 0) finally,i find the guys in this forum are always so kind and nice,always.i think that's why the flexsim software is so successful in this competitive market.it's all because of you!
__________________
Harry Qin Last edited by harry qin; 05-04-2010 at 12:22 PM. Reason: add something |
Tags |
c++, development, dll maker, remotely |
Thread | Thread Starter | Forum | Replies | Last Post |
Version control of Flexsim model | AlanZhang | Q&A | 11 | 12-09-2014 11:12 AM |
An example of using drawsurrogate to control transparency in Flexsim 5 | Phil BoBo | Tips and Tricks | 12 | 01-24-2011 12:45 AM |
Please help to control Flexsim remotely | cedric molthoff | Q&A | 0 | 03-30-2010 02:25 AM |
Controlling Flexsim Remotely | Anthony Johnson | Wiki Articles | 2 | 01-02-2009 12:36 PM |
control Flexsim remotely | Martin Saler | Q&A | 1 | 12-14-2007 04:35 AM |