|
See this[^] article.
/ravi
|
|
|
|
|
I am developing a flight simulator application that has a MDI interface to entry settings and read some status information. However, I am little lost where i should place the main state machine/loop that controls all of the motion based incoming UDP sockets messasges. Right now, I envision creating a class that starts it's own thread calling running that will recieve and process all the motions movement. Is this a good way to setup a systems. The UDP socket can recieve up to 30 motion commands per second.
//Peusodo Code
<br />
<br />
void service_motion::Runnning( void ) <br />
{<br />
UDP_Socket.GetPacket( &cmdpkt );<br />
<br />
switch( state )<br />
{<br />
<br />
case BOARDING:<br />
if( inputs == OK ) <br />
state = DOCKED_DOWN;<br />
break;<br />
<br />
case DOCKED_DOWN:<br />
if( cmdpkt.opcode == START_GAME )<br />
state = RUNNING;<br />
break;<br />
<br />
<br />
case PAUSED:<br />
break;<br />
<br />
case RUNNING:<br />
if( cmdpkt.opcode == PAUSE )<br />
state = PAUSED;<br />
<br />
if( cmdpkt.opcode == STOP)<br />
{<br />
stop_motion();<br />
state = PAUSED;<br />
}<br />
<br />
break;<br />
<br />
case EMERGENCY:<br />
<br />
break;<br />
<br />
case RECOVERY:<br />
break;<br />
<br />
<br />
<br />
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan wrote: switch( state )
That's not a state machine
led mike
|
|
|
|
|
led mike wrote: That's not a state machine
A switch statement is a perfectly fine way to implement a FSM. I'm curious why you feel otherwise?
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: A switch statement is a perfectly fine way to implement a FSM.
Whatever
led mike
|
|
|
|
|
Can this be accomplished using Events or messages? Does it make more sense to read the commands from UDP socket outside the Running Thread and send messages and/or events to FSM?
Scott Dolan
Jernie Corporation
Engineering & Manufacturing
Software, Hardware, & Enclosures
|
|
|
|
|
ScotDolan, I have no idea what your project parameters are:
A flight simulator
A UDP Socket
30 UDP commands per second
controls all the motion
EMERGENCY - Disables network commands
What commands? From what? Why a Socket? What Motion? What is "EMERGENCY"? What does "Disables network commands" mean?
What is the desired "result" of all this?
led mike
|
|
|
|
|
Dude, what are you talking about?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
|
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hi all
Could anyone please show me a good link which gives an in depth study of C++, i mean how the storage occurs, how an object is kept in memory, how all the things are done under ground.
Regards
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
|
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
Imho, you're more likely to find this kind of information in a textbook.
/ravi
|
|
|
|
|
Those were old days......felt we will find everything on the net
The Best Religion is Science.
Once you understand it, you will know God.
|
|
|
|
|
|
hi i tried to set the ip address using netsh as
UpdateData(TRUE);
CString para3 ;
para3.Format(( "Local Area Connection"));
CString ipadd;
ipadd.Format(_T("%s"),m_IpAddress);
HINSTANCE hInt;
CString command;
command.Format(("/cnetsh interface ip set address name=%s static %s %s %s 1"),para3,m_pIpadd,m_subnet,m_gateway);
system(command);
the values are from editboxes.is anything wrong with this code. this havent set the ip.
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: CString para3 ;
para3.Format(( "Local Area Connection"));
It is not necessary to call Format() . Just assign the string literal directly.
deeps_cute wrote: CString ipadd;
ipadd.Format(_T("%s"),m_IpAddress);
ipadd is not used. Is that intentional?
deeps_cute wrote: system(command);
Is the value of command correct at this point?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes i assigned the value of m_ipadd directly. the vale returned from command is correct.
UpdateData(TRUE);
char para2[1024];
strcpy (para2, "\"Local Area Connection\" ");
CString command;
command.Format(_T("netsh interface ip set address name=%s static %s %s %s 1"),para3,m_IpAddress,m_subnet,m_gateway);
system(command);
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: the vale returned from command is correct.
The value returned by system() is an integer which is zero or one of E2BIG, ENOENT, ENOEXEC or ENOMEM. I suspect you meant to capture the text output of the call. If that's the case, you may want to see this[^] article.
Corrected article link[^]
/ravi
|
|
|
|
|
thats nice but whats the case when we use shellexecute instead of system("")
-- modified at 11:59 Tuesday 6th March, 2007
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
deeps_cute wrote: thats nice but whats the case when we use shellexecute instead of system("")
As MSDN says, system() passes a command to the command interpreter, which executes the string as an operating-system command while ShellExecute() performs an operation on a file.
/ravi
|
|
|
|
|
Sorry, I pointed you to a C# article. See this[^] article instead.
/ravi
|
|
|
|
|
deeps_cute wrote: char para2[1024];
strcpy (para2, "\"Local Area Connection\" ");
You went from bad to worse. What's wrong with:
CString para2(\"Local Area Connection\"); or
CString para2 = "\"Local Area Connection\""; deeps_cute wrote: the vale returned from command is correct.
So what is it? You should be able to take the exact string (i.e., the contents of command ), paste it into a command prompt, and get the desired results. If not, then command is not formatted properly.
deeps_cute wrote: command.Format(_T("netsh interface ip set address name=%s static %s %s %s 1"),para3,m_IpAddress,m_subnet,m_gateway);
Is the value of para3 the same as it was in your initial post?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yes it is the same.the value of command is "netsh interface ip set address name="Local Area Connection" satic 192.168.168.110 255.255.255.5 192.168.168.168. but it havent set the ipaddress
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|