Ejemplo n.º 1
0
void TimeSync::ConfigureRequest(APDU& arAPDU)
{
	if(mDelay < 0) {
		arAPDU.Set(FC_DELAY_MEASURE);
		mStart = mpTimeSrc->GetUTC();
	}
	else {
		arAPDU.Set(FC_WRITE);
		ObjectWriteIterator owi = arAPDU.WriteContiguous(Group50Var1::Inst(), 0, 0, QC_1B_CNT);
		Group50Var1::Inst()->mTime.Set(*owi, mpTimeSrc->GetTimeStampUTC() + mDelay);
	}
}
Ejemplo n.º 2
0
void ConfigureUnsol::ConfigureRequest(APDU& arAPDU)
{
	arAPDU.Set(mIsEnable ? FC_ENABLE_UNSOLICITED : FC_DISABLE_UNSOLICITED);
	if(mClassMask & PC_CLASS_1) arAPDU.DoPlaceholderWrite(Group60Var2::Inst());
	if(mClassMask & PC_CLASS_2) arAPDU.DoPlaceholderWrite(Group60Var3::Inst());
	if(mClassMask & PC_CLASS_3) arAPDU.DoPlaceholderWrite(Group60Var4::Inst());
}
Ejemplo n.º 3
0
void ClearRestartIIN::ConfigureRequest(APDU& arAPDU)
{
	arAPDU.Set(FC_WRITE);
	Group80Var1* pObj = Group80Var1::Inst(); // Internal indications object
	ObjectWriteIterator i = arAPDU.WriteContiguous(pObj, 7, 7); // index 7 == device restart
	pObj->Write(*i, 7, 7, false);
}
Ejemplo n.º 4
0
void VtoTransmitTask::ConfigureRequest(APDU& arAPDU)
{
	/*
	 *  Masters never request confirmed data. The response from the
	 *  slave is all that's required for reliable delivery.
	 */
	arAPDU.Set(mUseNonStandardCode ? FC_PROPRIETARY_VTO_TRANSFER : FC_WRITE);

	const size_t MAX_VTO_EVENTS = 7;
	/* Get all of the data objects in the buffer. */
	size_t numObjects = this->mBuffer.Select(PC_ALL_EVENTS, MAX_VTO_EVENTS);

	LOG_BLOCK(LEV_INTERPRET, "VtoTransmitTask Sending: " << numObjects << " of " << this->mBuffer.Size());

	/* If there are no objects to write, skip the remainder. */
	if (numObjects == 0) {
		return;
	}

	/*
	 * Loop through the selected data and add corresponding objects to
	 * the arAPDU instance.
	 */
	VtoDataEventIter vto = this->mBuffer.Begin();

	for (size_t i = 0; i < numObjects; ++i) {
		/* Insert a new object into the APDU message. */
		IndexedWriteIterator itr = arAPDU.WriteIndexed(
		                               Group112Var0::Inst(),
		                               vto->mValue.GetSize(),
		                               vto->mIndex
		                           );

		/*
		 * Check to see if the APDU fragment has enough room for the
		 * data segment.  If the fragment is full, return out of this
		 * function and let the fragment send.
		 */
		if (itr.IsEnd()) {
			return;
		}

		/* Set the object index */
		itr.SetIndex(vto->mIndex);

		/* Write the data to the APDU message */
		Group112Var0::Inst()->Write(
		    *itr,
		    vto->mValue.GetSize(),
		    vto->mValue.mpData
		);

		/* Mark the data segment as being written */
		vto->mWritten = true;

		/* Move to the next data segment in the buffer */
		++vto;
	}
}
void ClassPoll::ConfigureRequest(APDU& arAPDU)
{
	if (mClassMask == PC_INVALID) {
		throw InvalidStateException(LOCATION, "Class mask has not been set");
	}

	arAPDU.Set(FC_READ);
	if (mClassMask & PC_CLASS_0) arAPDU.DoPlaceholderWrite(Group60Var1::Inst());
	if (mClassMask & PC_CLASS_1) arAPDU.DoPlaceholderWrite(Group60Var2::Inst());
	if (mClassMask & PC_CLASS_2) arAPDU.DoPlaceholderWrite(Group60Var3::Inst());
	if (mClassMask & PC_CLASS_3) arAPDU.DoPlaceholderWrite(Group60Var4::Inst());
}
void FreeFormPoll::ConfigureRequest(APDU& arAPDU)
{
	LOG_BLOCK(LEV_DEBUG, "FreeFormPoll::ConfigureRequest");

	if (this->GetClassMask() == PC_INVALID) {
		throw InvalidStateException(LOCATION, "Class mask has not been set");
	}

	arAPDU.Set(FC_READ);
	std::lock_guard<std::mutex> guard{ffInputPoints_mutex_};

	if ((this->GetClassMask() & PC_CLASS_0) && ffInputPoints.size() > 0) {

		for (std::pair<apl::DataTypes, std::vector<uint32_t>> element : ffInputPoints)
		{
			if (element.second.size() <= 0)
				continue; //should not come here
			if (element.first == apl::DataTypes::DT_ANALOG) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group30Var1::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_BINARY) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group1Var2::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_COUNTER) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group20Var1::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_CONTROL_STATUS) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group10Var2::Inst(), index, index, QC_1B_START_STOP );
				}
			}
			if (element.first == apl::DataTypes::DT_SETPOINT_STATUS) {
				for (int ind=0; ind<element.second.size(); ++ind) {
					size_t index = element.second.at(ind);
					ObjectWriteIterator i = arAPDU.WriteContiguous(Group40Var1::Inst(), index, index, QC_1B_START_STOP );
				}
			}

		}
	}
}