public static void Main() { Instrument = ArgusMC; //init parameters Instrument.GetParameter("Y-Symmetry Set", out LAST_Y_SYMMETRY); GetTuningSettings(); PrepareEnvironment(); //mReportGains(); //list attributes //listattributes(Instrument.GetType(), "instrument"); //setup data recording InitializeDataRecord(); if (USE_UDP) { UDPServeForever(); } else { TCPServeForever(); } }
public static void Main() { Instrument = ArgusMC; //init parameters Instrument.GetParameter("Y-Symmetry Set", out last_y_symmetry); GetTuningSettings(); PrepareEnvironment(); //setup data recording InitializeDataRecord(); if (use_udp) { UDPServeForever(); } else { TCPServeForever(); } }
// declaration of class methods public static void Main() { Instrument = HelixMC; //init parameters Instrument.GetParameter("Y-Symmetry Set", out LAST_Y_SYMMETRY); GetTuningSettings(); PrepareEnvironment(); //setup data recording InitializeDataRecord(); if (USE_UDP) { UDPServeForever(); } else { TCPServeForever(); } }
// declaration of class methods public static void Main() { Instrument = HelixMC; //init parameters Instrument.GetParameter("Y-Symmetry Set", out LAST_Y_SYMMETRY); //GetTuningSettings(); PrepareEnvironment(); //setup data recording InitializeDataRecord(); // don't start UDPServer, this is only for testing /* * if (USE_UDP) * { * UDPServeForever(); * } * else * { * TCPServeForever(); * } */ // ############################################################## // ############################################################## // run tests here string cmd = 'GetData' Logger.Log(LogLevel.UserInfo, "execute command: {0}", cmd); string result = ParseAndExecuteCommand(cmd); Logger.Log(LogLevel.UserInfo, result); MessageBox.Show(string.Format("command: {0}; Result: {1}", cmd, result), "Resulting Data", "OK", "Information"); // ############################################################## }
public static void Main () { // Configure the proper instrument // ================================================================================ //Instrument= ArgusMC; //DETECTOR_NAMES = Config.ARGUS_DETECTOR_NAMES //Instrument= HelixMC; //DETECTOR_NAMES = Config.HELIX_MC_DETECTOR_NAMES // ================================================================================ //Instrument= HelixSFT DETECTOR_NAMES = Config.HELIX_SFT_DETECTOR_NAMES //init parameters Instrument.GetParameter("Y-Symmetry Set", out LAST_Y_SYMMETRY); GetTuningSettings(); PrepareEnvironment(); //mReportGains(); //list attributes //listattributes(Instrument.GetType(), "instrument"); //setup data recording InitializeDataRecord(); if (Config.use_udp) { UDPServeForever(); } else { TCPServeForever(); } }
//==================================================================================================================================== // // Commands are case sensitive and in CamelCase // Commands: // GetTuningSettingsList #return a comma separated string // SetTuningSettings // GetData returns tagged data e.g. H2,aaa,L1,bbb,CDD,ccc // SetIntegrationTime <seconds> ****currently not enabled**** // BlankBeam <true or false> if true set y-symmetry to -50 else return to previous value //===========Cup/SubCup Configurations============================== // GetCupConfigurationList // GetSubCupConfigurationList // GetActiveCupConfiguration // GetActiveSubCupConfiguration // GetSubCupParameters returns list of Deflection voltages and the Ion Counter supply voltage // SetSubCupConfiguration <sub cup name> //===========Ion Counter============================================ // ActivateIonCounter // DeactivateIonCounter //===========Ion Pump Valve========================================= // Open #open the Ion pump to the mass spec // Close #closes the Ion pump to the mass spec // GetValveState #returns True for open false for close //===========Magnet================================================= // GetMagnetDAC // SetMagnetDAC <value> #0-10V //===========Source================================================= // GetHighVoltage or GetHV // SetHighVoltage or SetHV <kV> // GetTrapVoltage // SetTrapVoltage <value> // GetElectronEnergy // SetElectronEnergy <value> // GetYSymmetry // SetYSymmetry <value> // GetZSymmetry // SetZSymmetry <value> // GetZFocus // SetZFocus <value> // GetIonRepeller // SetIonRepeller <value> // GetExtractionLens // SetExtractionLens <value> //==========Detectors=============================================== // GetDeflection <name> // SetDeflection <name>,<value> // GetIonCounterVoltage // SetIonCounterVoltage <value> //================================================================== // Error Responses: // Error: Invalid Command - the command is poorly formated or does not exist. // Error: could not set <hardware> to <value> //==========Generic Device=============================================== // Get <name> - name is any valid device currently listed in the hardware database //==================================================================================================================================== private static string ParseAndExecuteCommand(string cmd) { string result = "Error: Invalid Command"; //Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); string[] args = cmd.Trim().Split(' '); double r; switch (args[0]) { case "GetTuningSettingsList": result = GetTuningSettings(); break; case "SetTuningSettings": if (SetTuningSettings(args[1])) { result = "OK"; } else { result = String.Format("Error: could not set tuning settings {0}", args[1]); } break; case "GetData": result = scan_data; break; case "SetIntegrationTime": result = SetIntegrationTime(Convert.ToDouble(args[1])); break; case "BlankBeam": if (!use_beam_blank) { result = "OK"; break; } double yval = last_y_symmetry; bool blankbeam = false; if (args[1] == "true") { if (!isblanked) { //remember the non blanking Y-Symmetry value Instrument.GetParameter("Y-Symmetry Set", out last_y_symmetry); yval = -50; isblanked = true; blankbeam = true; } } else { if (isblanked) { isblanked = false; blankbeam = true; result = SetParameter("Y-Symmetry Set", yval); } } result = "OK"; if (blankbeam) { result = SetParameter("Y-Symmetry Set", yval); } break; //============================================================================================ // Cup / SubCup Configurations //============================================================================================ case "GetCupConfigurationList": List <string> cup_names = GetCupConfigurations(); result = string.Join("\r", cup_names.ToArray()); break; case "GetSubCupConfigurationList": string config_name = args[1]; List <string> sub_names = GetSubCupConfigurations(config_name); result = string.Join("\r", sub_names.ToArray()); break; case "GetActiveCupConfiguration": result = Instrument.CupConfigurationDataList.GetActiveCupConfiguration().Name; break; case "GetActiveSubCupConfiguration": result = Instrument.CupConfigurationDataList.GetActiveSubCupConfiguration().Name; break; case "GetSubCupParameters": result = GetSubCupParameters(); break; case "SetSubCupConfiguration": Logger.Log(LogLevel.Debug, String.Format("Set SupCup {0}", cmd)); if (ActivateCupConfiguration("Argon", cmd.Remove(0, 23))) { result = "OK"; } else { result = String.Format("Error: could not set sub cup to {0}", args[1]); } break; //============================================================================================ // Ion Counter //============================================================================================ case "ActivateIonCounter": result = "OK"; SetIonCounterState(true); break; case "DeactivateIonCounter": result = "OK"; SetIonCounterState(false); break; //============================================================================================ // Ion Pump Valve //============================================================================================ case "Open": Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); //hardcode name for now result = SetParameter("Valve Ion Pump Set", OPEN); break; case "Close": Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); result = SetParameter("Valve Ion Pump Set", CLOSE); break; case "GetValveState": Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); result = GetValveState("Valve Ion Pump Set"); Logger.Log(LogLevel.Debug, String.Format("Valve state {0}", result)); break; //============================================================================================ // Magnet //============================================================================================ case "GetMagnetDAC": if (Instrument.GetParameter("Field Set", out r)) { result = r.ToString(); } break; case "SetMagnetDAC": if (use_magnet_step) { result = SetMagnetDAC(Convert.ToDouble(args[1])); } else { result = SetParameter("Field Set", Convert.ToDouble(args[1])); } break; //============================================================================================ // Source Parameters //============================================================================================ case "GetHighVoltage": if (Instrument.GetParameter("Acceleration Reference Set", out r)) { result = (r * 1000).ToString(); } break; case "SetHighVoltage": result = SetParameter("Acceleration Reference Set", Convert.ToDouble(args[1]) / 1000.0); break; case "GetHV": if (Instrument.GetParameter("Acceleration Reference Set", out r)) { result = (r).ToString(); } break; case "SetHV": result = SetParameter("Acceleration Reference Set", Convert.ToDouble(args[1]) / 1000.0); break; case "GetTrapVoltage": //double r; if (Instrument.GetParameter("Trap Voltage Readback", out r)) { result = r.ToString(); } break; case "SetTrapVoltage": result = SetParameter("Trap Voltage Set", Convert.ToDouble(args[1])); break; case "GetElectronEnergy": //double r; if (Instrument.GetParameter("Electron Energy Readback", out r)) { result = r.ToString(); } break; case "SetElectronEnergy": result = SetParameter("Electron Energy Set", Convert.ToDouble(args[1])); break; case "GetIonRepeller": //double r; if (Instrument.GetParameter("Ion Repeller Set", out r)) { result = r.ToString(); } break; case "SetIonRepeller": result = SetParameter("Ion Repeller Set", Convert.ToDouble(args[1])); break; case "GetYSymmetry": //double r; if (Instrument.GetParameter("Y-Symmetry Set", out r)) { result = r.ToString(); } break; case "SetYSymmetry": last_y_symmetry = Convert.ToDouble(args[1]); result = SetParameter("Y-Symmetry Set", Convert.ToDouble(args[1])); break; case "GetZSymmetry": //double r; if (Instrument.GetParameter("Z-Symmetry Set", out r)) { result = r.ToString(); } break; case "SetZSymmetry": result = SetParameter("Z-Symmetry Set", Convert.ToDouble(args[1])); break; case "GetZFocus": //double r; if (Instrument.GetParameter("Z-Focus Set", out r)) { result = r.ToString(); } break; case "SetZFocus": result = SetParameter("Z-Focus Set", Convert.ToDouble(args[1])); break; case "GetExtractionLens": //double r; if (Instrument.GetParameter("Extraction Lens Set", out r)) { result = r.ToString(); } break; case "SetExtractionLens": result = SetParameter("Extraction Lens Set", Convert.ToDouble(args[1])); break; //============================================================================================ // Detectors //============================================================================================ case "GetDeflection": //double r; if (Instrument.GetParameter(String.Format("Deflection {0} Set", args[1]), out r)) { result = r.ToString(); } break; case "SetDeflection": string[] pargs = args[1].Split(','); result = SetParameter(String.Format("Deflection {0} Set", pargs[0]), Convert.ToDouble(pargs[1])); break; case "GetIonCounterVoltage": //double r; if (Instrument.GetParameter("CDD Supply Set", out r)) { result = r.ToString(); } break; case "SetIonCounterVoltage": result = SetParameter("CDD Supply Set", Convert.ToDouble(args[1])); break; //============================================================================================ // Generic //============================================================================================ case "Get": if (Instrument.GetParameter(args[1], out r)) { result = r.ToString(); } break; } return(result); }
//==================================================================================================================================== // // Commands are case sensitive and in CamelCase // do not include the "<" or ">" in the commands. // e.g SetTrapVoltage 120 not SetTrapVoltage <120> // Commands: // GetTuningSettingsList #return a comma separated string // SetTuningSettings // GetData returns tagged data e.g. H2,aaa,L1,bbb,CDD,ccc // SetIntegrationTime <seconds> // GetIntegrationTime <seconds> // BlankBeam <true or false> if true set y-symmetry to -50 else return to previous value //===========Cup/SubCup Configurations============================== // GetCupConfigurationList // GetSubCupConfigurationList <cup name> // GetActiveCupConfiguration // GetActiveSubCupConfiguration // GetSubCupParameters returns list of Deflection voltages and the Ion Counter supply voltage // SetSubCupConfiguration <sub cup name> // SetCupConfiguration <cup name> <sub cup name> //===========Ion Counter============================================ // ActivateIonCounter // DeactivateIonCounter //===========Ion Pump Valve========================================= // Open #open the Ion pump to the mass spec // Close #closes the Ion pump to the mass spec // GetValveState #returns True for open false for close //===========Magnet================================================= // GetMagnetDAC // SetMagnetDAC <value> #0-10V // GetMagnetMoving // SetMass <value> //===========Source================================================= // GetHighVoltage or GetHV // SetHighVoltage or SetHV <kV> // GetTrapVoltage // SetTrapVoltage <value> // GetElectronEnergy // SetElectronEnergy <value> // GetYSymmetry // SetYSymmetry <value> // GetZSymmetry // SetZSymmetry <value> // GetZFocus // SetZFocus <value> // GetIonRepeller // SetIonRepeller <value> // GetExtractionLens // SetExtractionLens <value> //==========Detectors=============================================== // ProtectDetector <name>,<On/Off> // GetDeflection <name> // SetDeflection <name>,<value> // GetIonCounterVoltage // SetIonCounterVoltage <value> //================================================================== // Error Responses: // Error: Invalid Command - the command is poorly formated or does not exist. // Error: could not set <hardware> to <value> //==========Generic Device=============================================== // GetParameter <name> - name is any valid device currently listed in the hardware database // SetParameter <name>,<value> - name is any valid device currently listed in the hardware database //==================================================================================================================================== //------------------------------------------------------------------------------------------------------------------------------------------------------------- // <summary> // Parse the command, select the appropriate methode/function that executes the command. // command and list of arguments is separated by ' ' // parameters that are typically separated by ',' // </summary> // <param name="cmd">The command string: command parameter(s)</param> // <returns>None</returns> //------------------------------------------------------------------------------------------------------------------------------------------------------------- private static string ParseAndExecuteCommand(string cmd) { string result = "Error: Invalid Command"; Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); // command and list of arguments is separated by ' ' // args[0] is the command and args[1] is the sring of parameters that are typically separated by ',' string[] args = cmd.Trim().Split(' '); string[] pargs; string jargs; double r; // use the command stored in args[0] to select the appropriate function switch (args[0]) { case "GetTuningSettingsList": result = GetTuningSettings(); break; case "SetTuningSettings": if (SetTuningSettings(args[1])) { result = "OK"; } else { result = String.Format("Error: could not set tuning settings {0}", args[1]); } break; case "GetData": result = SCAN_DATA; break; case "SetIntegrationTime": result = SetIntegrationTime(Convert.ToDouble(args[1])); break; case "GetIntegrationTime": result = GetIntegrationTime(); break; case "BlankBeam": if (!USE_BEAM_BLANK) { result = "OK"; break; } double yval = LAST_Y_SYMMETRY; bool blankbeam = false; if (args[1].ToLower() == "true") { if (!IsBLANKED) { //remember the non blanking Y-Symmetry value Instrument.GetParameter("Y-Symmetry Set", out LAST_Y_SYMMETRY); yval = -50; IsBLANKED = true; blankbeam = true; } } else { if (IsBLANKED) { IsBLANKED = false; blankbeam = true; result = SetParameter("Y-Symmetry Set", yval); } } result = "OK"; if (blankbeam) { result = SetParameter("Y-Symmetry Set", yval); } break; //============================================================================================ // Cup / SubCup Configurations //============================================================================================ case "GetCupConfigurationList": List <string> cup_names = GetCupConfigurations(); result = string.Join("\r", cup_names.ToArray()); break; case "GetSubCupConfigurationList": string config_name = args[1]; List <string> sub_names = GetSubCupConfigurations(config_name); result = string.Join("\r", sub_names.ToArray()); break; case "GetActiveCupConfiguration": result = Instrument.CupConfigurationDataList.GetActiveCupConfiguration().Name; break; case "GetActiveSubCupConfiguration": result = Instrument.CupConfigurationDataList.GetActiveSubCupConfiguration().Name; break; case "GetSubCupParameters": result = GetSubCupParameters(); break; case "SetSubCupConfiguration": // this only sets the subcupconfiguration of the Argon cup configuration Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); if (ActivateCupConfiguration("Argon", cmd.Remove(0, 23))) { result = "OK"; } else { result = String.Format("Error: could not set sub cup to {0}", args[1]); } break; case "SetCupConfiguration": // this sets the cup configuration and its subcup configuration Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); if (ActivateCupConfiguration(args[1], args[2])) { result = "OK"; } else { result = String.Format("Error: could not set cup to {0} and sub cup to {1}", args[1], args[2]); } break; //============================================================================================ // Ion Counter //============================================================================================ case "ActivateIonCounter": result = "OK"; SetIonCounterState(true); break; case "DeactivateIonCounter": result = "OK"; SetIonCounterState(false); break; //============================================================================================ // Ion Pump Valve //============================================================================================ case "Open": Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); //hardcode name for now result = SetParameter("Valve Ion Pump Set", OPEN); break; case "Close": Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); result = SetParameter("Valve Ion Pump Set", CLOSE); break; case "GetValveState": Logger.Log(LogLevel.Debug, String.Format("Executing {0}", cmd)); result = GetValveState("Valve Ion Pump Set"); Logger.Log(LogLevel.Debug, String.Format("Valve state {0}", result)); break; //============================================================================================ // Magnet //============================================================================================ case "GetMagnetDAC": if (Instrument.GetParameter("Field Set", out r)) { result = r.ToString(); } break; case "SetMagnetDAC": result = SetMagnetDAC(Convert.ToDouble(args[1])); break; case "GetMagnetMoving": result = GetMagnetMoving(); break; case "SetMass": result = "Ok"; RunMonitorScan(Convert.ToDouble(args[1])); break; //============================================================================================ // Source Parameters //============================================================================================ case "GetHighVoltage": if (Instrument.GetParameter("Acceleration Reference Set", out r)) { result = (r * 1000).ToString(); } break; case "SetHighVoltage": result = SetParameter("Acceleration Reference Set", Convert.ToDouble(args[1]) / 1000.0); break; case "GetHV": if (Instrument.GetParameter("Acceleration Reference Set", out r)) { result = (r).ToString(); } break; case "SetHV": result = SetParameter("Acceleration Reference Set", Convert.ToDouble(args[1]) / 1000.0); break; case "GetTrapVoltage": if (Instrument.GetParameter("Trap Voltage Readback", out r)) { result = r.ToString(); } break; case "SetTrapVoltage": result = SetParameter("Trap Voltage Set", Convert.ToDouble(args[1])); break; case "GetElectronEnergy": if (Instrument.GetParameter("Electron Energy Readback", out r)) { result = r.ToString(); } break; case "SetElectronEnergy": result = SetParameter("Electron Energy Set", Convert.ToDouble(args[1])); break; case "GetIonRepeller": if (Instrument.GetParameter("Ion Repeller Set", out r)) { result = r.ToString(); } break; case "SetIonRepeller": result = SetParameter("Ion Repeller Set", Convert.ToDouble(args[1])); break; case "GetYSymmetry": if (Instrument.GetParameter("Y-Symmetry Set", out r)) { result = r.ToString(); } break; case "SetYSymmetry": LAST_Y_SYMMETRY = Convert.ToDouble(args[1]); result = SetParameter("Y-Symmetry Set", Convert.ToDouble(args[1])); break; case "GetZSymmetry": if (Instrument.GetParameter("Z-Symmetry Set", out r)) { result = r.ToString(); } break; case "SetZSymmetry": result = SetParameter("Z-Symmetry Set", Convert.ToDouble(args[1])); break; case "GetZFocus": if (Instrument.GetParameter("Z-Focus Set", out r)) { result = r.ToString(); } break; case "SetZFocus": result = SetParameter("Z-Focus Set", Convert.ToDouble(args[1])); break; case "GetExtractionLens": if (Instrument.GetParameter("Extraction Lens Set", out r)) { result = r.ToString(); } break; case "SetExtractionLens": result = SetParameter("Extraction Lens Set", Convert.ToDouble(args[1])); break; //============================================================================================ // Detectors //============================================================================================ case "ProtectDetector": pargs = args[1].Split(','); ProtectDetector(pargs[0], pargs[1]); break; case "GetDeflection": //jargs=String.Join(" ", args.Slice(1,-1)); if (Instrument.GetParameter(String.Format("Deflection {0} Set", args[0]), out r)) { result = r.ToString(); //result="OK"; } break; case "SetDeflection": //jargs=String.Join(" ", args.Slice(1,-1)); //pargs=jargs.Split(','); pargs = args[1].Split(','); result = SetParameter(String.Format("Deflection {0} Set", pargs[0]), Convert.ToDouble(pargs[1])); break; case "GetIonCounterVoltage": //if(Instrument.GetParameter("CDD Supply Set",out r)) if (Instrument.GetParameter("CDD Supply Set", out r)) { result = r.ToString(); } break; case "SetIonCounterVoltage": pargs = args[1].Split(','); //result=SetParameter("CDD Supply Set", Convert.ToDouble(args[1])); result = SetParameter(String.Format("{0} Supply Set", pargs[0]), Convert.ToDouble(pargs[1])); break; //============================================================================================ // Generic //============================================================================================ case "GetParameter": if (Instrument.GetParameter(args[1], out r)) { result = r.ToString(); } break; case "SetParameter": pargs = args[1].Split(','); result = SetParameter(pargs[0], Convert.ToDouble(pargs[1])); break; } return(result); }
public static void Main() { Instrument= ArgusMC; //init parameters Instrument.GetParameter("Y-Symmetry Set", out LAST_Y_SYMMETRY); GetTuningSettings(); PrepareEnvironment(); //mReportGains(); //list attributes //listattributes(Instrument.GetType(), "instrument"); //setup data recording InitializeDataRecord(); if (USE_UDP) { UDPServeForever(); } else { TCPServeForever(); } }