Commits

iorodeo committed 2eb17cc

Modified so that second input fields accept decimals. Added control over 2nd
current channel for IR lighting.

  • Participants
  • Parent commits 4e4815b

Comments (0)

Files changed (6)

lia_web_interface/src/lia_web_interface/config.py

 
 page_header = 'LIA - Video Acquisition System'
 server_port = 5000
+ir_light_channel = 'b'
 
 tab_dict = {
         'capture': {
         {
             'name'      : 'Recording Duration', 
             'tag'       : 'recording_duration', 
-            'value'     : (0,10,0), 
+            'value'     : (0,10,0.0), 
             'units'     : time_units,
             'type'      : 'time',
             },
         {   
             'name'      : 'Pulse Start Time',
             'tag'       : 'pulse_start_time',
-            'value'     : (0,3,0), 
+            'value'     : (0,3,0.0), 
             'units'     : time_units,
             'type'      : 'time',
             },
         {
             'name'      : 'Pulse High Time',
             'tag'       : 'pulse_high_time',
-            'value'     : (0,1,0), 
+            'value'     : (0,1,0.0), 
             'units'     : time_units,
             'type'      : 'time',
             },
         {
             'name'      : 'Pulse Period',
             'tag'       : 'pulse_period',
-            'value'     : (0,0,30), 
+            'value'     : (0,0,30.0), 
             'units'     : time_units,
             'type'      : 'time',
             },
 # Image quality option
 mjpeg_quality = 80 
 
+
 # For development only
 username = 'admin'
 password = 't3st'

lia_web_interface/src/lia_web_interface/display_tools.py

 """
 A collection of service functions usefull for createing the web display.
 """
+import math
 import config
 
 def get_log_display(log_values, show_file_suffix=False, color_values=('c2','c1')):
 
 
 def time_display(values):
-    return '%02d:%02d:%02d'%values
+    hr, mn, sc = values
+    sc_int = math.floor(sc)
+    sc_rem = int((math.floor(10*(sc - sc_int))))
+    if sc_rem != 0:
+        return '%02d:%02d:%02d.%d'%(hr,mn,sc_int,sc_rem,)
+    else:
+        return '%02d:%02d:%02d'%(hr,mn,sc_int,)
 
 def number_display(value):
     return '%d'%(value,)

lia_web_interface/src/lia_web_interface/form_tools.py

     except ValueError:
         t_min = 0
     try:
-        t_sec = int(form['%s_sec'%(name,)])
+        t_sec = float(form['%s_sec'%(name,)])
     except ValueError:
         t_sec = 0
     return  normalize_min_sec(t_hr, t_min, t_sec)
     """
     t = 3600.0*t_hr + 60.0*t_min + t_sec
     t_hr_norm = int(math.floor(t/3600.0))
-    t_rem = int(t - 3600*t_hr_norm)
+    t_rem = float(t - 3600*t_hr_norm)
 
     t_min_norm = int(math.floor(t_rem/60.0))
-    t_sec_norm = int(t_rem - 60*t_min_norm)
+    t_sec_norm = float(t_rem - 60*t_min_norm)
+    t_sec_norm = 0.1*(math.floor(10*t_sec_norm))
     return t_hr_norm, t_min_norm, t_sec_norm
 
 def get_selected_avi_files(form):

lia_web_interface/src/lia_web_interface/templates/capture.html

         setTimeout(arguments.callee,500);
     }, 500);
 </script>
+
+<script> 
+    function handleChange(input) { 
+        if (input.value < 0) input.value = 0; 
+        if (input.value > 1000) input.value = 1000; 
+        Sijax.request('update_ir_light',[input.value]);
+    } 
+</script>
+
 {% endblock %}
 
 {% block body%}
     <br>
 
     <div style="text-align:left;"> 
+        IR Light (Ch B) <input name="ir_light_input" id="ir_light_input" size="3" value="0" onKeyPress="return numbersonly(this,event)" onChange="handleChange(this)"\>
+        mA
+        <br> <br> <br>
         <button  name="recording_button" id="recording_button" onclick="Sijax.request('start_stop_recording');">{{recording_button_text}} </button>
         &nbsp;
         <span class="warning" id="avi_exists_message">  </span>

lia_web_interface/src/lia_web_interface/templates/forms.html

                                     id="{{item['tag']}}_{{label}}" 
                                     name="{{item['tag']}}_{{label}}" 
                                     type="text" 
-                                    onKeyPress="return numbersonly(this,event)" 
+                                    {% if i==2 %}
+                                        onKeyPress="return numbersonly(this,event,true)" 
+                                    {% else %}
+                                        onKeyPress="return numbersonly(this,event)" 
+                                    {% endif %}
                                     size="3" 
                                     value={{item['value_num'][i]}} 
                                 />  

lia_web_interface/src/lia_web_interface/web_interface.py

 
 # ROS Services
 from lia_services.srv import RecordingCmd
+from lia_services.srv import SetCurrentCmd
 
 # Set up application and database
 app = flask.Flask(__name__)
         # This is a sijax request - let sijax handle it
         flask.g.sijax.register_callback('update_recording_button', update_recording_button)
         flask.g.sijax.register_callback('start_stop_recording', start_stop_recording)
+        flask.g.sijax.register_callback('update_ir_light', update_ir_light)
         return flask.g.sijax.process_request()
 
     else:
     obj_response.html('#proxy_error_message', proxy_error_message)
     return
 
+def update_ir_light(obj_response,value):
+    """
+    Update the IR light on the current controller.
+    """
+    value = int(value)
+    set_ir_light_current(value)
+    return
+
+def set_ir_light_current(value):
+    """
+    Sets the current value for the IR light
+    """
+    try:
+        set_curr_proxy = rospy.ServiceProxy('set_current', SetCurrentCmd) 
+        response =set_curr_proxy(config.ir_light_channel,'on', value)
+    except rospy.ServiceException, e:
+        pass
 # -----------------------------------------------------------------------------
 if __name__ == '__main__': 
 
     except IndexError:
         server = 'tornado'
 
+    # Initialize ir lighting
+    set_ir_light_current(0)
+
     if server == 'debug':
         print ' * using debug server'
         app.debug = True