NetSim Source Code Help
Loading...
Searching...
No Matches
SimProcessInterpretor.c
Go to the documentation of this file.
1
/************************************************************************************
2
* Copyright (C) 2020 *
3
* TETCOS, Bangalore. India *
4
* *
5
* Tetcos owns the intellectual property rights in the Product and its content. *
6
* The copying, redistribution, reselling or publication of any or all of the *
7
* Product or its content without express prior written consent of Tetcos is *
8
* prohibited. Ownership and / or any other right relating to the software and all *
9
* intellectual property rights therein shall remain at all times with Tetcos. *
10
* *
11
* Author: Shashi kant suman
12
* *
13
* ---------------------------------------------------------------------------------*/
14
#include "
main.h
"
15
#include <signal.h>
16
#include "
CLI.h
"
17
18
void
cli_stop_simulation
(
ptrCLIENTINFO
info)
19
{
20
SIMSTATE
sim =
netsim_get_simstate
();
21
if
(sim ==
SIMSTATE_NOTSTARTED
)
22
send_message
(info,
"Simulation is not yet started\n"
);
23
else
if
(sim ==
SIMSTATE_STOPPED
)
24
send_message
(info,
"Simulation is already stopped\n"
);
25
else
26
raise(SIGINT);
27
}
28
29
void
cli_pause_simulation_at
(
ptrCLIENTINFO
info,
double
time)
30
{
31
SIMSTATE
sim =
netsim_get_simstate
();
32
if
(sim ==
SIMSTATE_STOPPED
)
33
send_message
(info,
"Simulation is already stopped\n"
);
34
else
35
{
36
NetSim_EVENTDETAILS
pevent;
37
memset(&pevent, 0,
sizeof
pevent);
38
pevent.
dEventTime
= time*
SECOND
;
39
pevent.
nEventType
=
TIMER_EVENT
;
40
pevent.
nSubEventType
=
SUBEVENT_PAUSESIMULATION
;
41
fnpAddEvent
(&pevent);
42
}
43
}
44
45
void
cli_pause_simulation
(
ptrCLIENTINFO
info)
46
{
47
SIMSTATE
sim =
netsim_get_simstate
();
48
if
(sim ==
SIMSTATE_NOTSTARTED
)
49
{
50
send_message
(info,
"Simulation is not yet started. Pausing at 0 sec.\n"
);
51
cli_pause_simulation_at
(info, 0);
52
}
53
else
if
(sim !=
SIMSTATE_RUNNING
)
54
send_message
(info,
"Simulation is not in running state\n"
);
55
else
56
netsim_set_simstate
(
SIMSTATE_PAUSED
);
57
}
58
59
void
cli_continue_simulation
(
ptrCLIENTINFO
info)
60
{
61
SIMSTATE
sim =
netsim_get_simstate
();
62
if
(sim ==
SIMSTATE_NOTSTARTED
)
63
send_message
(info,
"Simulation is not yet started\n"
);
64
else
if
(sim ==
SIMSTATE_STOPPED
)
65
send_message
(info,
"Simulation is already stopped\n"
);
66
else
if
(sim ==
SIMSTATE_RUNNING
)
67
send_message
(info,
"Simulation is already running\n"
);
68
else
69
netsim_set_simstate
(
SIMSTATE_RUNNING
);
70
}
71
72
void
cli_clear_prompt
(
ptrCLIENTINFO
info)
73
{
74
free
(info->
promptString
);
75
info->
promptString
= NULL;
76
send_message
(info,
"%s %s"
,
CMD_CHANGEPROMPT
,
DEFAULT_PROMPT
);
77
}
CLI.h
DEFAULT_PROMPT
#define DEFAULT_PROMPT
Definition:
CLI.h:10
CMD_CHANGEPROMPT
#define CMD_CHANGEPROMPT
Definition:
CLI.h:12
send_message
void send_message(ptrCLIENTINFO info, char *msg,...)
Definition:
commandProcessor.c:10
free
#define free(p)
Definition:
Memory.h:31
cli_continue_simulation
void cli_continue_simulation(ptrCLIENTINFO info)
Definition:
SimProcessInterpretor.c:59
cli_pause_simulation_at
void cli_pause_simulation_at(ptrCLIENTINFO info, double time)
Definition:
SimProcessInterpretor.c:29
cli_clear_prompt
void cli_clear_prompt(ptrCLIENTINFO info)
Definition:
SimProcessInterpretor.c:72
cli_pause_simulation
void cli_pause_simulation(ptrCLIENTINFO info)
Definition:
SimProcessInterpretor.c:45
cli_stop_simulation
void cli_stop_simulation(ptrCLIENTINFO info)
Definition:
SimProcessInterpretor.c:18
SUBEVENT_PAUSESIMULATION
@ SUBEVENT_PAUSESIMULATION
Definition:
Stack.h:126
SIMSTATE_PAUSED
@ SIMSTATE_PAUSED
Definition:
Stack.h:83
SIMSTATE_RUNNING
@ SIMSTATE_RUNNING
Definition:
Stack.h:84
SIMSTATE_NOTSTARTED
@ SIMSTATE_NOTSTARTED
Definition:
Stack.h:82
SIMSTATE_STOPPED
@ SIMSTATE_STOPPED
Definition:
Stack.h:85
netsim_set_simstate
void netsim_set_simstate(SIMSTATE state)
netsim_get_simstate
SIMSTATE netsim_get_simstate()
SECOND
#define SECOND
Definition:
Stack.h:60
TIMER_EVENT
@ TIMER_EVENT
Definition:
Stack.h:114
SIMSTATE
enum enum_sim_state SIMSTATE
main.h
fnpAddEvent
#define fnpAddEvent(pstruEvent)
Definition:
main.h:191
stru_NetSim_EventDetails
Definition:
Stack.h:744
stru_NetSim_EventDetails::nEventType
EVENT_TYPE nEventType
Definition:
Stack.h:747
stru_NetSim_EventDetails::nSubEventType
NETSIM_ID nSubEventType
Definition:
Stack.h:757
stru_NetSim_EventDetails::dEventTime
double dEventTime
Definition:
Stack.h:746
stru_clientInfo
Definition:
CLI.h:70
stru_clientInfo::promptString
char * promptString
Definition:
CLI.h:82
ALL
Component 1
Part 5
CLIInterpretor
SimProcessInterpretor.c
Generated on Fri Dec 9 2022 10:22:46 for NetSim Source Code Help by
1.9.5