void JRealComplexObj::writeContent(JOutputStream& os) { JLabelObj::writeContent(os); putDouble(os, "real", cval.r); putDouble(os, "imag", cval.i); putInteger(os, "w", w); putInteger(os, "f", f); }
int dumpNBT_list(NBT_list *input, uint8 *buffer) { int curpos=0; buffer[curpos]=TAG_LIST; curpos++; curpos+=dumpNBT_string(&buffer[curpos],input->name); buffer[curpos]=input->tagId; curpos++; putSint32(&buffer[curpos],input->length); curpos+=4; for(int i=0; i<input->length; i++) { switch(input->tagId) { case TAG_BYTE: buffer[curpos]=*(char *)input->items[i]; curpos++; break; case TAG_SHORT: putSint16(&buffer[curpos], *(int *)input->items[i]); curpos+=2; break; case TAG_INT: putSint32(&buffer[curpos], *(int *)input->items[i]); curpos+=4; break; case TAG_LONG: putSint64(&buffer[curpos], *(long long *)input->items[i]); curpos+=8; break; case TAG_FLOAT: putFloat(&buffer[curpos], *(float *)input->items[i]); curpos+=4; break; case TAG_DOUBLE: putDouble(&buffer[curpos], *(double *)input->items[i]); curpos+=8; break; case TAG_STRING: curpos+=dumpNBT_string(&buffer[curpos],*(std::string *)input->items[i]); break; case TAG_BYTE_ARRAY: curpos+=dumpNBT_byte_array((NBT_byte_array *)input->items[i], &buffer[curpos],true); break; case TAG_COMPOUND: curpos+=dumpNBT_struct((NBT_struct *)input->items[i], &buffer[curpos],true); break; } } return curpos; }
////////////////////////////////////////////////////////////////////////// // double bool BasePersistenceManager::transferDouble(const char *name, double *val) { if (_saving) { putDouble(*val); if (_saveStream->err()) { return STATUS_FAILED; } return STATUS_OK; } else { *val = getDouble(); if (_loadStream->err()) { return STATUS_FAILED; } return STATUS_OK; } }
int dumpNBT_value(NBT_value *input, uint8 *buffer) { int curpos=0; buffer[curpos]=input->type; curpos++; curpos+=dumpNBT_string(&buffer[curpos],input->name); switch(input->type) { case TAG_BYTE: buffer[curpos]=*(char *)input->value; curpos++; break; case TAG_SHORT: putSint16(&buffer[curpos], *(int *)input->value); curpos+=2; break; case TAG_INT: putSint32(&buffer[curpos], *(int *)input->value); curpos+=4; break; case TAG_LONG: putSint64(&buffer[curpos], *(long long *)input->value); curpos+=8; break; case TAG_FLOAT: putFloat(&buffer[curpos], *(float *)input->value); curpos+=4; break; case TAG_DOUBLE: putDouble(&buffer[curpos], *(double *)input->value); curpos+=8; break; case TAG_STRING: curpos+=dumpNBT_string(&buffer[curpos],*(std::string *)input->value); break; } return curpos; }
int Eiger::trigger (int timeout, double exposure) { // Trigger for INTS mode if(!exposure) return put(SSCommand, "trigger", "", 0, NULL, timeout); // Tigger for INTE mode // putDouble should block for the whole exposure duration, but it doesn't // (Eiger's fault) epicsTimeStamp start, end; epicsTimeGetCurrent(&start); if(putDouble(SSCommand, "trigger", exposure, NULL, timeout)) return EXIT_FAILURE; epicsTimeGetCurrent(&end); double diff = epicsTimeDiffInSeconds(&end, &start); if(diff < exposure) epicsThreadSleep(exposure - diff); return EXIT_SUCCESS; }
void JDouble::writeContent(JOutputStream& os) { JObject::writeContent(os); putDouble(os, "value", value); }
void NBT_Value::Write(std::vector<uint8> &buffer) { int storeAt = buffer.size();; switch(m_type) { case TAG_BYTE: buffer.push_back(m_value.byteVal); break; case TAG_SHORT: buffer.resize(storeAt + 2); putSint16(&buffer[storeAt], m_value.shortVal); break; case TAG_INT: buffer.resize(storeAt + 4); putSint32(&buffer[storeAt], m_value.intVal); break; case TAG_LONG: buffer.resize(storeAt + 8); putSint64(&buffer[storeAt], m_value.longVal); break; case TAG_FLOAT: buffer.resize(storeAt + 4); putFloat(&buffer[storeAt], m_value.floatVal); break; case TAG_DOUBLE: buffer.resize(storeAt + 8); putDouble(&buffer[storeAt], m_value.doubleVal); break; case TAG_BYTE_ARRAY: { int arraySize = m_value.byteArrayVal ? m_value.byteArrayVal->size() : 0; buffer.resize(storeAt + 4 + arraySize); putSint32(&buffer[storeAt], arraySize); storeAt += 4; if(arraySize) memcpy(&buffer[storeAt], &(*m_value.byteArrayVal)[0], arraySize); break; } case TAG_STRING: { int stringLen = m_value.stringVal ? m_value.stringVal->size() : 0; buffer.resize(storeAt + 2 + stringLen); putSint16(&buffer[storeAt], (sint16)stringLen); storeAt += 2; if(stringLen>0) memcpy(&buffer[storeAt], m_value.stringVal->c_str(), stringLen); break; } case TAG_LIST: { buffer.resize(storeAt + 5); int listCount = m_value.listVal.data ? m_value.listVal.data->size() : 0; buffer[storeAt] = m_value.listVal.type; storeAt++; putSint32(&buffer[storeAt], listCount); for(int i=0;i<listCount;i++) (*m_value.listVal.data)[i]->Write(buffer); break; } case TAG_COMPOUND: { int compoundCount = m_value.compoundVal ? m_value.compoundVal->size() : 0; if(compoundCount) { std::map<std::string, NBT_Value*>::iterator iter = m_value.compoundVal->begin(), end = m_value.compoundVal->end(); for( ; iter != end; iter++) { const std::string &key = iter->first; int keySize = key.size(); NBT_Value *val = iter->second; int curPos = buffer.size(); buffer.resize(curPos + 3 + keySize); buffer[curPos] = (uint8)val->GetType(); curPos++; putSint16(&buffer[curPos], keySize); curPos += 2; if(keySize) memcpy(&buffer[curPos], key.c_str(), keySize); val->Write(buffer); } } buffer.push_back(TAG_END); break; } case TAG_END: break; //for completeness } }
void JComplex::writeContent(JOutputStream& os) { JObject::writeContent(os); putDouble(os, "real", value.r); putDouble(os, "imag", value.i); }
static void prim() { switch (currTok) { case tEnd: break; case tFunc: calcFunc(); getToken(); break; case tVar: put(MCODE_OP_PUSHVAR); putstr(nameString); getToken(); break; case tConst: put(MCODE_OP_PUSHCONST); putstr(nameString); getToken(); break; case tInt: put(MCODE_OP_PUSHINT); put64(currVar.i()); getToken(); break; case tFloat: put(MCODE_OP_PUSHFLOAT); putDouble(currVar.d()); getToken(); break; case tFARVar: put(FARVar); // nFARVar получаем в getToken() getToken(); break; case tStr: put(MCODE_OP_PUSHSTR); putstr(currVar.s()); getToken(); break; case tMinus: getToken(); prim(); put(MCODE_OP_NEGATE); break; case tBitNot: getToken(); prim(); put(MCODE_OP_BITNOT); break; case tNot: getToken(); prim(); put(MCODE_OP_NOT); break; case tLp: getToken(); expr(); if (currTok != tRp) keyMacroParseError(err_Expected_Token, L")"); getToken(); break; case tRp: //??? break; default: keyMacroParseError(err_Expr_Expected); break; } }
void J1DSliderObj::writeContent(JOutputStream& os) { JBtnObj::writeContent(os); putDouble(os, "fraction", fraction); putInteger(os, "max", max); putInteger(os, "min", min); }
sp<ByteBuffer> ByteBuffer::putDouble(double value) { putDouble(mPosition, value); mPosition += sizeof(value); return this; }
void IF_pi(void) { putDouble(M_PI); }
void JCAddObj::writeContent(JOutputStream& os) { JModuleObj::writeContent(os); putDouble(os, "real", value.r); putDouble(os, "imag", value.i); }