// Constructors public EVI_D70() { // Initialize internal variables port = new SerialPort(); hardware_connected = false; thread_control = new CancellationTokenSource(); initilization_error = false; serial_channel_open = new ManualResetEventSlim(true); socket_available = new ManualResetEventSlim(true); command_buffer = new ObservableCollection<command>(); emergency_stop_turnstyle = new ManualResetEventSlim(false); _pan = new angular_position(); _tilt = new angular_position(); _zoom = new zoom_position(); pan_tilt_status = DRIVE_STATUS.FULL_STOP; zoom_status = DRIVE_STATUS.FULL_STOP; last_inquiry_was_pan_tilt = false; num_cmds_since_inquiry = 0; command_buffer.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(command_buffer_changed_event_handler); command_buffer_populated = new ManualResetEventSlim(false); failed_command = null; last_successful_pan_tilt_cmd = null; last_successful_zoom_cmd = null; socket_one_cmd = null; socket_two_cmd = null; // Trace listener trace_msgs = new internal_trace_listener(); Trace.Listeners.Add(trace_msgs); position_data_error += new CameraHardwareErrorEventHandler(print_trace_log); serial_port_error += new CameraHardwareErrorEventHandler(print_trace_log); command_error += new CameraHardwareErrorEventHandler(print_trace_log); // Threads inquiry_after_stop_thread = new Thread(new ThreadStart(inquiry_after_stop)); pan_tilt_inquiry_after_stop = false; zoom_inquiry_after_stop = false; after_stop = new ManualResetEventSlim(false); pan_tilt_inquiry_complete = new ManualResetEventSlim(false); zoom_inquiry_complete = new ManualResetEventSlim(false); dispatch_thread = new Thread(new ThreadStart(dispatch)); receive_thread = new Thread(new ThreadStart(receive)); // PID pid_thread = new Thread(new ThreadStart(pid)); pid_turnstyle = new ManualResetEventSlim(false); pid_data_turnstyle = new ManualResetEventSlim(true); pid_pan_tilt_speed = (new pan_tilt_jog_command(1)).pan_tilt_speed; pid_zoom_speed = (new zoom_jog_command(1)).zoom_speed; _pan.position_changed += new EventHandler<EventArgs>(pid_data_changed); _tilt.position_changed += new EventHandler<EventArgs>(pid_data_changed); _zoom.position_changed += new EventHandler<EventArgs>(pid_data_changed); _pid_target_pan_position.position_changed += new EventHandler<EventArgs>(pid_data_changed); _pid_target_tilt_position.position_changed += new EventHandler<EventArgs>(pid_data_changed); _pid_target_zoom_position.position_changed += new EventHandler<EventArgs>(pid_data_changed); }
public void absolute_zoom(zoom_position zoom_ratio) { if (!hardware_connected) // No motion commands allowed now return; lock (command_buffer) { // Eliminate any zoom command from the buffer for (int i = 0; i < command_buffer.Count; ++i) if (command_buffer[i] is zoom_absolute_command || command_buffer[i] is zoom_cancel_command || command_buffer[i] is zoom_jog_command || command_buffer[i] is zoom_stop_jog_command) // There's already a zoom command that is awaiting dispatch command_buffer.RemoveAt(i); command_buffer.Add(new zoom_absolute_command(camera_num, zoom_ratio)); // Add it to the end of the buffer } }
public void deep_clone(zoom_absolute_command rhs) { base.deep_clone(rhs); zoom_pos = new zoom_position(rhs.zoom_pos); }
public zoom_absolute_command(zoom_absolute_command rhs) : base(rhs) { zoom_pos = new zoom_position(rhs.zoom_pos); }
public zoom_absolute_command(int camera_number, zoom_position z = null) : base(camera_number) { if (z == null) zoom_pos = new zoom_position(); else zoom_pos = new zoom_position(z); }
public void deep_clone(zoom_position rhs) { encoder_count = rhs.encoder_count; ratio = rhs.ratio; }
public static zoom_position create_from_ratio(double r) { zoom_position p = new zoom_position(); p.ratio = r; return p; }
public static zoom_position create_from_encoder_count(short e) { zoom_position p = new zoom_position(); p.encoder_count = e; return p; }
public zoom_position(zoom_position rhs) { encoder_count = rhs.encoder_count; ratio = rhs.ratio; }
public readonly_zoom_position(zoom_position rhs) { pos.deep_clone(rhs); }