示例#1
0
文件: Protocol.cs 项目: RobAmos/osla
 public StaticProtocolItem ReplaceVariablesWithValues(StaticProtocolItem ToRun)
 {
     //This method will take a protocol item that has variables, and replace it with actual values,
     //It should be called before the method is run
     StaticProtocolItem NewProtocolItem = ToRun.Clone();
     NewProtocolItem.ContainingProtocol = this;
     for (int i = 0; i < NewProtocolItem.Parameters.Length; i++)
     {
         object o = ToRun.Parameters[i];
         //check if it is a string
         if (o is string)
         {
             string VariableName;
             //now have to go through and remove all of the variables, replacing them with other strings
             String myval = (String)o;
             while (true)
             {
                 bool variableInString = ProtocolManager.GetVariableNameFromText(myval, out VariableName);
                 if (variableInString)
                 {
                     string ToReplace = Variables[VariableName].Value.ToString();
                     myval = myval.Replace(VariableName, ToReplace);//swap out the value and searchagain
                 }
                 else
                 { break; }
             }
             ToRun.Parameters[i] = myval;
         }
         else if (o is ReferenceToProtocolVariable)
         {
             ReferenceToProtocolVariable RefToVariable = (ReferenceToProtocolVariable)o;
             ToRun.Parameters[i] = Variables[RefToVariable.ToString()].Value;
         }
     }
     return NewProtocolItem;
 }
示例#2
0
文件: Protocol.cs 项目: RobAmos/osla
 public ListBoxProtocolItem()
 {
     Instruction = new StaticProtocolItem();
 }
示例#3
0
文件: Protocol.cs 项目: RobAmos/osla
 public StaticProtocolItem Clone()
 {
     StaticProtocolItem SP = new StaticProtocolItem();
     SP.MethodName = this.MethodName;
     SP.Parameters = this.Parameters;
     SP.InstrumentName = this.InstrumentName;
     SP.ContainingProtocol = this.ContainingProtocol;
     return SP;
 }
示例#4
0
        private void CreateProtocolItems(string ExpName,int Slot)
        {
            ExpSlot = Slot;
            toVictorInstruction = new StaticProtocolItem();
            toVictorInstruction.InstrumentName = "Macros";
            toVictorInstruction.Parameters = new object[1] { Slot };
            toVictorInstruction.MethodName = "MovePlateFromIncubatorToVictor";

            OD_OutDirec=ExpName + "_" + Slot.ToString();

            ODReadInstruction = new StaticProtocolItem();
            ODReadInstruction.MethodName = "ReadPlate2";
            ODReadInstruction.InstrumentName = "PlateReader";
            ODReadInstruction.Parameters = new object[2] {OD_OutDirec, OD600ProtocolID };

            VenusReadInstruction = ODReadInstruction.Clone();
            //VenusReadInstruction = new StaticProtocolItem();
            //VenusReadInstruction.MethodName = "ReadPlate2";
            //VenusReadInstruction.InstrumentName = "Plate_Reader";
            //VenusReadInstruction.Parameters = new object[2] { "Ve_" + OD_OutDirec, VenusProtocolID };
            VenusReadInstruction.Parameters[1] = VenusProtocolID;

            awayFromVictorInstruction = toVictorInstruction.Clone();
            awayFromVictorInstruction.MethodName = "MovePlateFromVictorToIncubatorWithLidOnTransferStation";

            DT = new DelayTime();
            DT.minutes = MinBetweenReads;

            ReturnInstruction = new StaticProtocolItem();
            ReturnInstruction.MethodName = "ModifyGrowthProtocol";
            ReturnInstruction.InstrumentName = this.Name;
            //Last item is passed in by the parser
            ReturnInstruction.Parameters = new object[2] { ExpName, Slot };
        }
示例#5
0
        /// <summary>
        /// This method creates a protocol to run a certain type of 
        /// experiment for the user, in this case an experiment that moves plates
        /// from an incubator to a plate reader periodically.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStartGrowthRate_Click(object sender, EventArgs e)
        {
            try
            {
                //this will create and start a protocol, first to check for errors
                int minuteDelay = 0;
                int cycles = 0;
                if (txtGrowthRateEmail.Text == "" | txtGrowthRateExperimentName.Text == "" | txtGrowthRateMinutes.Text == "" | txtGrowthRateTimesToMeasure.Text == "")
                {
                    ShowError("You did not fill out all of the required fields");
                }
                else if (lstGrowthRatesProtocol.SelectedIndex == -1)
                {
                    ShowError("You did not select any slots");
                }
                // For SkypeAlarm
                else if (ClarityEngine.UseAlarm && ClarityEngine.Clarity_Alarm!=null && ClarityEngine.Clarity_Alarm.Connected && !ClarityEngine.Clarity_Alarm.ValidNumbers(textbox_number.Text))
                {
                    ShowError("Your number is not valid!");
                }
                else
                {
                    try { minuteDelay = Convert.ToInt32(txtGrowthRateMinutes.Text); cycles = Convert.ToInt32(txtGrowthRateTimesToMeasure.Text); }
                    catch { ShowError("Could not convert your delay or measurement into an integer, please enter an appropriate value"); return; }
                    if (minuteDelay < 9 | minuteDelay > 25 * 60)
                    {
                        ShowError("Your delay time is  weird, please make it greater then 9 minutes or less than 25 hours");
                        return;
                    }
                    if (cycles < 0 | cycles > 200)
                    {
                        ShowError("You seem to have selected less than 0 or more than 200 readings, please pick an alternative");
                        return;
                    }
                    Protocol NewProt = new Protocol();
                    NewProt.ProtocolName = txtGrowthRateExperimentName.Text;
                    NewProt.ErrorEmailAddress = txtGrowthRateEmail.Text;
                    NewProt.ErrorPhoneNumber = textbox_number.Text;
                    NewProt.Instructions = new List<ProtocolInstruction>();
                    for (int i = 0; i < cycles; i++)
                    {
                        foreach (int plateslot in lstGrowthRatesProtocol.SelectedItems)
                        {
                            //move from incubator to platereader
                            StaticProtocolItem SP = new StaticProtocolItem();
                            SP.InstrumentName = "Macros";
                            SP.Parameters = new object[1] { plateslot };
                            SP.MethodName = "MovePlateFromIncubatorToVictor";
                            NewProt.Instructions.Add(SP);
                            //read plate
                            StaticProtocolItem SP2;
                            if (chk48WellPlate.Checked)
                            {
                                SP2 = new StaticProtocolItem();
                                SP2.MethodName = "ReadPlate2";
                                SP2.InstrumentName = "PlateReader";
                                SP2.Parameters = new object[2] { NewProt.ProtocolName + INSTRUMENT_NAME_DELIMITER + plateslot.ToString(), WELL48_PLATE_PROTOCOL_ID };
                                NewProt.Instructions.Add(SP2);

                            }
                            else if (chkGBO.Checked)
                            {
                                SP2 = new StaticProtocolItem();
                                SP2.MethodName = "ReadPlate2";
                                SP2.InstrumentName = "PlateReader";
                                SP2.Parameters = new object[2] { NewProt.ProtocolName + INSTRUMENT_NAME_DELIMITER + plateslot.ToString(), GBO_PLATE_PROTOCOL_ID };
                                NewProt.Instructions.Add(SP2);
                            }
                            else
                            {
                                SP2 = new StaticProtocolItem();
                                SP2.MethodName = "ReadPlate";
                                SP2.InstrumentName = "PlateReader";
                                SP2.Parameters = new object[1] { NewProt.ProtocolName + INSTRUMENT_NAME_DELIMITER + plateslot.ToString() };
                                NewProt.Instructions.Add(SP2);
                            }
                            //now to move the old plate back
                            SP2 = SP.Clone();
                            SP2.MethodName = "MovePlateFromVictorToIncubatorWithLidOnTransferStation";
                            NewProt.Instructions.Add(SP2);
                        }
                        DelayTime DT = new DelayTime();
                        DT.minutes = minuteDelay;
                        NewProt.Instructions.Add(DT);
                    }
                    DialogResult DR = MessageBox.Show("Are you sure you have entered the right values and are ready to load this protocol?", "Final Check", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (DR == DialogResult.Yes)
                    {

                        ClarityEngine.AddProtocol(NewProt);
                        UpdateLoadedProtocols();
                        if (ClarityEngine.CurrentRunningState == RunningStates.Idle)//this timer is running while a protocol is waiting to go
                        {
                            DialogResult DR2 = MessageBox.Show("Would you like to start your protocol immediately?", "Begin Protocol", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                            if (DR2 == DialogResult.Yes)
                            {
                                ClarityEngine.StartProtocolExecution();
                            }
                        }
                    }
                }
            }
            catch { ShowError("Weird error occurred"); }
        }
示例#6
0
        private void btnGenerateNSFData_Click(object sender, EventArgs e)
        {
            try
            {
                int tranNum;
                List<Protocol> ProtsToAdd = new List<Protocol>();
                //this will create and start a protocol, first to check for errors
                if (txtNSFTransferNumber.Text == "" | txtNSFName.Text == "")
                {
                    ShowError("You did not fill out all of the required fields");
                }
                else if (lstNSFPlates.SelectedIndex == -1)
                {
                    ShowError("You did not select any slots");
                }
                else
                {
                    try { tranNum = Convert.ToInt32(txtNSFTransferNumber.Text); }
                    catch { ShowError("Could not convert your transfer number into an integer, please enter an appropriate value"); return; }
                    //NSFExperiment tmp = new NSFExperiment();
                    foreach (int plateslot in lstNSFPlates.SelectedItems)
                    {
                        Protocol NewProt = new Protocol();
                        NewProt.ErrorEmailAddress = "";
                        string baseName = "NSF-" + txtNSFName.Text + "-" + txtNSFTransferNumber.Text.ToString();
                        NewProt.ProtocolName = baseName + "_" + plateslot.ToString();
                        StaticProtocolItem SP = new StaticProtocolItem();
                        SP.MethodName = "CreateProtocol";
                        //SP.InstrumentName = tmp.Name;
                        SP.Parameters = new object[2] { baseName, plateslot };
                        NewProt.Instructions.Add(SP);
                        ProtsToAdd.Add(NewProt);
                    }
                    Protocol Watcher = new Protocol();
                    Watcher.ProtocolName = "NSF-Error-" + txtNSFTransferNumber.Text.ToString();
                    Watcher.ErrorPhoneNumber = "4158234767";
                    Watcher.MaxIdleTimeBeforeAlarm = 50;
                    Watcher.ErrorEmailAddress = this.NSFErrorEmails;
                    DelayTime DT = new DelayTime();
                    DT.minutes = 60 * 70;
                    Watcher.Instructions.Add(DT);
                    ProtsToAdd.Add(Watcher);
                }
                DialogResult DR = MessageBox.Show("Are you sure you have entered the right values and are ready to load this protocol?", "Final Check", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (DR == DialogResult.Yes)
                {
                    foreach (Protocol p in ProtsToAdd)
                    {
                        ClarityEngine.AddProtocol(p);
                    }
                    UpdateLoadedProtocols();
                    if (ClarityEngine.CurrentRunningState==RunningStates.Idle)//this timer is running while a protocol is waiting to go
                    {
                        DialogResult DR2 = MessageBox.Show("Would you like to start your protocols immediately?", "Begin Protocol", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (DR2 == DialogResult.Yes)
                        {
                            ClarityEngine.StartProtocolExecution();
                        }
                    }
                }
            }

            catch { ShowError("Weird error occurred"); }
        }