Esempio n. 1
0
bool SrGetDataLabel(HANDLE hCom, unsigned int iPw, unsigned short shPc,
		unsigned char *szEpc, unsigned int iszLen, unsigned char cBlock,
		unsigned short shStartAddr, unsigned short shDataLenWord,
		unsigned char *szOut, unsigned int *pdwErr) {
	sreadlabel commandstruct;
	bzero(&commandstruct, sizeof(sreadlabel));
	sepc epc;
	bzero(&epc, sizeof(sepc));
	commandstruct.epc = &epc;

	commandstruct.password = iPw;
	commandstruct.epc->pc[0] = shPc >> 8 & 0xff;
	commandstruct.epc->pc[1] = shPc >> 0 & 0xff;
	memcpy(commandstruct.epc->epc, szEpc, iszLen);
	commandstruct.bank = cBlock;
	commandstruct.accesspath = shStartAddr * 2;
	commandstruct.readsize = shDataLenWord * 2;

	slabeldata data;
	bzero(&data, sizeof(slabeldata));

	LabelData(hCom, 0x19, &commandstruct, (void*) &data, pdwErr);
	if (!data.data) {
		*pdwErr = ERR_CODE_GET_LABEL_DATA;
		return false;
	}
	memcpy(szOut, data.data, data.len);
	return true;
}
//------------------------------------------------------------------------------
void UI::AddLabel(const UI::Label& label)
{
    GL::BufferObject* buffer = new GL::BufferObject(
        GL_ARRAY_BUFFER, 
        label.GetLength()*sizeof(float)*3, 
        GL_STATIC_DRAW
    );

    float* data = new float[3*label.GetLength()];

    std::string text = label.GetText();

    int xOffset = 0;
    for (unsigned int i = 0; i < label.GetLength(); i++)
    {   
        data[3*i + 0]  = static_cast<float>(characterInfo_[i].XOff0)/atlas_.Width;
        data[3*i + 1]  = static_cast<float>(characterInfo_[i].XOff0 + characterInfo_[i].Width)/atlas_.Width;
        data[3*i + 2]  = static_cast<float>(xOffset);
        xOffset += characterInfo_[i].Width;
    }

    buffer->SetData(label.GetLength()*sizeof(float)*3, data);

    labels_.push_back(LabelData(&label, buffer));

    delete[] data;
}