summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--globals.h6
-rw-r--r--instr-daemon.c11
-rw-r--r--menus.c54
3 files changed, 50 insertions, 21 deletions
diff --git a/globals.h b/globals.h
index 2e9e700..8d591be 100644
--- a/globals.h
+++ b/globals.h
@@ -785,6 +785,11 @@ typedef struct {
typedef struct {
+ int connections;
+} RemoteStruct;
+
+
+typedef struct {
ConstraintsStruct Constraints;
ChannelStruct ChannelState[max_channels];
FlashStruct Flash;
@@ -795,6 +800,7 @@ typedef struct {
FlagStruct DefaultFlags;
TimeStruct Timers;
MenuStatusStruct MenuStatus;
+ RemoteStruct Remote;
int control_mode; // FIXME and all instances of control_mode
} GlobalStruct;
diff --git a/instr-daemon.c b/instr-daemon.c
index a60ed83..553745f 100644
--- a/instr-daemon.c
+++ b/instr-daemon.c
@@ -23,8 +23,7 @@ static gboolean periodic_poll (void);
int port=3333; //port to listen
-int connections=0;
-int maxConn=16; //max connections - 16
+int maxConn=8; //max connections - 8
guint signalMyCb; //signal to register which is used in cbClientInput(), step 10 from requirements
GAsyncQueue** stdinQueue=NULL;
@@ -101,11 +100,11 @@ incomingConnection (GSocketService *service,
GSocketListener *listener,
gpointer user_data)
{
- if(connections +1 > maxConn) {
+ if(globals.Remote.connections +1 > maxConn) {
g_print_debug("Connection closed. Max reached\n");
return TRUE;
}
- connections++;
+ globals.Remote.connections++;
g_print_debug("Incoming connection\n");
return FALSE;
}
@@ -126,7 +125,7 @@ handler (GThreadedSocketService *service,
out = g_io_stream_get_output_stream (G_IO_STREAM (connection));
in = g_io_stream_get_input_stream (G_IO_STREAM (connection));
- g_print_debug("Handling, connections: %d\n", connections);
+ g_print_debug("Handling %d connections\n", globals.Remote.connections);
//register ourselves in the peers vector, use the index obtained in the stdinQueue
//should not get -1
@@ -182,7 +181,7 @@ handler (GThreadedSocketService *service,
}
g_print_debug("Thread end\n");
- connections--; //keep track of connections
+ globals.Remote.connections--; //keep track of connections
g_async_queue_unref(queue); //unreference the queue
pullIndex(g_thread_self()); //unregister from the peers vector
return TRUE;
diff --git a/menus.c b/menus.c
index fce9623..3e57ab5 100644
--- a/menus.c
+++ b/menus.c
@@ -256,6 +256,26 @@ void Menu_Update_Display(void)
globals.MenuStatus.Error_Screen=NO;
globals.MenuStatus.Nonstd_Display=NO;
+ int is_remote, is_lockout;
+ GPIB_check_remote_status (&is_remote, &is_lockout);
+
+#define RM_NOT_LOCK 0
+#define RM_NOT_REM 0
+#define RM_NOT_TERM 0
+#define RM_LOCK 1
+#define RM_REM 2
+#define RM_TERM 4
+
+ int remote_mode = 0;
+ if (is_lockout) {
+ remote_mode += RM_LOCK;
+ }
+ if (is_remote) {
+ remote_mode += RM_REM;
+ }
+ if (globals.Remote.connections > 0) {
+ remote_mode += RM_TERM;
+ }
/* fill in unused cursor columns */
for (i=0; i<(menu_cursor_pos % LCD_max_entries_per_page); ++i) {
@@ -938,30 +958,34 @@ void Menu_Update_Display(void)
gchar *ctrl_str = NULL;
- switch (globals.control_mode) {
- case REMS_ctrl:
- ctrl_str = g_strdup ("GPIB CTRL");
+
+//FIXME delete all refs to globals.control_mode
+ switch (remote_mode) {
+ case (RM_NOT_TERM | RM_NOT_REM | RM_NOT_LOCK):
+ case (RM_NOT_TERM | RM_NOT_REM | RM_LOCK):
+ ctrl_str = g_strdup ("LOCAL");
break;
- case RWLS_ctrl:
- ctrl_str = g_strdup ("GPIB LOCK");
+ case (RM_NOT_TERM | RM_REM | RM_NOT_LOCK):
+ ctrl_str = g_strdup ("LOCAL+GPIB");
break;
- case RS232_ctrl:
- ctrl_str = g_strdup ("RS232 CTRL");
+ case (RM_NOT_TERM | RM_REM | RM_LOCK):
+ ctrl_str = g_strdup ("GPIB");
break;
- case WEB_ctrl:
- ctrl_str = g_strdup ("WEB CTRL");
+ case (RM_TERM | RM_NOT_REM | RM_NOT_LOCK):
+ case (RM_TERM | RM_NOT_REM | RM_LOCK):
+ ctrl_str = g_strdup_printf ("LOCAL+%dTER", globals.Remote.connections);
break;
- case TELNET_ctrl:
- ctrl_str = g_strdup ("TELNET CTRL");
+ case (RM_TERM | RM_REM | RM_NOT_LOCK):
+ ctrl_str = g_strdup_printf ("LO+GPIB+%dTER", globals.Remote.connections);
break;
- case LWLS_ctrl:
- ctrl_str = g_strdup ("LOCAL LOCK");
+ case (RM_TERM | RM_REM | RM_LOCK):
+ ctrl_str = g_strdup_printf ("GPIB+%dTER", globals.Remote.connections);
break;
- case LOCS_ctrl:
default:
- ctrl_str = g_strdup ("LOCAL CTRL");
+ ctrl_str = g_strdup ("LOCAL");
break;
}
+ printf ("control mode: %s\n", ctrl_str); // FIXME - delete
if (globals.Changes.update_whole_main_menu && Menu_Is_Item_Visible(LCD_entry)) {
LCD_write_padded_spaces(LCD_row,LCD_col,ctrl_str,LCD_col_width);