00001
00002
00003
00004
00005
00006
00007
00008 #include "MyFieldSvcMessenger.hh"
00009
00010 #include "MyFieldSvc.hh"
00011 #include "G4UIdirectory.hh"
00012 #include "G4UIcmdWithAString.hh"
00013 #include "G4UIcmdWithADoubleAndUnit.hh"
00014 #include "G4UIcmdWithADouble.hh"
00015 #include "G4UIcmdWithoutParameter.hh"
00016
00017 MyFieldSvcMessenger::MyFieldSvcMessenger(MyFieldSvc* magFieldSvc)
00018 :fMyFieldSvc(magFieldSvc)
00019 {
00020 g4simDir = new G4UIdirectory("/g4sim/");
00021 g4simDir->SetGuidance("UI commands of this example");
00022
00023 magDir = new G4UIdirectory("/g4sim/mag/");
00024 magDir->SetGuidance("magnet field control");
00025
00026 ReadCardCmd = new G4UIcmdWithAString("/g4sim/mag/ReadCard",this);
00027 ReadCardCmd->SetGuidance("Read MagField settings from assigned file.");
00028 ReadCardCmd->SetParameterName("filename",false);
00029 ReadCardCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00030
00031 SetFieldCmd = new G4UIcmdWithoutParameter("/g4sim/mag/update",this);
00032 SetFieldCmd->SetGuidance("SetField.");
00033 SetFieldCmd->SetGuidance("This command MUST be applied before \"beamOn\" and cannot be used when you chose fieldMap mode!!!");
00034 SetFieldCmd->SetGuidance("if you changed MagField value(s).");
00035 SetFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00036
00037 SetMagIntensityCmd = new G4UIcmdWithADoubleAndUnit("/g4sim/mag/setIntensity",this);
00038 SetMagIntensityCmd->SetGuidance("SetMagIntensity.");
00039 SetMagIntensityCmd->SetParameterName("intensity",false);
00040 SetMagIntensityCmd->SetRange("intensity>=0.");
00041 SetMagIntensityCmd->SetUnitCategory("Magnetic flux density");
00042 SetMagIntensityCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00043
00044 SetMagThetaCmd = new G4UIcmdWithADoubleAndUnit("/g4sim/mag/setTheta",this);
00045 SetMagThetaCmd->SetGuidance("SetMagTheta.");
00046 SetMagThetaCmd->SetParameterName("Theta",false);
00047 SetMagThetaCmd->SetUnitCategory("Angle");
00048 SetMagThetaCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00049
00050 SetMagPhiCmd = new G4UIcmdWithADoubleAndUnit("/g4sim/mag/setPhi",this);
00051 SetMagPhiCmd->SetGuidance("SetMagPhi.");
00052 SetMagPhiCmd->SetParameterName("Phi",false);
00053 SetMagPhiCmd->SetUnitCategory("Angle");
00054 SetMagPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00055 }
00056
00057 MyFieldSvcMessenger::~MyFieldSvcMessenger()
00058 {
00059 delete g4simDir;
00060 delete magDir;
00061 delete SetFieldCmd;
00062 delete ReadCardCmd;
00063 delete SetMagIntensityCmd;
00064 delete SetMagThetaCmd;
00065 delete SetMagPhiCmd;
00066 }
00067
00068 void MyFieldSvcMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
00069 {
00070 if( command == SetFieldCmd ) { fMyFieldSvc->SetField(); }
00071 if( command == ReadCardCmd ) { fMyFieldSvc->ReadCard(newValue); }
00072 if( command == SetMagIntensityCmd ) { fMyFieldSvc->SetMagIntensity(SetMagIntensityCmd->GetNewDoubleValue(newValue)); }
00073 if( command == SetMagThetaCmd ) { fMyFieldSvc->SetMagTheta(SetMagThetaCmd->GetNewDoubleValue(newValue)); }
00074 if( command == SetMagPhiCmd ) { fMyFieldSvc->SetMagPhi(SetMagPhiCmd->GetNewDoubleValue(newValue)); }
00075 }