void deinit() { if (condition() == false) { std::string msg = getType() == PreCondition ? "FAILURE: Precondition: " : "FAILURE: Postcondition: "; std::string strCondition = context.condition; replaceBoostLambdaVarWithPost(strCondition); formatHeader( msg + strCondition + " in " + context.function ); formatArgs(); print(); fail(); } if (invariant() == false) { std::string msg = getType() == PreCondition ? "FAILURE: Class invariant (on entry): " : "FAILURE: Class invariant (on exit): "; std::vector<std::pair<std::string, std::string> > invariantArgs; this->invariantArgs( invariantArgs ); for (unsigned int i=0; i<invariantArgs.size(); i++) { formatHeader( msg + invariantArgs[i].first + " in " + context.function ); formatArgs( invariantArgs[i].second ); print(); fail(); } } }
char * DmxMsg::printHeader (enum DmxHeaderType htype) { DtMailEnv env; char *status, *indicator; if (isCurrent == B_TRUE) { indicator = ">"; } else { indicator = " "; } if (isNew == B_TRUE) { status = "N"; } else { status = "O"; // how about "unread" ?? } if (hasAttachments == B_TRUE) { indicator = "@"; } // the addlInfo string is any extra info needed by the // viewer, such as a message number char *buffer = new char [1024]; memset (buffer, 0, 1024); switch (htype) { case MSGLIST: sprintf (buffer, "%s%s%s %s", indicator, status, addlInfo, formatHeader (msgHeader, MSGLIST)); break; case MSGHEADER: sprintf (buffer, "%s", formatHeader (msgHeader, MSGHEADER)); break; default: printf ("error in DmxMsg::display\n"); break; } return buffer; }
Report& InvoiceFormatter::formatFullInvoice(InvoiceData& invoice) { output.Clear(); output.Header(String("[A0> ") + String(t_("Page")) + String(" $$P]")); StringBuffer buf; buf.Cat("{{1f4 "); formatHeader(buf, invoice); buf.Cat(":: "); formatCompanyData(buf); buf.Cat(":: "); formatClientData(buf, invoice); buf.Cat(":: "); formatPatientData(buf, invoice); buf.Cat(":: "); formatInvoiceItems(buf, invoice); buf.Cat("}}"); if (!AsString(invoice.payed_date).IsEmpty() && lang != LANG_CZ) { buf.Cat("&&&&"); buf.Cat("{{1f4 "); formatBillHeader(buf, invoice, false); buf.Cat(":: "); formatBillPrice(buf, invoice); buf.Cat("}}"); } output << ~buf; return output; }
bool ModbusClient::readHoldingRegisters(quint16 startingAddress, quint16 quantityOfRegisters) { if(!statusConnected) return false; if(isWaitingForResponse) return false; if(startingAddress>=holdingRegistersSize) return false; if((startingAddress+quantityOfRegisters) >= holdingRegistersSize) return false; if(quantityOfRegisters>holdingRegistersSize) return false; byteArrayOutput.clear(); formatHeader(6); quint8 functionCode = MODBUS_FC_READ_HOLDING_REGISTERS; byteArrayOutput.push_back(functionCode); char temp = 0; byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput, 8, startingAddress); byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput, 10, quantityOfRegisters); if(mySocket->write(byteArrayOutput)) { responseTimer->start(responseTimerTimeout); isWaitingForResponse = true; responseTimer->start(); waitingFunctionCode = MODBUS_FC_READ_HOLDING_REGISTERS; return true; } return false; }
bool ModbusClient::writeSingleRegister(quint16 registerAddress) { if(!statusConnected) return false; if(isWaitingForResponse) return false; if(registerAddress>=holdingRegistersSize) return false; byteArrayOutput.clear(); formatHeader(6); quint8 functionCode = MODBUS_FC_WRITE_SINGLE_REGISTER; byteArrayOutput.push_back(functionCode); char temp = 0; byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput,8,registerAddress); byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput,10,holdingRegisters[registerAddress]); if(mySocket->write(byteArrayOutput)) { responseTimer->start(responseTimerTimeout); isWaitingForResponse = true; waitingFunctionCode = MODBUS_FC_WRITE_SINGLE_REGISTER; return true; } return false; }
void DeviceObjectDvp_c::formatBytestream( ByteStreamBuffer_c& byteStream, const IsoAgLib::ProcData::ConnectionCapabilities_s& ) const { formatHeader( byteStream ); byteStream.format( m_offset ); byteStream.format( m_scale ); byteStream.format( m_decimals ); byteStream.format( m_designator ); }
void DeviceObjectDpt_c::formatBytestream( ByteStreamBuffer_c& byteStream, const IsoAgLib::ProcData::ConnectionCapabilities_s& ) const { formatHeader( byteStream ); byteStream.format( m_ddi ); byteStream.format( m_value ); byteStream.format( m_designator ); byteStream.format( m_dvpObjectId ); }
void DeviceObjectDpd_c::formatBytestream( ByteStreamBuffer_c& byteStream, const IsoAgLib::ProcData::ConnectionCapabilities_s& caps ) const { formatHeader( byteStream ); byteStream.format( ddi() ); byteStream.format( properties( caps.hasPeerControl ) ); byteStream.format( method() ); byteStream.format( m_designator ); byteStream.format( m_dvpObjectId ); }
void DeviceObjectDet_c::formatBytestream( ByteStreamBuffer_c& byteStream, const IsoAgLib::ProcData::ConnectionCapabilities_s& ) const { formatHeader( byteStream ); byteStream.format( uint8_t( m_type ) ); byteStream.format( m_designator ); byteStream.format( m_elementNumber ); byteStream.format( m_parentId ); byteStream.format( ( uint16_t )m_childList.size() ); STL_NAMESPACE::vector<uint16_t>::const_iterator it; for ( it = m_childList.begin(); it != m_childList.end(); ++it ) byteStream.format( *it ); }
bool InvoiceList::prepare() { String sqlStatement = "select r.invoice_id, r.inv_create_date, \ (select sum(ri.item_price) from record_item ri where ri.record_id = r.id) \ from record r \ where r.invoice_id is not null and r.inv_create_date between '" + AsString(from) + "' and '" + AsString(to) + "' order by r.inv_create_date, r.invoice_id"; SQL.Execute(sqlStatement); bool found = false; while (SQL.Fetch()) { found = true; VectorMap<int, String> vmap; vmap.Add(iliInvNum, AsString(SQL[0])); vmap.Add(iliDate, AsString(SQL[1])); vmap.Add(iliTotal, fixFuckedLinuxFormating(ConvertMoney().Format(SQL[2]))); inv_list_items.Add(vmap); } if (!found) return false; SQL & Select(SqlSum(ITEM_PRICE.Of(RECORD_ITEM))).From(RECORD_ITEM) .InnerJoin(RECORD).On(RECORD_ID.Of(RECORD_ITEM) == ID.Of(RECORD)) .Where(NotNull(INVOICE_ID.Of(RECORD)) && (Between(INV_CREATE_DATE.Of(RECORD), from, to))); if (SQL.Fetch()) summary_price = SQL[0]; invoiceList.Clear(); invoiceList.Header(String("[A0> ") + String(t_("Page")) + String(" $$P")); StringBuffer buf; buf.Cat("{{1f4 "); formatHeader(buf); buf.Cat(":: "); formatCompanyData(buf); buf.Cat(":: "); formatItems(buf); buf.Cat("}}"); LOG(~buf); invoiceList << ~buf; return true; }
bool ModbusClient::writeMultipleRegisters(quint16 startingAddress, quint16 quantityOfRegisters) { if(!statusConnected) return false; if(isWaitingForResponse) return false; if(startingAddress>=holdingRegistersSize) return false; if((startingAddress+quantityOfRegisters)>=holdingRegistersSize) return false; if(quantityOfRegisters>holdingRegistersSize) return false; byteArrayOutput.clear(); formatHeader(7+2*quantityOfRegisters); quint8 functionCode = MODBUS_FC_WRITE_MULTIPLE_REGISTERS; byteArrayOutput.push_back(functionCode); char temp = 0; byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput, 8, startingAddress); byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput, 10, quantityOfRegisters); quint8 byteCount = quantityOfRegisters*2; byteArrayOutput.push_back(temp); setQInt8(byteArrayOutput, 12, byteCount); for(int i=0 ; i<quantityOfRegisters ; i++) { byteArrayOutput.push_back(temp); byteArrayOutput.push_back(temp); setQInt16(byteArrayOutput,13+2*i,holdingRegisters[startingAddress+i]); } if(mySocket->write(byteArrayOutput, byteArrayOutput.size())) { isWaitingForResponse = true; waitingFunctionCode = MODBUS_FC_WRITE_MULTIPLE_REGISTERS; responseTimer->start(responseTimerTimeout); return true; } return false; }
void DeviceObjectDvc_c::formatBytestream( ByteStreamBuffer_c& byteStream, const IsoAgLib::ProcData::ConnectionCapabilities_s& caps ) const { formatHeader( byteStream ); isoaglib_assert( CNAMESPACE::strlen( m_version ) <= size_t((caps.versionNr >= 4) ? 128 : 32) ); byteStream.format( m_designator ); byteStream.format( m_version ); byteStream.format( getWsmName().outputString(), 8 ); byteStream.format( m_serialNumber ); byteStream.format( ( uint8_t* )&m_structLabel, 7 ); byteStream.format( ( uint8_t* )&m_localization, 7 ); if( caps.versionNr >= 4 ) { byteStream.format( m_extendedStructureLabel.length ); byteStream.format( (uint8_t*)&m_extendedStructureLabel.byteString, m_extendedStructureLabel.length ); } }
Report& InvoiceFormatter::formatFullInvoices(Vector<InvoiceData>& invoices) { output.Clear(); output.Header(String("[A0> ") + String(t_("Page")) + String(" $$P]")); for (int i=0; i<invoices.GetCount(); i++) { StringBuffer buf; buf.Cat("[ "); buf.Cat("{{1f4 "); formatHeader(buf, invoices[i]); buf.Cat(":: "); formatCompanyData(buf); buf.Cat(":: "); formatClientData(buf, invoices[i]); buf.Cat(":: "); formatPatientData(buf, invoices[i]); buf.Cat(":: "); formatInvoiceItems(buf, invoices[i]); buf.Cat("}}"); if (!AsString(invoices[i].payed_date).IsEmpty() && lang != LANG_CZ) { buf.Cat("&&&&"); buf.Cat("{{1f4 "); formatBillHeader(buf, invoices[i], false); buf.Cat(":: "); formatBillPrice(buf, invoices[i]); buf.Cat("}}"); } buf.Cat(" ]"); output << ~buf; if (i != invoices.GetCount()-1) output.NewPage(); } return output; }
static void prtLoad (struct hostInfoEnt *hPtrs, struct lsInfo *lsInfo) { static char fname[] = "prtLoad"; char **nlp = NULL; int i, nf; char **loadval; char **loadval1; int start = 0; int end; int last; if (!fmt) { if(!(fmt=(struct indexFmt *) malloc((lsInfo->numIndx+2)*sizeof (struct indexFmt)))) { lsberrno=LSBE_NO_MEM; lsb_perror("print_long"); exit(-1); } for (i=0; i<NBUILTINDEX+2; i++) fmt[i]=fmt1[i]; } if ((nlp = formLINamesList (lsInfo)) == NULL) { fprintf (stderr, "%s\n", _i18n_msg_get(ls_catd,NL_SETN,1629, "Bad load index name specified")); /* catgets 1629 */ exit (-1); } if ((loadval=(char **) malloc((lsInfo->numIndx+1) * sizeof(char *))) == NULL) { lserrno=LSE_MALLOC; lsb_perror(fname); exit(-1); } if ((loadval1=(char **) malloc((lsInfo->numIndx+1) * sizeof(char *))) == NULL) { lserrno=LSE_MALLOC; lsb_perror(fname); exit(-1); } last = hPtrs->nIdx; for (i=0; i < last; i++) { loadval[i] = malloc(MAXFIELDSIZE); loadval1[i] = malloc(MAXFIELDSIZE); if (loadval[i] == NULL || loadval[i] == NULL) { lserrno=LSE_MALLOC; lsb_perror(fname); exit(-1); } } nf = makeFields(hPtrs, loadval, nlp, TRUE); nf = makeFields(hPtrs, loadval1, nlp, FALSE); while ((end = getDispLastItem(nlp, start, last)) > start && start < last) { printf(" %11s", " "); printf("%s\n", formatHeader(nlp, start, end)); printf( " %-11.11s", _i18n_msg_get(ls_catd,NL_SETN,1630, "Total")); /* catgets 1630 */ for (i=start; i < end; i++) printf("%s", loadval[i]); putchar('\n'); printf( " %-11.11s", _i18n_msg_get(ls_catd,NL_SETN,1631, "Reserved")); /* catgets 1631 */ for (i=start; i < end; i++) printf("%s", loadval1[i]); putchar('\n'); putchar('\n'); start = end; } putchar('\n'); for (i=0; i < last; i++) { FREEUP(loadval[i]); FREEUP(loadval1[i]); } FREEUP(loadval); FREEUP(loadval1); }