object Accumlator var chan%; var multiplier; var ref_event; var ref_value; var start_event; var end_event; var size%; var values[1]; func setRef(event) self.ref_event := event; NextTime(self.chan%, self.ref_event, self.ref_value); return self.ref_value; end func setChan(chan%) self.chan% := chan%; end func setMultiplier(value) self.multiplier := value; end func setStartEvent(event) self.start_event := event; end func setEndEvent(event) self.end_event := event; end func clear() return ArrConst(self.values, 0); end func resizeBuffer() self.size% := (1/BinSize(self.chan%))*(self.end_event - self.start_event); resize self.values[self.size%]; return self.size%; end func writeToBuffer() self.resizeBuffer(); self.clear(); return ChanData(self.chan%, self.values, self.start_event, self.end_event, self.start_event); end func writeMeanToChan(chan%) var mean := 0; ArrSum(self.values, mean); mean := Round((mean - self.ref_value)*1000*self.multiplier)/(1000*self.multiplier); var mean$ := Str$(mean); return MemSetItem(chan%, 0, self.start_event, 0, mean$); end func writeFFTMaxToChan(chan%) ArrFFT(self.values, 1); end func call(chan%, process$) if self.writeToBuffer() >= 0 then docase case process$ = "mean" then return writeMeanToChan(chan%); case process$ = "FFTMax" then return writeFFTMaxToChan(chan%); endcase else return -1; endif end objend