#include "KnapTaeller.h"

KnapTaeller::KnapTaeller() {
	this->antal_tryk = 0;
	this->sem = RTKCreateSemaphore(ST_COUNTING, 1, "KnapTaeller");
	RTKSignal( this->sem );
}

unsigned int KnapTaeller::aktuelVaerdi() {
	unsigned int tmp;
	RTKWait( this->sem );
	tmp = this->antal_tryk;
	RTKSignal( this->sem );
	return( tmp );
}

void KnapTaeller::nulstil() {
	RTKWait( this->sem );
	this->antal_tryk = 0;
	RTKSignal( this->sem );
}

void KnapTaeller::opdater( unsigned int value ) {
	RTKWait( this->sem );
	this->antal_tryk = value;
	RTKSignal( this->sem );
}