October 2011 Archives

2011-10-28 23:27:38

CODA crash video


Posted by Jeong Han Lee | Permanent link

2011-10-17 02:21:01

Qweak RunControl GUI concept


Posted by Jeong Han Lee | Permanent link

2011-10-10 16:01:48

Write a XML file by using Perl


    $AutoRunKeywordsComments_Log = "qweak_daq_conf.xml"; 
    my @automode_xml_tags = qw (QWEAKDAQ STATUS STARTKEYWORDS ENDKEYWORDS COMMENTS);
    use XML::Writer;
    my $output;
    open($output, '>', $AutoRunKeywordsComments_Log) or die "Unable to open output file: $!";

    my $writer = new XML::Writer(OUTPUT => $output);
    $writer->xmlDecl();
    $writer->startTag($automode_xml_tags[0]);
    $writer->characters("\n");
    $writer->startTag($automode_xml_tags[1]);
    $writer->characters("auto");
    $writer->endTag($automode_xml_tags[1]);
    $writer->characters("\n");
    $writer->startTag($automode_xml_tags[2]);
    $writer->characters("Automode 1");
    $writer->endTag($automode_xml_tags[2]);
    $writer->characters("\n");
    $writer->startTag($automode_xml_tags[3]);
    $writer->characters("Automode 2");
    $writer->endTag($automode_xml_tags[3]);
    $writer->characters("\n");
    $writer->startTag($automode_xml_tags[4]);
    $writer->characters("This is the automode run log");
    $writer->endTag($automode_xml_tags[4]);
    $writer->characters("\n");
    $writer->endTag($automode_xml_tags[0]);
    $writer->end();
    close $output;
So the output is


auto
Automode 1 
Automode 2
This is the automode run log


Read a XML file by using Perl

    use XML::Simple;
    my $ref = XMLin($AutoRunKeywordsComments_Log);
    $AutoHClog_Status = $ref->{"$automode_xml_tags[1]"};
    $AutoHClog_StartKeywords = $ref->{"$automode_xml_tags[2]"};
    $AutoHClog_EndKeywords = $ref->{"$automode_xml_tags[3]"};
    $AutoHClog_Comments = $ref->{"$automode_xml_tags[4]"};

Read a XML file by using Bash

rdom () { local IFS=\> ; read -d \< E C ;}

automode_xml=qweak_daq_conf.xml

while rdom; do
    if [[ $E = STATUS ]]; then
	automode_status=$C
    elif [[ $E = STARTKEYWORDS ]]; then
	automode_start_keywords=$C
    elif [[ $E = ENDKEYWORDS ]]; then
	automode_end_keywords=$C
    elif [[ $E = COMMENTS ]]; then
	automode_comments=$C
    fi

done < $automode_xml

echo "---- Automode DAQ Status Settings"
echo "Auto Qweak DAQ status : $automode_status"
echo "Start Keywords        : $automode_start_keywords"
echo "End   Keywords        : $automode_end_keywords"
echo "Comments              : $automode_comments"
The rdom function is from a refererence

Read a XML file by using Tcl

Need the tDOM package.

	 
load /lib/tdom0.8.3/libtdom0.8.3.so

proc read_autolog_xml {} {

    global automode_status
    global automode_start_keywords
    global automode_end_keywords
    global automode_comments
    
    set autolog_xml qweak_daq_conf.xml

    set xmlfile [open $autolog_xml]
    set XML [read $xmlfile]
    close $xmlfile
    set doc  [dom parse $XML]
    set root [$doc documentElement]
    set automode_status_node         [$root selectNodes /QWEAKDAQ/STATUS/text()]
    set automode_start_keywords_node [$root selectNodes /QWEAKDAQ/STARTKEYWORDS/text()]
    set automode_end_keywords_node   [$root selectNodes /QWEAKDAQ/ENDKEYWORDS/text()]
    set automode_comments_node       [$root selectNodes /QWEAKDAQ/COMMENTS/text()]
    
    set automode_status         [$automode_status_node data]
    set automode_start_keywords [$automode_start_keywords_node data]
    set automode_end_keywords   [$automode_end_keywords_node data]
    set automode_comments       [$automode_comments_node data]
 
    puts "Status         : $automode_status"
    puts "Start Keywords : $automode_start_keywords"
    puts "End   Keywords : $automode_end_keywords"
    puts "      Comments : $automode_comments"
}


Posted by Jeong Han Lee | Permanent link