Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 4e4ac93

Browse files
adeas31OpenModelica-Hudson
authored andcommitted
Added a new flag for interactive mode.
`--interactive=none|corba|tcp|zmq` The flags `-d=interactive` and `-d=interactiveCorba` are still valid with a depreciation message. The flag -d=interactiveZMQ is removed.
1 parent f1f89cc commit 4e4ac93

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

Compiler/Main/Main.mo

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ protected function interactivemode
662662
"Initiate the interactive mode using socket communication."
663663
input GlobalScript.SymbolTable symbolTable;
664664
algorithm
665-
print("Opening a socket on port " + intString(29500) + "\n");
666665
serverLoop(true, Socket.waitforconnect(29500), symbolTable);
667666
end interactivemode;
668667

@@ -869,6 +868,8 @@ protected function main2
869868
"This is the main function that the MetaModelica Compiler (MMC) runtime system calls to
870869
start the translation."
871870
input list<String> args;
871+
protected
872+
String interactiveMode;
872873
algorithm
873874
// Version requested using --version.
874875
if Config.versionRequest() then
@@ -877,7 +878,9 @@ algorithm
877878
end if;
878879

879880
// Don't allow running omc as root due to security risks.
880-
if System.userIsRoot() and (Flags.isSet(Flags.INTERACTIVE) or Flags.isSet(Flags.INTERACTIVE_CORBA) or Flags.isSet(Flags.INTERACTIVE_ZMQ)) then
881+
interactiveMode := Flags.getConfigString(Flags.INTERACTIVE);
882+
if System.userIsRoot() and (Flags.isSet(Flags.INTERACTIVE_TCP) or Flags.isSet(Flags.INTERACTIVE_CORBA)
883+
or interactiveMode == "corba" or interactiveMode == "tcp" or interactiveMode == "zmq") then
881884
Error.addMessage(Error.ROOT_USER_INTERACTIVE, {});
882885
print(ErrorExt.printMessagesStr(false));
883886
fail();
@@ -893,11 +896,17 @@ algorithm
893896
try
894897
Settings.getInstallationDirectoryPath();
895898

896-
if Flags.isSet(Flags.INTERACTIVE) then
899+
if Flags.isSet(Flags.INTERACTIVE_TCP) then
900+
print("The flag -d=interactive is depreciated. Please use --interactive=tcp\n");
901+
interactivemode(readSettings(args));
902+
elseif interactiveMode == "tcp" then
897903
interactivemode(readSettings(args));
898904
elseif Flags.isSet(Flags.INTERACTIVE_CORBA) then
905+
print("The flag -d=interactiveCorba is depreciated. Please use --interactive=corba\n");
906+
interactivemodeCorba(readSettings(args));
907+
elseif interactiveMode == "corba" then
899908
interactivemodeCorba(readSettings(args));
900-
elseif Flags.isSet(Flags.INTERACTIVE_ZMQ) then
909+
elseif interactiveMode == "zmq" then
901910
interactivemodeZMQ(readSettings(args));
902911
else // No interactive flag given, try to flatten the file.
903912
readSettings(args);

Compiler/Util/Flags.mo

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ constant DebugFlag TRANSFORMS_BEFORE_DUMP = DEBUG_FLAG(33, "transformsbeforedump
239239
Util.gettext("Applies transformations required for code generation before dumping flat code."));
240240
constant DebugFlag DAE_DUMP_GRAPHV = DEBUG_FLAG(34, "daedumpgraphv", false,
241241
Util.gettext("Dumps the DAE in graphviz format."));
242-
constant DebugFlag INTERACTIVE = DEBUG_FLAG(35, "interactive", false,
242+
constant DebugFlag INTERACTIVE_TCP = DEBUG_FLAG(35, "interactive", false,
243243
Util.gettext("Starts omc as a server listening on the socket interface."));
244244
constant DebugFlag INTERACTIVE_CORBA = DEBUG_FLAG(36, "interactiveCorba", false,
245245
Util.gettext("Starts omc as a server listening on the Corba interface."));
@@ -514,8 +514,6 @@ constant DebugFlag DISABLE_COLORING = DEBUG_FLAG(169, "disableColoring", false,
514514
Util.gettext("Disables coloring algorithm while spasity detection."));
515515
constant DebugFlag MERGE_ALGORITHM_SECTIONS = DEBUG_FLAG(170, "mergeAlgSections", false,
516516
Util.gettext("Disables coloring algorithm while spasity detection."));
517-
constant DebugFlag INTERACTIVE_ZMQ = DEBUG_FLAG(171, "interactiveZMQ", false,
518-
Util.gettext("Starts omc as a ZeroMQ server listening on the socket interface."));
519517

520518

521519
// This is a list of all debug flags, to keep track of which flags are used. A
@@ -558,7 +556,7 @@ constant list<DebugFlag> allDebugFlags = {
558556
EXEC_STAT,
559557
TRANSFORMS_BEFORE_DUMP,
560558
DAE_DUMP_GRAPHV,
561-
INTERACTIVE,
559+
INTERACTIVE_TCP,
562560
INTERACTIVE_CORBA,
563561
INTERACTIVE_DUMP,
564562
RELIDX,
@@ -693,8 +691,7 @@ constant list<DebugFlag> allDebugFlags = {
693691
EVAL_PARAM_DUMP,
694692
NF_UNITCHECK,
695693
DISABLE_COLORING,
696-
MERGE_ALGORITHM_SECTIONS,
697-
INTERACTIVE_ZMQ
694+
MERGE_ALGORITHM_SECTIONS
698695
};
699696

700697
public
@@ -931,7 +928,7 @@ constant ConfigFlag SILENT = CONFIG_FLAG(22, "silent",
931928

932929
constant ConfigFlag CORBA_SESSION = CONFIG_FLAG(23, "corbaSessionName",
933930
SOME("c"), EXTERNAL(), STRING_FLAG(""), NONE(),
934-
Util.gettext("Sets the name of the corba session if -d=interactiveCorba is used."));
931+
Util.gettext("Sets the name of the corba session if -d=interactiveCorba or --interactive=corba is used."));
935932

936933
constant ConfigFlag NUM_PROC = CONFIG_FLAG(24, "numProcs",
937934
SOME("n"), EXTERNAL(), INT_FLAG(0), NONE(),
@@ -1356,9 +1353,18 @@ constant ConfigFlag TEARING_STRICTNESS = CONFIG_FLAG(113, "tearingStrictness",
13561353
("veryStrict", Util.gettext("Very strict tearing rules that do not allow to divide by any parameter. Use this if you aim at overriding parameters after compilation with values equal to or close to zero."))
13571354
})),
13581355
Util.gettext("Sets the strictness of the tearing method regarding the solvability restrictions."));
1359-
constant ConfigFlag ZEROMQ_FILE_SUFFIX = CONFIG_FLAG(114, "zeroMQFileSuffix",
1356+
constant ConfigFlag INTERACTIVE = CONFIG_FLAG(114, "interactive",
1357+
NONE(), EXTERNAL(), STRING_FLAG("none"),SOME(
1358+
STRING_DESC_OPTION({
1359+
("none", Util.gettext("do nothing")),
1360+
("corba", Util.gettext("Starts omc as a server listening on the socket interface.")),
1361+
("tcp", Util.gettext("Starts omc as a server listening on the Corba interface.")),
1362+
("zmq", Util.gettext("Starts omc as a ZeroMQ server listening on the socket interface."))
1363+
})),
1364+
Util.gettext("Sets the interactive mode for omc."));
1365+
constant ConfigFlag ZEROMQ_FILE_SUFFIX = CONFIG_FLAG(115, "zeroMQFileSuffix",
13601366
SOME("z"), EXTERNAL(), STRING_FLAG(""), NONE(),
1361-
Util.gettext("Sets the file suffix for zeroMQ port file if -d=interactiveZMQ is used."));
1367+
Util.gettext("Sets the file suffix for zeroMQ port file if --interactive=zmq is used."));
13621368

13631369
protected
13641370
// This is a list of all configuration flags. A flag can not be used unless it's
@@ -1478,6 +1484,7 @@ constant list<ConfigFlag> allConfigFlags = {
14781484
WFC_ADVANCED,
14791485
GRAPHICS_EXP_MODE,
14801486
TEARING_STRICTNESS,
1487+
INTERACTIVE,
14811488
ZEROMQ_FILE_SUFFIX
14821489
};
14831490

Compiler/runtime/socketimpl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,11 @@ make_socket (unsigned short int port)
124124
return 0;
125125
}
126126

127-
if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0)
128-
{
129-
printf("Error binding socket\n");
130-
return 0;
131-
}
127+
if (bind (sock, (struct sockaddr *) &name, sizeof (name)) < 0) {
128+
printf("Error binding socket\n");
129+
return 0;
130+
}
131+
printf("Started a tcp server on port %d\n", port);fflush(NULL);
132132

133133
return sock;
134134
}

0 commit comments

Comments
 (0)