#include "libraries/wiredbas/node/ArcnetBus.h"

namespace cosi {

namespace library {

namespace wiredbas {

std::string ArcnetBus::ComponentName = "ArcnetBus";
std::string ArcnetBus::ComponentType = "Bus";

ArcnetBus::ArcnetBus(double pBusSpeed,cosi::rules::wiredbas::WiringRule* pWiringRule,cosi::models::wiredbas::WireCost* pWireCost,cosi::models::wiredbas::WireDelay* pWireDelay) {
	mBusSpeed = pBusSpeed ;
	//Instantiation of arcnet models
	mBusCost = new cosi::models::wiredbas::ArcnetBusCost(pWireCost);
	mBusDelay = new cosi::models::wiredbas::ArcnetBusDelay(pBusSpeed,pWireDelay);
	mWiringRule = pWiringRule ;
	mWireCost = pWireCost ;
	mWireDelay = pWireDelay ;
	mArcnetBusRule = new cosi::rules::wiredbas::ArcnetBusRule(pBusSpeed) ;
}

ArcnetBus::~ArcnetBus() {
	delete mBusCost;
	delete mBusDelay;
}

void ArcnetBus::SetWiringRule(cosi::rules::wiredbas::WiringRule* pWiringRule) {
	mWiringRule = pWiringRule ;
}
void ArcnetBus::SetWireCostModel(cosi::models::wiredbas::WireCost* pWireCost) {
	mWireCost = pWireCost ;
	mBusCost->SetWireCost(pWireCost) ;
}
void ArcnetBus::SetWireDelayModel(cosi::models::wiredbas::WireDelay* pWireDelay) {
	mWireDelay = pWireDelay ;
	mBusDelay->SetWireDelayModel(pWireDelay) ;
}

double ArcnetBus::BusAccessLatencyValue(cosi::commstruct::wiredbas::Implementation* pBus){
	return mBusDelay->GetValue(pBus) ;
}
double ArcnetBus::BusAccessLatencyValue(int pNodeId,
		cosi::commstruct::wiredbas::Implementation* pBus){
	return mBusDelay->GetValue(pBus) ;
}
bool ArcnetBus::Satisfies(cosi::commstruct::wiredbas::Implementation* pBus){
	return mArcnetBusRule->Satisfies(pBus) ;
}

double
			ArcnetBus::GetBusBandwidthValue(
					cosi::commstruct::wiredbas::Implementation* pBus){
	return mArcnetBusRule->GetBandwidthValue(pBus) ;
}


double ArcnetBus::GetCost(cosi::commstruct::wiredbas::Implementation* pBus) {
	return mBusCost->GetValue(pBus) ;
}

}
}
}
