NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
SimProcessInterpretor.c
1/************************************************************************************
2* Copyright (C) 2023 *
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
18void 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
29void 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
45void 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
59void 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
72void 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}