Esempio n. 1
0
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)
}
Esempio n. 2
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)
}
Esempio n. 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)
}
Esempio n. 4
0
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)
}
Esempio n. 5
0
func (self *alg1) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("== execute == [%v]\n", ctx.Idx())
	return kernel.StatusCode(0)
}
Esempio n. 6
0
func (self *alg2) Execute(ctx kernel.IEvtCtx) kernel.Error {
	self.MsgDebug("~~ execute ~~ [ctx:%v]\n", ctx.Idx())
	return kernel.StatusCode(0)
}
Esempio n. 7
0
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)
}