1# -*- tcl -*- 2# -- $Id: writer_mecpu.tcl,v 1.2 2007/03/21 23:15:53 andreas_kupries Exp $ --- 3# 4# PAGE plugin - writer - ME cpu ~ Match Engine CPU 5# 6 7# ### ### ### ######### ######### ######### 8## Imported API 9 10# -----------------+-- 11# page_wdata | Access to processed input stream. 12# -----------------+-- 13# page_info | Reporting to the user. 14# page_warning | 15# page_error | 16# -----------------+-- 17# page_log_error | Reporting of internals. 18# page_log_warning | 19# page_log_info | 20# -----------------+-- 21 22# ### ### ### ######### ######### ######### 23## Exported API 24 25# -----------------+-- 26# page_wfeature | Query for special plugin features page might wish to use. 27# page_wtime | Activate collection of timing statistics. 28# page_wgettime | Return the collected timing statistics. 29# page_wlabel | User readable label for the plugin. 30# page_whelp | Doctools help text for plugin. 31# page_woptions | Options understood by plugin. 32# page_wconfigure | Option (re)configuration. 33# page_wrun | Generate output from data per plugin configuration and hardwiring. 34# -----------------+-- 35 36# ### ### ### ######### ######### ######### 37## Requisites 38 39package require page::gen::peg::mecpu 40 41global usec 42global timed 43set timed 0 44 45# ### ### ### ######### ######### ######### 46## Implementation of exported API 47 48proc page_wlabel {} { 49 return {ME cpu Assembler} 50} 51 52proc page_wfeature {key} { 53 return [string eq $key timeable] 54} 55 56proc page_wtime {} { 57 global timed 58 set timed 1 59 return 60} 61 62proc page_wgettime {} { 63 global usec 64 return $usec 65} 66 67proc page_whelp {} { 68 return {} 69} 70 71proc page_woptions {} { 72 return {--package --copyright --template --cmarker} 73} 74 75proc page_wconfigure {option value} { 76 switch -exact -- $option { 77 --package { 78 page::gen::peg::mecpu::package $value 79 } 80 --copyright { 81 page::gen::peg::mecpu::copyright $value 82 } 83 --template { 84 page::gen::peg::mecpu::template $value 85 } 86 --cmarker { 87 page::gen::peg::mecpu::cmarker $value 88 } 89 default { 90 return -code error "Cannot set value of unknown option \"$option\"" 91 } 92 } 93} 94 95proc page_wrun {chan data} { 96 global timed usec 97 page_log_info "writer/me-cpu/run/" 98 99 if {$timed} { 100 set usec [lindex [time { 101 page::gen::peg::mecpu $data $chan 102 }] 0] ; #{} 103 } else { 104 page::gen::peg::mecpu $data $chan 105 } 106 page_log_info "writer/me-cpu/run/ok" 107 return 108} 109 110# ### ### ### ######### ######### ######### 111## Internal helper code. 112 113# ### ### ### ######### ######### ######### 114## Initialization 115 116package provide page::writer::mecpu 0.1.1 117