Пример #1
0
	void convert(DipData &dipData, VariablePtr DPEValue, const CharString & tagName) const{
		DynVar * vals = (DynVar *)(DPEValue);
		if (!vals){
			throw BadTypeConversionException(BadTypeConversionException::BADTYPE);
		}

		if (vals->isA() != DYNTEXT_VAR){
			throw BadTypeConversionException(BadTypeConversionException::BADTYPE);
		}
		unsigned int size = vals->getArrayLength();
		if (size == 0){
			return;
		}
		const char ** array = new const char*[size];
		for (unsigned int i = 0; i < size; i++){
			Variable * value =  vals->getAt(i);
			array[i] = ((TextVar *)(value))->getValue();
		}
		if (tagName.len() == 0){
			dipData.insert(array, size);
		} else {
			dipData.insert(array, size, tagName); 
		}

		delete []array;
	}
Пример #2
0
	VariablePtr convert(const std::string & tag, DipData & data) const{
		DipLong value;

		if (tag.length() == 0){
			value = data.extractLong();
		} else {
			value = data.extractLong(const_cast<char *>(tag.c_str()));
		}
	
		return new IntegerVar(value);  
	}	
Пример #3
0
	void convert(DipData &dipData, VariablePtr DPEValue, const CharString & tagName) const{
		TextVar * val = (TextVar *)DPEValue;
		if (!val){
			throw BadTypeConversionException(BadTypeConversionException::BADTYPE);
		}
		if (tagName.len() == 0){
			dipData.insert((char *)val->getValue());
		} else {
			dipData.insert((char *)val->getValue(), tagName); 
		}
	}
Пример #4
0
	VariablePtr convert(const std::string & tag, DipData & data) const{
		DipInt value;

		if (tag.length() == 0){
			value = data.extractByte();
		} else {
			value = data.extractByte(const_cast<char *>(tag.c_str()));
		}
	
		return new Bit32Var(value);  
	}
Пример #5
0
	void convert(DipData &dipData, VariablePtr DPEValue, const CharString & tagName) const{
		CharVar * val = (CharVar *)DPEValue;
		if (!val){
			throw BadTypeConversionException(BadTypeConversionException::BADTYPE);
		}

		char stringifiedChar[2]={0,0};
		stringifiedChar[0] = val->getValue();
		if (tagName.len() == 0){
			dipData.insert(stringifiedChar);
		} else {
			dipData.insert(stringifiedChar, tagName); 
		}
	}
Пример #6
0
	VariablePtr convert(const std::string & tag, DipData & data) const{
		const char ** value;

		int noElements;
		if (tag.length() == 0){
			value = data.extractCStringArray(noElements);
		} else {
			value = data.extractCStringArray(noElements, const_cast<char *>(tag.c_str()));
		}
	
		DynVar * array = new DynVar(TEXT_VAR);
		for (int i = 0; i < noElements; i++){
			TextVar element(value[i]);
			array->append(element);
		}

		return array;
	}
Пример #7
0
/*
Now the API manager can be reconfigured at run time. This means that DPE's
can be 
1)added
2)removed
3)changed. 
What we do NOT want to happen is that these opertions occur the when in the handler
as it will mess up the iterators and possibly the CdipDpeBridge::addValueToList operation,
so we lock this instance so that add/removes can not it can not occur whilst the handler 
is iterating though the list.
*/
void CdipSubscription::handleMessage(DipSubscription* subscription, DipData& data){
	//PVSSTRACE(TRACEIN,"CdipSubscription::handleMessage()");
	if (this->mustGetLastPubValue()){
		/**
		* clear any pending update request, since we have just received the data
		* the new mapping needed (see mustGetLastPubValueFlag).
		* this situation may occur (for example) if updating a DPE mapping configuration
		* will cause two (or more) mappings are made to an newly created subscription. The 2nd
		* mapping would cause the mustGetLastPubValueFlag to be set, whilst the creation of
		* the subscription will cause this subscription to automatically receive the last transmitted
		* publication data. If we do'nt clear the flag this subscription will request the data a second
		* time, if we don't have this mechanism subsequent mappings may not recv a value until the
		* subscribed to publication explicitly publishes a new value(s).
		*/
		this->mustGetLastPubValueFlag = false;
	}

	if (data.extractDataQuality() == DIP_QUALITY_UNINITIALIZED){
		PVSSLOG(ErrClass::PRIO_INFO, "Uninitialized DIP data received for :"<<subscription->getTopicName()<<", skipped.");
		return;
	}


	//PVSSLOG(ErrClass::PRIO_INFO, "Data received and being processed.");

	//PVSSINFO("DIP-70 Subscription data received " << (int)data.size() << " data fields from pub " << (const char *)(this->getPubName()) << " with ts " << data.extractDipTime().getAsMillis() << " quality "<< data.extractDataQuality());

	try{
		DpIdValueList *list = new DpIdValueList();
		
		//MD In case the DIP data time is older than datapoints time , 
		// then force current time and send a Warning message with the previous time and the new time.
		DipLong lastTagMappingUpdateTimestamp = 0l;
		DipLong timeInMs = 0l;
		{
			SmutexGuard guard(lock); // lock this instance whilst in this code block
			std::vector<CdipDataMapping *>::const_iterator it = tagMappings.begin();
			lastTagMappingUpdateTimestamp = ((*it)->timeSecondsPVSS)*1000L + (*it)->timeMSecPVSS;

			if (data.extractDipTime().getAsMillis() <= lastTagMappingUpdateTimestamp) {
				//Use current time instead and send warning.
				timeInMs = getCurrentTimeAsDipLong();
				PVSSINFO("Data from: "<<subscription->getTopicName()<<" has an older timestamp than PVSS, changed to current time.");

				addMappedDPEValueInformationToUpdateList(*list, data, timeInMs,data.extractDipTime().getAsMillis(), true, true);
			} else if( data.extractDipTime().getAsMillis() > getCurrentTimeAsDipLong()){
				// DIP-44 Case where the DIP value is in the future, we force it to current time but
				//  raise the User bit to indicate source time discrepancy
				timeInMs = getCurrentTimeAsDipLong();
				addMappedDPEValueInformationToUpdateList(*list, data, timeInMs, 0, true, true);
			} else {
				timeInMs = data.extractDipTime().getAsMillis();
				addMappedDPEValueInformationToUpdateList(*list, data, timeInMs, 0, true, false);
			}

			////
			// The validity check must happen AFTER the DIP data has been parsed
			// because it is only by trying to convert DIP data to DPE that we can
			// determine whether the DPE is invalid or not
			addMappedDPEValidityStatusToUpdateList(*list);
			/////
		}

		sendListOfUpdatesToPVSS(list, timeInMs);
		//PVSSINFO("Handle: List size = " << (int)list->getNumberOfItems ()<<".")
	} catch (std::runtime_error &de){
		PVSSERROR("Exception " << de.what() << 
			" thrown in handler for pub" <<
			(const char *)this->getPubName());
		int numFields;
		const char ** fields = data.getTags(numFields);
		PVSSINFO("Fields in publication are:-");
		for (int i = 0; i < numFields; i++){
			PVSSINFO(i << " " << fields[i]);
		}
	} catch (...){
		PVSSERROR("Exception thrown in handler for pub " <<
			(const char *)this->getPubName());
	}
	//PVSSTRACE(TRACEOUT,"CdipSubscription::handleMessage()");
}
Пример #8
0
	void handleMessage(DipSubscription *sub, DipData &message) {
		
		// Source parameters
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Irradiator/EmergencyStop") EmergencyStop =  message.extractBool("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Irradiator/Moving") Moving = message.extractBool("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Irradiator/Siren") Siren = message.extractBool("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Irradiator/SourceOFF") SourceOFF = message.extractBool("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Irradiator/SourceON") SourceON = message.extractBool("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Irradiator/Veto") Veto = message.extractBool("__DIP_DEFAULT__");

		// Attenuator parameters
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/DownStreamPos/A") AttDA = message.extractInt("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/DownStreamPos/B") AttDB = message.extractInt("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/DownStreamPos/C") AttDC = message.extractInt("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/DownStreamPos/EffectiveAttenuation") AttDEff = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/UpStreamPos/A") AttUA = message.extractInt("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/UpStreamPos/B") AttUB = message.extractInt("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/UpStreamPos/C") AttUC = message.extractInt("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Attenuators/UpStreamPos/EffectiveAttenuation") AttUEff = message.extractFloat("__DIP_DEFAULT__");
		
		// Radmon parameters
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/1/Dose") D1 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/1/Temperature") T1 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/2/Dose") D2 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/2/Temperature") T2 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/3/Dose") D3 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/3/Temperature") T3 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/4/Dose") D4 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/4/Temperature") T4 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/5/Dose") D5 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/5/Temperature") T5 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/6/Dose") D6 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/6/Temperature") T6 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/7/Dose") D7 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/7/Temperature") T7 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/8/Dose") D8 = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Radmon/8/Temperature") T8 = message.extractFloat("__DIP_DEFAULT__");

		// Environmental parameters
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Atmospheric_Pressure") P = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Temp_Inside_Bunker") TIN = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Temp_Outside_Bunker") TOUT = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Humidity_Inside_Bunker") RHIN = message.extractFloat("__DIP_DEFAULT__");
		if((string)sub->getTopicName() == "dip/GIFFppGPN/Humidity_Outside_Bunker") RHOUT = message.extractFloat("__DIP_DEFAULT__");
		
		if((string)sub->getTopicName() == "EnvSensors/203/ZONE5") {		
			P203 = message.extractFloat("P");
			T203 = message.extractFloat("T");
			RH203 = message.extractFloat("RH");
		}

		if((string)sub->getTopicName() == "EnvSensors/202/ZONE1") {		
			P202 = message.extractFloat("P");
			T202 = message.extractFloat("T");
			RH202 = message.extractFloat("RH");
		}

		if((string)sub->getTopicName() == "EnvSensors/201/ZONE2") {		
			P201 = message.extractFloat("P");
			T201 = message.extractFloat("T");
			RH201 = message.extractFloat("RH");
		}

		// Gas parameters
		if((string)sub->getTopicName() == "dip/GIFFppGPN/gas/RPC_MFC_Humidity") RPC_MFC_Humidity = message.extractFloat("H2O");

		if((string)sub->getTopicName() == "dip/GIFFppGPN/gas/IRsensor") {
			iC4H10_BINOS1 = message.extractFloat("iC4H10_BINOS1");
			iC4H10_BINOS2 = message.extractFloat("iC4H10_BINOS2");
		}

		if((string)sub->getTopicName() == "dip/GIFFppGPN/gas/RPC_MFC") {		
			C2H2F4 = message.extractFloat("C2H2F4");
			iC4H10 = message.extractFloat("iC4H10");
			mixture_with_water = message.extractFloat("mixture_with_water");
			mixture_without_water = message.extractFloat("mixture_without_water");
			SF6 = message.extractFloat("SF6");
		}

		if((string)sub->getTopicName() == "GasSensors/106/ZONE5") {		
			P106 = message.extractFloat("P");
			T106 = message.extractFloat("T");
			RH106 = message.extractFloat("RH");
		}

		if((string)sub->getTopicName() == "GasSensors/105/ZONE2") {		
			P105 = message.extractFloat("P");
			T105 = message.extractFloat("T");
			RH105 = message.extractFloat("RH");
		}

		if((string)sub->getTopicName() == "GasSensors/103/ZONE5") {		
			P103 = message.extractFloat("P");
			T103 = message.extractFloat("T");
			RH103 = message.extractFloat("RH");
		}

		if((string)sub->getTopicName() == "GasSensors/102/ZONE2") {		
			P102 = message.extractFloat("P");
			T102 = message.extractFloat("T");
			RH102 = message.extractFloat("RH");
		}

		if((string)sub->getTopicName() == "GasSensors/101/ZONE3") {		
			P101 = message.extractFloat("P");
			T101 = message.extractFloat("T");
			RH101 = message.extractFloat("RH");
		}

	}
Пример #9
0
	/**
	* handle changes to subscribed to publications
	* Simply prints the contents of the received data.
	* @param subscription - the subsciption to the publications thats changed.
	* @param message - object containing publication data
	* */
	void handleMessage(DipSubscription *subscription, DipData &message){

		cout<<"Received data from "<<subscription->getTopicName()<<endl;
		cout<<"value :"<<message.extractDouble("value")<<endl;
		}