예제 #1
0
 public void SetValue(string channel, bool value)
 {
     HCState = SHCUIControlState.LOCAL;
     stateRecord.digitals[channel] = value;
     SetDigitalLine(channel, value);
     setValuesDisplayedOnUI(stateRecord);
     HCState = SHCUIControlState.OFF;
 }
예제 #2
0
 /// <summary>
 /// These SetValue functions are for giving commands to the hc from another program, while keeping the hc in control of hardware.
 /// Use this if you want the HC to keep control, but you want to control the HC from some other program
 /// </summary>
 public void SetValue(string channel, double value)
 {
     HCState = SHCUIControlState.LOCAL;
     stateRecord.analogs[channel] = value;
     SetAnalogOutput(channel, value, false);
     setValuesDisplayedOnUI(stateRecord);
     HCState = SHCUIControlState.OFF;
 }
예제 #3
0
 public void SetValue(string channel, double value, bool useCalibration)
 {
     stateRecord.analogs[channel] = value;
     HCState = SHCUIControlState.LOCAL;
     SetAnalogOutput(channel, value, useCalibration);
     setValuesDisplayedOnUI(stateRecord);
     HCState = SHCUIControlState.OFF;
 }
예제 #4
0
        public void Start()
        {
            // make the digital analogTasks. The function "CreateDigitalTask" is defined later
            //e.g   CreateDigitalTask("notEOnOff");
            //      CreateDigitalTask("eOnOff");

            //This is to keep track of the various things which the HC controls.
            analogTasks          = new Dictionary <string, Task>();
            stateRecord          = new hardwareState();
            stateRecord.analogs  = new Dictionary <string, double>();
            stateRecord.digitals = new Dictionary <string, bool>();

            tstage = new Parker404XR("ASRL1::INSTR", profilesPath + "TranslationStageInitFile.txt");
            CreateDigitalTask("aom0enable");
            CreateDigitalTask("aom1enable");
            CreateDigitalTask("aom2enable");
            CreateDigitalTask("aom3enable");
            CreateDigitalTask("shutterenable");

            // make the analog output analogTasks. The function "CreateAnalogOutputTask" is defined later
            //e.g.  bBoxAnalogOutputTask = CreateAnalogOutputTask("b");
            //      steppingBBiasAnalogOutputTask = CreateAnalogOutputTask("steppingBBias");

            CreateAnalogOutputTask("aom0amplitude");
            CreateAnalogOutputTask("aom0frequency");
            CreateAnalogOutputTask("aom1amplitude");
            CreateAnalogOutputTask("aom1frequency");
            CreateAnalogOutputTask("aom2amplitude");
            CreateAnalogOutputTask("aom2frequency");
            CreateAnalogOutputTask("aom3amplitude");
            CreateAnalogOutputTask("aom3frequency");
            CreateAnalogOutputTask("coil0current");
            CreateAnalogOutputTask("coil1current");

            CreateAnalogInputTask("laserLockErrorSignal", -10, 10);
            CreateAnalogInputTask("chamber1Pressure");
            CreateAnalogInputTask("chamber2Pressure");

            // make the control controlWindow
            controlWindow            = new ControlWindow();
            controlWindow.controller = this;


            HCState = SHCUIControlState.OFF;



            Application.Run(controlWindow);
        }
예제 #5
0
 /// <summary>
 /// This is used when you want another program to take control of some/all of the hardware. The hc then just saves the
 /// last hardware state, then prevents you from making any changes to the UI. Use this if your other program wants direct control of hardware.
 /// </summary>
 public void StartRemoteControl()
 {
     if (HCState == SHCUIControlState.OFF)
     {
         if (!ImageController.IsCameraFree())
         {
             StopCameraStream();
         }
         StoreParameters(profilesPath + "tempParameters.bin");
         HCState = SHCUIControlState.REMOTE;
         controlWindow.UpdateUIState(HCState);
         controlWindow.WriteToConsole("Remoting Started!");
     }
     else
     {
         MessageBox.Show("Controller is busy");
     }
 }
예제 #6
0
        public void StopRemoteControl()
        {
            try
            {
                controlWindow.WriteToConsole("Remoting Stopped!");
                setValuesDisplayedOnUI(loadParameters(profilesPath + "tempParameters.bin"));

                if (System.IO.File.Exists(profilesPath + "tempParameters.bin"))
                {
                    System.IO.File.Delete(profilesPath + "tempParameters.bin");
                }
            }
            catch (Exception)
            {
                controlWindow.WriteToConsole("Unable to load Parameters.");
            }
            HCState = SHCUIControlState.OFF;
            controlWindow.UpdateUIState(HCState);
            ApplyRecordedStateToHardware();
        }
예제 #7
0
        private void applyToHardware(hardwareState state)
        {
            if (state.analogs.Count != 0 || state.digitals.Count != 0)
            {
                if (HCState == SHCUIControlState.OFF)
                {
                    HCState = SHCUIControlState.LOCAL;
                    controlWindow.UpdateUIState(HCState);

                    applyAnalogs(state);
                    applyDigitals(state);

                    HCState = SHCUIControlState.OFF;
                    controlWindow.UpdateUIState(HCState);

                    controlWindow.WriteToConsole("Update finished!");
                }
            }
            else
            {
                controlWindow.WriteToConsole("The values on the UI are identical to those on the controller's records. Hardware must be up to date.");
            }
        }
예제 #8
0
        public void StopRemoteControl()
        {
            try
            {
                controlWindow.WriteToConsole("Remoting Stopped!");
                setValuesDisplayedOnUI(loadParameters(profilesPath + "tempParameters.bin"));

                if (System.IO.File.Exists(profilesPath + "tempParameters.bin"))
                {
                    System.IO.File.Delete(profilesPath + "tempParameters.bin");
                }
            }
            catch (Exception)
            {
                controlWindow.WriteToConsole("Unable to load Parameters.");
            }
            HCState = SHCUIControlState.OFF;
            controlWindow.UpdateUIState(HCState);
            ApplyRecordedStateToHardware();
        }
예제 #9
0
        private void applyToHardware(hardwareState state)
        {
            if (state.analogs.Count != 0 || state.digitals.Count != 0)
            {
                if (HCState == SHCUIControlState.OFF)
                {

                    HCState = SHCUIControlState.LOCAL;
                    controlWindow.UpdateUIState(HCState);

                    applyAnalogs(state);
                    applyDigitals(state);

                    HCState = SHCUIControlState.OFF;
                    controlWindow.UpdateUIState(HCState);

                    controlWindow.WriteToConsole("Update finished!");
                }
            }
            else
            {
                controlWindow.WriteToConsole("The values on the UI are identical to those on the controller's records. Hardware must be up to date.");
            }
        }
예제 #10
0
 /// <summary>
 /// This is used when you want another program to take control of some/all of the hardware. The hc then just saves the
 /// last hardware state, then prevents you from making any changes to the UI. Use this if your other program wants direct control of hardware.
 /// </summary>
 public void StartRemoteControl()
 {
     if (HCState == SHCUIControlState.OFF)
     {
         if (!ImageController.IsCameraFree())
         {
             StopCameraStream();
         }
         StoreParameters(profilesPath + "tempParameters.bin");
         HCState = SHCUIControlState.REMOTE;
         controlWindow.UpdateUIState(HCState);
         controlWindow.WriteToConsole("Remoting Started!");
     }
     else
     {
         MessageBox.Show("Controller is busy");
     }
 }
예제 #11
0
        public void Start()
        {
            // make the digital analogTasks. The function "CreateDigitalTask" is defined later
            //e.g   CreateDigitalTask("notEOnOff");
            //      CreateDigitalTask("eOnOff");

            //This is to keep track of the various things which the HC controls.
            analogTasks = new Dictionary<string, Task>();
            stateRecord = new hardwareState();
            stateRecord.analogs = new Dictionary<string, double>();
            stateRecord.digitals = new Dictionary<string, bool>();

            tstage = new Parker404XR("ASRL1::INSTR", profilesPath + "TranslationStageInitFile.txt");
            CreateDigitalTask("aom0enable");
            CreateDigitalTask("aom1enable");
            CreateDigitalTask("aom2enable");
            CreateDigitalTask("aom3enable");
            CreateDigitalTask("shutterenable");

            // make the analog output analogTasks. The function "CreateAnalogOutputTask" is defined later
            //e.g.  bBoxAnalogOutputTask = CreateAnalogOutputTask("b");
            //      steppingBBiasAnalogOutputTask = CreateAnalogOutputTask("steppingBBias");

            CreateAnalogOutputTask("aom0amplitude");
            CreateAnalogOutputTask("aom0frequency");
            CreateAnalogOutputTask("aom1amplitude");
            CreateAnalogOutputTask("aom1frequency");
            CreateAnalogOutputTask("aom2amplitude");
            CreateAnalogOutputTask("aom2frequency");
            CreateAnalogOutputTask("aom3amplitude");
            CreateAnalogOutputTask("aom3frequency");
            CreateAnalogOutputTask("coil0current");
            CreateAnalogOutputTask("coil1current");

            CreateAnalogInputTask("laserLockErrorSignal", -10, 10);
            CreateAnalogInputTask("chamber1Pressure");
            CreateAnalogInputTask("chamber2Pressure");

            // make the control controlWindow
            controlWindow = new ControlWindow();
            controlWindow.controller = this;

            HCState = SHCUIControlState.OFF;

             Application.Run(controlWindow);
        }
예제 #12
0
 public void SetValue(string channel, bool value)
 {
     HCState = SHCUIControlState.LOCAL;
     stateRecord.digitals[channel] = value;
     SetDigitalLine(channel, value);
     setValuesDisplayedOnUI(stateRecord);
     HCState = SHCUIControlState.OFF;
 }
예제 #13
0
 public void SetValue(string channel, double value, bool useCalibration)
 {
     stateRecord.analogs[channel] = value;
     HCState = SHCUIControlState.LOCAL;
     SetAnalogOutput(channel, value, useCalibration);
     setValuesDisplayedOnUI(stateRecord);
     HCState = SHCUIControlState.OFF;
 }
예제 #14
0
 /// <summary>
 /// These SetValue functions are for giving commands to the hc from another program, while keeping the hc in control of hardware.
 /// Use this if you want the HC to keep control, but you want to control the HC from some other program
 /// </summary>
 public void SetValue(string channel, double value)
 {
     HCState = SHCUIControlState.LOCAL;
     stateRecord.analogs[channel] = value;
     SetAnalogOutput(channel, value, false);
     setValuesDisplayedOnUI(stateRecord);
     HCState = SHCUIControlState.OFF;
 }