00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "scope.h"
00027 #include "systemclock.h"
00028
00029
00030 using namespace std;
00031
00032 class ScopePin : public Pin {
00033 protected:
00034 Scope *scope;
00035 unsigned int channel;
00036
00037 public:
00038 ScopePin(Scope *s, unsigned int c ):scope(s), channel(c){};
00039 void SetInState(const Pin& p) {
00040 scope->SetInStateForChannel(channel, p);
00041 }
00042 };
00043
00044 Scope::Scope( UserInterface *u, const string & n, unsigned int cnt, const char *baseWindow)
00045 : ui(u), name(n), vecPin(cnt), lastVal(cnt), noOfChannels(cnt)
00046 {
00047 for (unsigned int tt=0; tt< cnt; tt++) {
00048 vecPin[tt]=new ScopePin(this, tt);
00049 lastVal[tt]=0;
00050 }
00051
00052
00053 ostringstream os;
00054 os << "create Scope " << name << " "<<baseWindow <<" " << noOfChannels << endl;
00055 ui->Write(os.str());
00056 }
00057
00058 Scope::~Scope() {}
00059
00060 Pin *Scope::GetPin(unsigned int n) {
00061 return vecPin[n];
00062 }
00063
00064 void Scope::SetInStateForChannel(unsigned int channel, const Pin& p) {
00065 if ( lastVal[channel]!= p.GetAnalog() ) {
00066 ostringstream os;
00067 os << name << " ChangeValue " << SystemClock::Instance().GetCurrentTime() << " " << channel << " " << p.GetAnalog()<<endl;
00068
00069 ui->Write(os.str());
00070
00071 lastVal[channel]=p.GetAnalog();
00072
00073 }
00074 }
00075
00076
00077
00078
00079
00080
00081