예제 #1
0
/*----------------------------------------------------------------------------------------------------------------------*/
void ReadS(GtkWidget *W,gpointer Unused)
{
gchar ErrMessg[200];

if (strlen(FileX->Path)+strlen(FileX->TargetFile)+1>MAX_FNAME_LENGTH) 
   { Attention(0,"ERROR: MAX_FNAME_LENGTH exceeded"); return; }
sprintf(Setup.FName,"%s/%s",FileX->Path,FileX->TargetFile);
strcpy(SetupDir,FileX->Path); SavePrefs();                                                                    //Store path
g_free(FileX);
if (Read(ErrMessg,0))       //Kept all the real work in this function which can be called from a thread outside gtk_main()
   { Attention(0,ErrMessg); return; } 
}
예제 #2
0
/*----------------------------------------------------------------------------------------------------------------------*/
void SaveAsS(GtkWidget *W,gpointer Unused)
{
GtkWidget *Label,*But,*Win;
char Str[MAX_FNAME_LENGTH+20];

if (strlen(FileX->Path)+strlen(FileX->TargetFile)+1>MAX_FNAME_LENGTH) 
   { Attention(0,"ERROR: MAX_FNAME_LENGTH exceeded"); return; }
sprintf(Setup.FName,"%s/%s",FileX->Path,FileX->TargetFile);
strcpy(SetupDir,FileX->Path); SavePrefs();                                                                   //Store path
g_free(FileX);

if (access(Setup.FName,0)==0) 
   {
   Win=gtk_dialog_new(); gtk_grab_add(Win);
   gtk_signal_connect_object(GTK_OBJECT(Win),"destroy",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
   gtk_window_set_title(GTK_WINDOW(Win),"Overwrite?"); gtk_container_border_width(GTK_CONTAINER(Win),5);
   sprintf(Str,"Overwrite %s?",Setup.FName);
   Label=gtk_label_new(Str); gtk_misc_set_padding(GTK_MISC(Label),10,10);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->vbox),Label,TRUE,TRUE,0);
   But=gtk_button_new_with_label("Yes");
   gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(YesOverwrite),Win);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,TRUE,0);
   But=gtk_button_new_with_label("No");
   gtk_signal_connect_object(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(Win));
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(Win)->action_area),But,TRUE,TRUE,0);
   gtk_widget_show_all(Win);
   }
else Save(0);
}
예제 #3
0
void printHelpInfo(){

	printVersion();
	Usage();
	Attention();

}
예제 #4
0
/*----------------------------------------------------------------------------------------------------------------------*/
void SaveSetup(GtkWidget *W,gpointer Unused)
{
if (ProgramState != Free) { Attention(0,"SaveSetup is not allowed in the current Program State"); return; }
if (strlen(Setup.FName)==0) 
   {
   FileX=g_new(struct FileSelectType,1);
   FileOpenNew("Save Setup",NULL,300,TOP_SPACE,FALSE,SetupDir,".set",FALSE,&SaveAsS,FALSE);
   }
예제 #5
0
파일: attnmem.C 프로젝트: AmesianX/hostboot
void resolveMcs(uint64_t i_mcs, void * i_data)
{
    ResolveMcsArgs * args = static_cast<ResolveMcsArgs *>(i_data);

    uint64_t mciFirScomData;

    TargetHandle_t mcs = getTargetService().getMcs(args->proc, i_mcs);

    // read the MCI fir to determine what type of attention
    // centaur reporting

    errlHndl_t err = getScom(mcs, MCI::address, mciFirScomData);

    if(err)
    {
        errlCommit(err, ATTN_COMP_ID);
    }
    else
    {
        // pick the highest priority attention

        for(uint64_t type = INVALID_ATTENTION_TYPE;
                type != END_ATTENTION_TYPE;
                ++type)
        {
            uint64_t mask;

            if(!MCI::getCheckbits(type, mask))
            {
                // this object doesn't support
                // this attention type

                continue;
            }

            if(mask & mciFirScomData)
            {
                AttnData d;
                d.targetHndl = getTargetService().getMembuf(mcs);

                if(!d.targetHndl)
                {
                    // this membuf not functional
                    // or nothing is attached to this MCS

                    break;
                }

                d.attnType = static_cast<ATTENTION_VALUE_TYPE>(type);

                args->list->add(Attention(d, args->ops));
                break;
            }
        }
    }
}
예제 #6
0
/*----------------------------------------------------------------------------------------------------------------------*/
void GetFName(GtkWidget *W,gpointer Unused)
{
gchar Str[MAX_FNAME_LENGTH+5];
                                                                                                                             
if (strlen(FileX->Path)+strlen(FileX->TargetFile)+1>MAX_FNAME_LENGTH)
   { Attention(0,"ERROR: MAX_FNAME_LENGTH exceeded"); return; }
sprintf(Ascii2d->InFName,"%s/%s",FileX->Path,FileX->TargetFile);
g_free(FileX);
AbbreviateFileName(Str,Ascii2d->InFName,MAX_FNAME_LENGTH);
gtk_label_set_text(GTK_LABEL(GTK_BIN(Ascii2d->FileBut)->child),Str);
strcpy(rindex(Str,'.'),".txt");
gtk_entry_set_text(GTK_ENTRY(Ascii2d->OutEntry),Str);
Ascii2d->Ready=TRUE;
}
예제 #7
0
/*-----------------------------------------------------------------------------------------------------------------------*/
void Start(GtkWidget *W,gpointer Data)
{
gint i;
GtkWidget *Win,*VBox,*HBox,*Label,*But,*Entry;
static GdkColor Black   = {0,0x0000,0x0000,0x0000};
static GdkColor Magenta = {0,0xFFFF,0x0000,0xFFFF};
static GdkColor Gray   = {0,0x8888,0x8888,0x8888};
static GdkColor Blue  =   {0,0x7777,0x7777,0xFFFF};
GtkStyle *Style1,*Style2,*Style3;
 
if (AcqOn) { Attention(100,"Counting is already started"); return; }

Style1=gtk_style_copy(gtk_widget_get_default_style());                                  //Copy default style to this style
for (i=0;i<5;i++) { Style1->fg[i]=Style1->text[i]=Magenta; Style1->bg[i]=Black; }             //Set colours for all states
Style2=gtk_style_copy(gtk_widget_get_default_style());                             //Copy default style to this style
for (i=0;i<5;i++) { Style2->fg[i]=Style2->text[i]=Black; Style2->bg[i]=Blue; }           //Set colours
Style3=gtk_style_copy(gtk_widget_get_default_style());                                             //Copy default style
for (i=0;i<5;i++) { Style3->fg[i]=Style3->text[i]=Black; Style3->bg[i]=Gray; }                   //Set colours

Win=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_grab_add(Win);                                    //Define a new modal window
gtk_window_set_title(GTK_WINDOW(Win),"Start Counting"); gtk_widget_set_uposition(GTK_WIDGET(Win),300,300);
gtk_widget_set_usize(GTK_WIDGET(Win),245,90); gtk_container_set_border_width(GTK_CONTAINER(Win),10);
VBox=gtk_vbox_new(FALSE,0); gtk_container_add(GTK_CONTAINER(Win),VBox);                       //VBox for the entire window

HBox=gtk_hbox_new(FALSE,10); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,5);
Label=gtk_label_new("Run Name:"); gtk_box_pack_start(GTK_BOX(HBox),Label,FALSE,FALSE,5);
Entry=gtk_entry_new_with_max_length(35); gtk_box_pack_start(GTK_BOX(HBox),Entry,FALSE,FALSE,0);
SetStyleRecursively(Entry,Style1);
strcpy(RunName,"mydata"); gtk_entry_set_text(GTK_ENTRY(Entry),RunName);
gtk_widget_set_usize(GTK_WIDGET(Entry),130,25);
gtk_signal_connect(GTK_OBJECT(Entry),"changed",GTK_SIGNAL_FUNC(RunNameCallBack),NULL);

HBox=gtk_hbox_new(FALSE,10); gtk_box_pack_start(GTK_BOX(VBox),HBox,FALSE,FALSE,5);
But=gtk_button_new_with_label("Start"); SetStyleRecursively(But,Style2);
gtk_widget_set_usize(GTK_WIDGET(But),100,25);
gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(StartCallBack),GTK_OBJECT(Win));
But=gtk_button_new_with_label("Cancel"); SetStyleRecursively(But,Style3);
gtk_widget_set_usize(GTK_WIDGET(But),100,25);
gtk_box_pack_start(GTK_BOX(HBox),But,TRUE,FALSE,5);
gtk_signal_connect(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(CancelCallBack),GTK_OBJECT(Win));
 
gtk_widget_show_all(Win);
gtk_style_unref(Style1); gtk_style_unref(Style2); gtk_style_unref(Style3);
}
예제 #8
0
/*-----------------------------------------------------------------------------------------------------------------------*/
gint DeleteMain(GtkWidget *W,GdkEvent *Event,gpointer Data)
{
if (AcqOn) { Attention(0,"Cant quit now. Counting in progress"); return TRUE; };
return FALSE;
}
예제 #9
0
/*-----------------------------------------------------------------------------------------------------------------------*/
void DestroyMain(GtkWidget *W,gpointer Data)
{
if   (AcqOn) Attention(0,"Cant quit now. Counting in progress");
else gtk_main_quit(); 
}
예제 #10
0
/*-----------------------------------------------------------------------------------------------------------------------*/
void SAttention(gchar *Messg)                                                           //Thread safe version of Attention
{ gdk_threads_enter(); Attention(0,Messg); gdk_threads_leave(); }
예제 #11
0
/*----------------------------------------------------------------------------------------------------------------------*/
void ReadSetup(GtkWidget *W,gpointer Unused)
{
if (ProgramState != Free) { Attention(0,"ReadSetup is not allowed in the current Program State"); return; }
FileX=g_new(struct FileSelectType,1);
FileOpenNew("Read Setup",NULL,300,TOP_SPACE,TRUE,SetupDir,".set",FALSE,&ReadS,FALSE);
}
예제 #12
0
/*---------------------------------------------------------------------------------------------------------------------*/
void DefaultSetup(void)                                                    //Makes a setup based on ACTIONS_local.CHC_PAR
{
gint i,j,GateLim,Bits;
FILE *Fp;
gchar ErrMessg[200];

Setup.ListMode.Compr=3;                                                                        //Exogam format files only
GateLim=65535;                                                                                             //GateHi limit
strcpy(Setup.FName,""); Setup.Modified=FALSE;                                                    //No file name initially
Setup.Oned.WSz=2; Setup.Twod.WSz=1;

Setup.Offline.NFiles=0; Setup.Offline.BufRefresh=100; Setup.Offline.Delay=0;                     //Offline setup defaults
for (i=0;i<MAX_OFFLINE_FILES;++i)
    {
    Setup.Offline.Zero[i]=FALSE; strcpy(Setup.Offline.ListFName[i],""); strcpy(Setup.Offline.SetFName[i],"Current"); 
    Setup.Offline.SaveSpec[i]=FALSE; strcpy(Setup.Offline.SpecFName[i],"None"); Setup.Offline.BufSkip[i]=0; 
    strcpy(Setup.Offline.BufRead[i],"All");
    }
Setup.Offline.Zero[0]=TRUE;

Setup.ReWrite.NFiles=0; Setup.ReWrite.OutFormat='N';                                       //ReWrite files setup defaults
for (i=0;i<MAX_TOTAL_PAR;++i) Setup.ReWrite.Select[i]=FALSE;
for (i=0;i<MAX_REWRITE_FILES;++i)
    { 
    strcpy(Setup.ReWrite.ListFName[i],""); Setup.ReWrite.BufSkip[i]=0; strcpy(Setup.ReWrite.BufRead[i],"All"); 
    strcpy(Setup.ReWrite.OutFName[i],"run_NNNN.dat");
    }

for (i=0;i<MAX_1D;++i) 
    { 
    sprintf(Setup.Oned.Name[i],"Oned_%d",i+1);
    Setup.Oned.Par[i]=i+1; Setup.Oned.NPar[i]=1; Setup.Oned.Chan[i]=1024;
    Setup.Oned.Gate1[i].NGates=0; Setup.Oned.Gate2[i].NGates=0;
    Setup.Oned.Gate1[i].Cond=And; Setup.Oned.Gate2[i].Cond=And;
    for (j=0;j<MAX_GATES_1D;j++)
        {
        Setup.Oned.Gate1[i].Gate1d[j].Para=1; Setup.Oned.Gate1[i].Gate1d[j].Lo=0; 
        Setup.Oned.Gate1[i].Gate1d[j].Hi=GateLim;
        } 
    for (j=0;j<MAX_GATES_2D;j++) strcpy(Setup.Oned.Gate2[i].Gate2d[j],"");
    }
for (i=0;i<MAX_2D;i++) 
    { 
    sprintf(Setup.Twod.Name[i],"Twod_%d",i+1);
    Setup.Twod.XPar[i]=1; Setup.Twod.NXPar[i]=1; Setup.Twod.YPar[i]=2; Setup.Twod.NYPar[i]=1;
    Setup.Twod.XChan[i]=512; Setup.Twod.YChan[i]=512;
    Setup.Twod.Gate1[i].NGates=0; Setup.Twod.Gate2[i].NGates=0;
    Setup.Twod.Gate1[i].Cond=And; Setup.Twod.Gate2[i].Cond=And;
    for (j=0;j<MAX_GATES_1D;j++)
        {
        Setup.Twod.Gate1[i].Gate1d[j].Para=1; Setup.Twod.Gate1[i].Gate1d[j].Lo=0; 
        Setup.Twod.Gate1[i].Gate1d[j].Hi=GateLim;
        } 
    for (j=0;j<MAX_GATES_2D;j++) strcpy(Setup.Twod.Gate2[i].Gate2d[j],"");
    Setup.Twod.CDdet[i].Enabled=FALSE;
    for (j=0;j<8;++j) Setup.Twod.CDdet[i].P[j]=1;
    }
Setup.Pseudo.N=0;                                                                    //Defaults for PseudoParameter Setup
for (i=0;i<MAX_PSEUDO;++i)
    {
    sprintf(Setup.Pseudo.Name[i],"Pseudo_%d",i+1);
    Setup.Pseudo.P1[i]=1; Setup.Pseudo.P2[i]=1; Setup.Pseudo.Size[i]=8192; Setup.Pseudo.Type[i]=Sum;
    Setup.Pseudo.K1[i]=1.0; Setup.Pseudo.K2[i]=1.0; Setup.Pseudo.K3[i]=1.0;
    Setup.Pseudo.O1[i]=0.0; Setup.Pseudo.O2[i]=0.0; Setup.Pseudo.O3[i]=0.0;
    Setup.Pseudo.Power[i]=1.65; Setup.Pseudo.L1[i]=1; Setup.Pseudo.L2[i]=1;
    Setup.Pseudo.ArrayN[i]=4; Setup.Pseudo.ArrayMFactor[i]=1.0;
    for (j=0;j<MAX_ARRAY;++j)
        {
        Setup.Pseudo.ArrayPar[j][i]=1; Setup.Pseudo.ArrayLLD[j][i]=0.0; Setup.Pseudo.ArrayOffset[j][i]=0.0;
        Setup.Pseudo.ArrayULD[j][i]=65535.0;
        Setup.Pseudo.ArraySlope[j][i]=1.0; Setup.Pseudo.ArrayQuad[j][i]=0.0;
        }
    strcpy(PsBGated[i].Name,"");                      //Initialize name of banana gate file for all the pseudo parameters
    }
for (i=0;i<MAX_PAR;++i)
    {
    Setup.Parameter.N[i]=10; Setup.Parameter.A[i]=0; Setup.Parameter.F[i]=0; 
    Setup.Parameter.Chan[i]=8192; Setup.Parameter.LLD[i]=1; Setup.Parameter.ULD[i]=8191;
    sprintf(Setup.Parameter.Name[i],"Para %d",i+1);
    }
    
Setup.Scaler.NSc=0; Setup.Scaler.NSc1=0;
for (i=0;i<MAX_SCALER;++i)
    { 
    sprintf(Setup.Scaler.Name[i],"Scaler%02d",i+1); 
    Setup.Scaler.C[i]=1; Setup.Scaler.N[i]=1; Setup.Scaler.A[i]=i; Setup.Scaler.F[i]=0; 
    }

Setup.PLogSetup.On=TRUE; Setup.PLogSetup.BufCount=1024;                              //Defaults for periodic log settings

Setup.Macro.N=0;                                                                                     //Defaults for Macro
Setup.Macro.RefreshRate=100;
LogOutBox=MacroOutBox=FALSE;
for (i=0;i<MAX_MACRO;++i)
    {
    sprintf(Setup.Macro.Name[i],"Macro%02d",i+1); Setup.Macro.Type[i]=MacroArea;
    Setup.Macro.Display[i]=TRUE; Setup.Macro.SpecNo[i]=1; Setup.Macro.XMin[i]=10; Setup.Macro.XMax[i]=100;
    Setup.Macro.YMin[i]=10; Setup.Macro.YMax[i]=100; Setup.Macro.K1[i]=1.0; Setup.Macro.K2[i]=1.0; 
    Setup.Macro.ScalerNo[i]=1; Setup.Macro.Index1[i]=1; Setup.Macro.Index2[i]=1;
    MacroCurr[i]=MacroPrev[i]=MacroDiff[i]=0.0;
    }

if (!(Fp=fopen("ACTIONS_local.CHC_PAR","r"))) 
   { Attention(0,"File ACTIONS_local.CHC_PAR not found\nPlease run Utilities:Make ACTIONS File\nRestart glamps"); return; }
for (i=0;;++i)
    {
    if (i==MAX_PAR) { Attention(20,"ACTIONS file too big. Increase MAX_PAR in\nlamps.h and constants.h"); break; }
    if (fscanf(Fp,"%s %d %d\n",Setup.Parameter.Name[i],&Setup.Parameter.ExogamID[i],&Bits)==EOF) break; 
    Setup.Parameter.Chan[i]=1<<Bits;
    Setup.Parameter.LLD[i]=1; Setup.Parameter.ULD[i]=Setup.Parameter.Chan[i]-2;            //LLD, ULD used by Hit Pattern
    }
fclose(Fp);
Setup.Parameter.NPar=i; Setup.Oned.N=i+1; Setup.Twod.N=0;
if (Setup.Parameter.NPar>MAX_PAR) Attention(0,"MAX_PAR exceeded... modify lamps.h and recompile");
if (Setup.Oned.N>MAX_1D) Attention(0,"MAX_1D exceeded... modify lamps.h and recompile");
sprintf(Setup.Oned.Name[i],"Hit Pattern");
Setup.Oned.Par[i]=0;
Setup.Oned.Chan[i]=CLAMP((gint)(pow(2.0,ceil(log((gdouble)(i))/log(2.0)))),16,2048);                     //Next power of 2
Read(ErrMessg,1);                                                                           //Read .lamps_set if it exists
CheckSetup(); ZeroOned(-1); ZeroTwod(-1);
}
예제 #13
0
void printHelpInfo(){
	printVersion();			//打印版本号,以及版本更新区别
	Usage();				//配置文件使用打印
	Attention();			//提示配置文件配置,以及生成默认配置文件
}
예제 #14
0
/*----------------------------------------------------------------------------------------------------------------------*/
void MakeAscii2d(GtkWidget *Win,gpointer Data)
{
gchar OutFName[MAX_FNAME_LENGTH+5],Str[150];
const gchar *BitType;
FILE *Fp;
gshort XSize,YSize;
guint16 *Data16;
guint32 *Data32,DMax;
gint X,Y,WSize;
gboolean Error;
GtkWidget *W,*Label,*But;
                                                                                                                             
if (!Ascii2d->Ready) { Attention(0,"Error: No file selected!"); return; }
strcpy(OutFName,gtk_entry_get_text(GTK_ENTRY(Ascii2d->OutEntry)));
BitType=gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(Ascii2d->BitCombo)->entry));
                                                                                                                             
if ( !(Fp=fopen(Ascii2d->InFName,"r"))) 
   { sprintf(Str,"Could not open %s",Ascii2d->InFName); Attention(0,Str); return; }
fread(&XSize,sizeof(gshort),1,Fp); fread(&YSize,sizeof(gshort),1,Fp);
if (BitType[0]=='S') { WSize=1; Data16=g_new(guint16,XSize*YSize); InitMat16(XSize,YSize,Data16); }
else                 { WSize=2; Data32=g_new(guint32,XSize*YSize); InitMat32(XSize,YSize,Data32); }
Readz2d(WSize,XSize,YSize,Fp,Data16,Data32,&Error);
fclose(Fp);
if (Error) { sprintf(Str,"Error reading %s",Ascii2d->InFName); Attention(0,Str); return; }
                                                                                                                             
if ( !(Fp=fopen(OutFName,"w"))) { sprintf(Str,"Could not open %s",OutFName); Attention(0,Str); return; }
fprintf(Fp,"#Ascii file suitable for gnuplot: splot \"%s\"\n",OutFName);
if (WSize==1)
   {
   for (X=0,DMax=0;X<XSize;++X) 
       {
       for (Y=0;Y<YSize;++Y) 
           {
           fprintf(Fp,"%4d %6d %d\n",X,Y,Data16[X+XSize*Y]);
           if ((X>0) && (Y>0)) DMax=MAX(DMax,(guint32)Data16[X+XSize*Y]);
           }
       fprintf(Fp,"\n");
       }
   g_free(Data16);
   }
else
   {
   for (X=0,DMax=0;X<XSize;++X) 
       {
       for (Y=0;Y<YSize;++Y) 
           {
           fprintf(Fp,"%4d %6d %d\n",X,Y,Data32[X+XSize*Y]);
           if ((X>0) && (Y>0)) DMax=MAX(DMax,Data32[X+XSize*Y]);
           }
       fprintf(Fp,"\n");
       }
   g_free(Data32);
   }
fclose(Fp);

W=gtk_dialog_new(); gtk_grab_add(W); gtk_window_set_title(GTK_WINDOW(W),"Finished");
gtk_widget_set_uposition(GTK_WIDGET(W),350,350); //gtk_widget_set_usize(GTK_WIDGET(W),300,100);
gtk_signal_connect_object(GTK_OBJECT(W),"delete_event",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(W));
sprintf(Str,"File ./%s written",OutFName);
Label=gtk_label_new(Str); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(W)->vbox),Label,TRUE,FALSE,5);
sprintf(Str,"For gnuplot: splot [0:%d] [0:%d] [1:%d] \"%s\"",XSize,YSize,DMax,OutFName);
Label=gtk_label_new(Str); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(W)->vbox),Label,TRUE,FALSE,5);
Fp=fopen("work.gnu","w");
fprintf(Fp,"splot [0:%d] [0:%d] [1:%d] \"%s\"",XSize,YSize,DMax,OutFName);
fclose(Fp);
But=gtk_button_new_with_label("Dismiss");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(W)->action_area),But,TRUE,FALSE,0);
gtk_signal_connect_object(GTK_OBJECT(But),"clicked",GTK_SIGNAL_FUNC(gtk_widget_destroy),GTK_OBJECT(W));
gtk_widget_show_all(W);
}
예제 #15
0
/*----------------------------------------------------------------------------------------------------------------------*/
void Sorry(GtkWidget *w,gpointer Unused)
{ Attention(0,"This part of the program is not yet completed"); }