Example #1
0
        private void SetSyringe(object sender)
        {
            ComboBox cb = (ComboBox)sender;

            if (syringeCombobox.SelectedItem == null)
            {
                validateSyringe();
            }
            else
            {
                if (syringe != syringes[cb.SelectedIndex])
                {
                    syringe = syringes[cb.SelectedIndex];
                    decoder.setSyringe(syringe);
                    reset(sw);
                }

                DisplaySpeedValue();

                communication.sendCommand(Commands.HARD_STOP.ToString("D"), syringe.getStop());
                set_syringe.Enabled = false;

                t.Start();
                Thread.Sleep(100);
                t.Stop();
            }
        }
Example #2
0
            private static long calculateProperties(Syringe syringe, double injectionVolume, int currentPosition)
            {
                double param = injectionVolume / (syringe.volume * 1000);
                long   stop  = (long)(currentPosition + getDistance(syringe, param));

                return(stop);
            }
Example #3
0
        /// <summary>
        /// Create New Syringe Form.
        /// </summary>
        /// <param ID="id">
        /// Id of new syringe to create
        /// </param>
        /// <param Decoder="d"></param>
        public NewSyringe(int id, ProgressDecoder d)
        {
            InitializeComponent();
            initColors();

            decoder    = d;
            connector  = SyringesBaseConnector.getInstance();
            newSyringe = new Syringe()
            {
                ID = id
            };

            this.ok_btn.DialogResult = DialogResult.OK;

            t           = new System.Timers.Timer();
            t.Interval  = 25;
            t.Elapsed  += new ElapsedEventHandler(getData);
            t.AutoReset = true;

            communication = Communication.getCommunicationManager();

            speed_cmb.SelectedIndex = 0;

            decoder.NewPositionArrived += new EventHandler <DecoderArgs>(newPositionEvent);
            decoder.HomingDoneArrived  += new EventHandler <DecoderArgs>(homeDoneEvent);
        }
Example #4
0
 public static bool startPosition(Syringe syringe)
 {
     try
     {
         long startPos = Convert.ToInt32(syringe.start_pos);
         communication.sendCommand(Commands.SET_START.ToString("D"), startPos);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #5
0
 public static bool startInjection(Syringe syringe)
 {
     try
     {
         communication.sendCommand(Commands.SET_PERIOD.ToString("D"), syringe.getDelay());
         communication.sendCommand(Commands.RUN.ToString("D"));
         return(SUCCESS);
     }
     catch
     {
         return(ERROR);
     }
 }
 /// <summary>
 /// Add new Syringe.
 /// Write to CSV all values of new Syringe.
 /// </summary>
 /// <param Syringe object = "syringe"></param>
 /// <returns>
 /// return true if write, false if raise exception.
 /// </returns>
 public bool addSyringe(Syringe syringe)
 {
     try
     {
         using (StreamWriter sw = File.AppendText(path))
         {
             sw.Write(string.Format("\n{0};{1};{2};{3};{4}", syringe.ID, syringe.name, syringe.volume, syringe.length, syringe.start_pos));
             sw.Close();
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #7
0
            public static bool startInjection(Syringe syringe, double injectionVolume, int currentPosition)
            {
                long stop = calculateProperties(syringe, injectionVolume, currentPosition);

                try
                {
                    communication.sendCommand(Commands.SET_PERIOD.ToString("D"), syringe.getDelay());
                    communication.sendCommand(Commands.STOP_POS.ToString("D"), stop);
                    communication.sendCommand(Commands.BOLUS.ToString("D"));
                    return(SUCCESS);
                }
                catch
                {
                    return(ERROR);
                }
            }
Example #8
0
 private static double getDistance(Syringe syringe, double param)
 {
     return(syringe.length * param);
 }
 public void setSyringe(Syringe syringe)
 {
     this.syringe = syringe;
 }
 public ProgressDecoder(Syringe syringe)
 {
     this.syringe = syringe;
 }