示例#1
0
文件: pkg2.go 项目: sbinet/go-gaudi
func (self *alg_adder) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("== execute == [%v]\n", ctx.Idx())

	njets := 1 + ctx.Idx()
	val := self.val + 1
	store := self.EvtStore(ctx)

	if store.Has("njets") {
		njets += store.Get("njets").(int)
	}
	store.Put("njets", njets)

	if store.Has("ptjets") {
		val += store.Get("ptjets").(float64)
	}
	store.Put("ptjets", val)

	cnt := &simple_counter{0}
	if store.Has(self.cnt_key) {
		cnt = store.Get(self.cnt_key).(*simple_counter)
	}
	cnt.Cnt += 1
	store.Put(self.cnt_key, cnt)
	return kernel.StatusCode(0)
}
示例#2
0
func (self *datastoresvc) Store(ctx kernel.IEvtCtx) kernel.IDataStore {
	store := ctx.Store()
	n := self.CompName()
	if _, ok := store[n]; !ok {
		dstore := make(kernel.DataStore)
		//dstore := make(map[string]chan interface{})
		store[n] = dstore
	}

	dstore := store[n].(kernel.DataStore)
	//dstore := store[n].(map[string]chan interface{})
	if dstore != nil {
		return &datastore{dstore}
	}

	return nil
}
示例#3
0
func (self *json_outstream) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("== execute ==\n")
	store := self.EvtStore(ctx)
	if store == nil {
		self.MsgError("could not retrieve evt-store\n")
	}

	hdr_offset := 1

	val := make([]interface{}, len(self.item_names)+hdr_offset)
	val[0] = ctx.Idx()

	for i, k := range self.item_names {
		val[i+hdr_offset] = store.Get(k)
	}

	return self.handle.Write(val)
}
示例#4
0
func (self *evtproc) ExecuteEvent(ictx kernel.IEvtCtx) kernel.Error {
	ctx := ictx.Idx()
	self.MsgDebug("executing event [%v]... (#algs: %v)\n", ctx, len(self.algs))
	for i, alg := range self.algs {
		self.MsgDebug("-- ctx:%03v --> [%s]...\n", ctx, alg.CompName())
		if !alg.Execute(ictx).IsSuccess() {
			self.MsgError("pb executing alg #%v (%s) for ctx:%v\n",
				i, alg.CompName(), ictx.Idx())
			return kernel.StatusCode(1)
		}
	}
	self.MsgDebug("data: %v\n", ictx.Store())
	return kernel.StatusCode(0)
}
示例#5
0
文件: pkg2.go 项目: sbinet/go-gaudi
func (self *alg_dumper) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("== execute == [%v]\n", ctx.Idx())

	store := self.EvtStore(ctx)
	njets := store.Get(self.njets_key).(int)
	ptjets := store.Get(self.ptjets_key).(float64)
	cnt := store.Get(self.cnt_key).(*simple_counter)

	if self.cnt_val == cnt.Cnt {
		self.MsgDebug("[ctx:%03v] njets: %03v ptjets: %8.3v [OK]\n",
			ctx.Idx(), njets, ptjets)
	} else {
		self.MsgError("[ctx:%03v] njets: %03v ptjets: %8.3v (%v|%v) [ERR]\n",
			ctx.Idx(), njets, ptjets, self.cnt_val, cnt.Cnt)
		panic("race condition detected in evt-store")
	}

	// simulate a cpu-burning algorithm
	time.Sleep(3 * 10e6) // 3ms
	return kernel.StatusCode(0)
}
示例#6
0
文件: pkg2.go 项目: sbinet/go-gaudi
func (self *alg1) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("== execute == [%v]\n", ctx.Idx())
	return kernel.StatusCode(0)
}
示例#7
0
文件: pkg1.go 项目: sbinet/go-gaudi
func (self *alg2) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("~~ execute ~~ [ctx:%v]\n", ctx.Idx())
	return kernel.StatusCode(0)
}
示例#8
0
文件: pkg1.go 项目: sbinet/go-gaudi
func (self *alg1) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("== execute == [ctx:%v]\n", ctx.Idx())
	detstore := self.DetStore(ctx)
	self.MsgDebug("det-store: %v\n", detstore)
	return kernel.StatusCode(0)
}