Can create a mac file..
This commit is contained in:
@ -124,13 +124,16 @@ void QmuSRSim::helpAbout()
|
||||
void QmuSRSim::CreateAllInput()
|
||||
{
|
||||
my %All=();
|
||||
my @AllParams= ("L1","L3","TL","BFIELD","RA_T","RA_B","RA_R","RA_L","SR_B","SR_E",
|
||||
"L1_2","L2_2","L3_2","BFIELD_2","RA_T_2","RA_B_2","RA_R_2","RA_L_2");
|
||||
my @AllParams= ("L1","L3","TL","BFIELD","RA_T","RA_B","RA_R","RA_L","SR_B","SR_E","ENERGY",
|
||||
"L1_2","L2_2","L3_2","BFIELD_2","RA_T_2","RA_B_2","RA_R_2","RA_L_2","ENERGY_2");
|
||||
foreach my $Param (@AllParams) {
|
||||
my $Child = child($Param);
|
||||
my $Value = $Child->text;
|
||||
$All{$Param}=$Value;
|
||||
# print "$Param=".$All{$Param}."\n";
|
||||
}
|
||||
# Return Hash with all important values
|
||||
return %All;
|
||||
}
|
||||
|
||||
|
||||
@ -138,5 +141,56 @@ void QmuSRSim::CreateAllInput()
|
||||
void QmuSRSim::StartCalc()
|
||||
{
|
||||
my %All=CreateAllInput();
|
||||
my $Page = Tabs->currentPageIndex;
|
||||
my %ToReplace=();
|
||||
my @SpaceHolder=();
|
||||
my $FName="SRBeamLine.mac";
|
||||
# 0 for spin rotator and 1 for current.
|
||||
if ($Page == 0) {
|
||||
%ToReplace= (
|
||||
"L1"=>"L1VOLTAGE",
|
||||
"L3"=>"L3VOLTAGE",
|
||||
"TL"=>"TLVOLTAGE",
|
||||
"BFIELD"=>"SAM_BFIELD",
|
||||
"RA_T"=>"RA_TVOL",
|
||||
"RA_B"=>"RA_BVOL",
|
||||
"RA_R"=>"RA_RVOL",
|
||||
"RA_L"=>"RA_LVOL",
|
||||
"SR_B"=>"SR_BFIELD",
|
||||
"SR_E"=>"SR_EFIELD",
|
||||
"ENERGY"=>"ENERGY"
|
||||
);
|
||||
# Use the following template
|
||||
$FName="SRBeamLine.mac";
|
||||
} elsif ($Page == 1) {
|
||||
%ToReplace= (
|
||||
"L1_2"=>"L1VOLTAGE",
|
||||
"L2_2"=>"L2VOLTAGE",
|
||||
"L3_2"=>"L3VOLTAGE",
|
||||
"BFIELD_2"=>"SAM_BFIELD",
|
||||
"RA_T_2"=>"RA_TVOL",
|
||||
"RA_B_2"=>"RA_BVOL",
|
||||
"RA_R_2"=>"RA_RVOL",
|
||||
"RA_L_2"=>"RA_LVOL",
|
||||
"ENERGY_2"=>"ENERGY"
|
||||
);
|
||||
# Use the following template
|
||||
$FName="CBeamLine.mac";
|
||||
}
|
||||
|
||||
open(MACF,"$FName");
|
||||
my @lines=<MACF>;
|
||||
close(MACF);
|
||||
|
||||
for my $key (keys %ToReplace) {
|
||||
# Need to check values of replace parameters...
|
||||
map(s/$ToReplace{$key}/$All{$key}/, @lines);
|
||||
print "Replacing \t".$ToReplace{$key}."\t by \t".$All{$key}."\n";
|
||||
}
|
||||
|
||||
open(NEWMACF,">1000.mac");
|
||||
print (NEWMACF "@lines");
|
||||
close(NEWMACF);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user