diff --git a/Src/Include/Db.h b/Src/Include/Db.h index 7749033b5..e7e310595 100644 --- a/Src/Include/Db.h +++ b/Src/Include/Db.h @@ -4810,28 +4810,36 @@ struct SDataPageHeader { }; class SRecPageManager { -public: // // Структура RowId: // | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | // 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 // 6 5 4 3 2 1 0 - // | | | - // reserve offs bits + // | | | | | + // reserve pobw page sequence number offset in the page // // Общий размер типа: 64 бита // Старшие 16 бит - зарезервированы // Следующие старшие 4 бита - индикатор битовой ширины поля смещения внутри страницы. // Битовая ширина смещения может быть от 9 до 24 бит (0: 9, 1: 10, 15: 24) // Битовую ширину поля смещения назовем pobw (page offset bit-width) - // Само смещение внутри страницы задается со сдвигом в 32 поскольку заголовок - // страницы длиной 32 байта не участвует в распределении рабочих блоков. - // Таким образом максимальная длина страницы = 2^(24+5) // Следующие старшие (64-4-pobw) бит - номер страницы. + // Самые младшие pobw бит - смещение внутри страницы // static constexpr uint RowIdBitWidth = 48; + static FORCEINLINE uint GetPageBits(uint offsetBits) { return (RowIdBitWidth - offsetBits - 4/*pobw*/); } + // + // Descr: Вспомогательная функция, определяющая битовую ширину поля смещения в идентификаторе + // блока записи. Функция принимает опциональный проверочный аргумент pageSize. + // Если pageSize != 0, то функция одновременно извлекает битовую ширину смещения из rowid + // и вычисляет ее исходя из размера страницы. Если полученные два значения не равны, + // то возвращает 0 (error). + // + static uint Helper_SplitRowId_GetOffsetBits(uint64 rowId, uint pageSize); +public: static uint64 MakeRowId(uint pageSize, uint pageSeq, uint offset); - static int SplitRowId(uint64 rowId, uint pageSize, uint * pPageSeq, uint * pOffset); + static int SplitRowId_WithPageSizeCheck(uint64 rowId, uint pageSize, uint * pPageSeq, uint * pOffset); + static int SplitRowId(uint64 rowId, uint * pPageSeq, uint * pOffset); SRecPageManager(uint32 pageSize); ~SRecPageManager(); int Write(uint64 * pRowId, uint pageType, const void * pData, size_t dataLen); @@ -4847,6 +4855,7 @@ class SRecPageManager { SDataPageHeader * AllocatePage(uint32 type); SDataPageHeader * QueryPageForReading(uint64 rowId, uint32 pageType, uint * pOffset); int ReleasePage(SDataPageHeader * pPage); + int WriteToPage(SDataPageHeader * pPage, uint64 rowId, const void * pData, size_t dataLen); const uint32 PageSize; uint32 LastSeq; diff --git a/Src/Include/Pp.h b/Src/Include/Pp.h index 14aafdea8..041c8edae 100644 --- a/Src/Include/Pp.h +++ b/Src/Include/Pp.h @@ -22030,6 +22030,18 @@ class PPSyncCashSession { int Status; // tag 2109 Сведения о статусе товара (ofdtag-2109) */ static void LogPreprocessChZnCodeResult(int ret, int op, const char * pCode, double qtty, const CCheckPacket::PreprocessChZnCodeResult & rResult); + + enum { + ppchzcopCheck = 0, // проверка марки + ppchzcopAccept = 1, // акцепт марки. должна быть вызвана непосредственно после вызова PreprocessChZnCode(0, ...) + ppchzcopReject = 2, // отказ от акцепта марки. должна быть вызвана непосредственно после вызова PreprocessChZnCode(0, ...) + ppchzcopInit = 100, // предварительные операции перед проверкой марок по чеку. Может быть актуально для некоторых типов регистраторов + ppchzcopSurrogateCheck = 101, // фиктивная проверка марки в специальных случаях (draftbeer horeca) // @v11.9.4 + ppchzcopSurrogateAccept = 102, // фиктивный акцепт марки в специальных случаях (draftbeer horeca) // @v11.9.4 + ppchzcopCancel = 103, // @v12.0.4 Функция отмены после проверки марок. Применяется в паре с ppchzcopInit если операция инициализации + // провела какие-то действия, которые требуется отменить в случае, если чек не проводится. + // Фактически, эта операция введена ради аппарата Штрих-ФР из-за того, что проверку марок он осущетсвляет только в режиме открытого чека. + }; // // Descr: Функция реализует препроцессинг кодов маркировки товаров в соответствии с российскими правилами ОФД 1.2 // ARG(op IN): diff --git a/Src/Include/SLIB.H b/Src/Include/SLIB.H index dbd74c930..fd2779bed 100644 --- a/Src/Include/SLIB.H +++ b/Src/Include/SLIB.H @@ -7732,6 +7732,9 @@ public: #endif static FORCEINLINE uint32 Rotr(ulong x, uint n) { return Rotr((uint32)x, n); } static FORCEINLINE uint32 Rotl(ulong x, uint n) { return Rotl((uint32)x, n); } + // + static FORCEINLINE uint32 CeilLog2(uint32 x) { return x ? (32 - Clz(x - 1)) : 0; } // @v12.0.4 + static FORCEINLINE uint64 CeilLog2(uint64 x) { return x ? (64 - Clz(x - 1)) : 0; } // @v12.0.4 }; // // Encrypt / Decrypt functions diff --git a/Src/OSF/openjpeg/src/lib/openjp2/t2.c b/Src/OSF/openjpeg/src/lib/openjp2/t2.c index 2067356ae..e6f768996 100644 --- a/Src/OSF/openjpeg/src/lib/openjp2/t2.c +++ b/Src/OSF/openjpeg/src/lib/openjp2/t2.c @@ -1218,24 +1218,19 @@ static boolint opj_t2_read_packet_header(opj_t2_t* p_t2, } } n = (int32_t)l_cblk->numnewpasses; - if((p_tcp->tccps[p_pi->compno].cblksty & J2K_CCP_CBLKSTY_HT) != 0) do { uint32_t bit_number; l_cblk->segs[l_segno].numnewpasses = l_segno == 0 ? 1 : (uint32_t)n; - bit_number = l_cblk->numlenbits + opj_uint_floorlog2( - l_cblk->segs[l_segno].numnewpasses); + bit_number = l_cblk->numlenbits + opj_uint_floorlog2(l_cblk->segs[l_segno].numnewpasses); if(bit_number > 32) { - opj_event_msg(p_manager, EVT_ERROR, - "Invalid bit number %d in opj_t2_read_packet_header()\n", - bit_number); + opj_event_msg(p_manager, EVT_ERROR, "Invalid bit number %d in opj_t2_read_packet_header()\n", bit_number); opj_bio_destroy(l_bio); return FALSE; } l_cblk->segs[l_segno].newlen = opj_bio_read(l_bio, bit_number); JAS_FPRINTF(stderr, "included=%d numnewpasses=%d increment=%d len=%d \n", - l_included, l_cblk->segs[l_segno].numnewpasses, l_increment, - l_cblk->segs[l_segno].newlen); + l_included, l_cblk->segs[l_segno].numnewpasses, l_increment, l_cblk->segs[l_segno].newlen); n -= (int32_t)l_cblk->segs[l_segno].numnewpasses; if(n > 0) { ++l_segno; diff --git a/Src/OSF/openjpeg/src/lib/openjp2/tcd.c b/Src/OSF/openjpeg/src/lib/openjp2/tcd.c index 18a84331c..6e4ead540 100644 --- a/Src/OSF/openjpeg/src/lib/openjp2/tcd.c +++ b/Src/OSF/openjpeg/src/lib/openjp2/tcd.c @@ -931,40 +931,28 @@ static INLINE boolint opj_tcd_init_tile(opj_tcd_t * p_tcd, uint32_t p_tile_no, b /* BUG_WEIRD_TWO_INVK (look for this identifier in dwt.c): */ /* the test (!isEncoder && l_tccp->qmfbid == 0) is strongly */ /* linked to the use of two_invK instead of invK */ - const int32_t log2_gain = (!isEncoder && - l_tccp->qmfbid == 0) ? 0 : (l_band->bandno == 0) ? 0 : - (l_band->bandno == 3) ? 2 : 1; - + const int32_t log2_gain = (!isEncoder && l_tccp->qmfbid == 0) ? 0 : (l_band->bandno == 0) ? 0 : (l_band->bandno == 3) ? 2 : 1; /* Nominal dynamic range. Equation E-4 */ const int32_t Rb = (int32_t)l_image_comp->prec + log2_gain; - /* Delta_b value of Equation E-3 in "E.1 Inverse quantization * procedure" of the standard */ - l_band->stepsize = (float)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0, - (int32_t)(Rb - l_step_size->expn)))); + l_band->stepsize = (float)(((1.0 + l_step_size->mant / 2048.0) * pow(2.0, (int32_t)(Rb - l_step_size->expn)))); } - /* Mb value of Equation E-2 in "E.1 Inverse quantization * procedure" of the standard */ - l_band->numbps = l_step_size->expn + (int32_t)l_tccp->numgbits - - 1; - + l_band->numbps = l_step_size->expn + (int32_t)l_tccp->numgbits - 1; if(!l_band->precincts && (l_nb_precincts > 0U)) { - l_band->precincts = (opj_tcd_precinct_t*)opj_malloc(/*3 * */ - l_nb_precinct_size); + l_band->precincts = (opj_tcd_precinct_t*)opj_malloc(/*3 * */ l_nb_precinct_size); if(!l_band->precincts) { - opj_event_msg(manager, EVT_ERROR, - "Not enough memory to handle band precints\n"); + opj_event_msg(manager, EVT_ERROR, "Not enough memory to handle band precints\n"); return FALSE; } - /*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t): - %d\n",l_nb_precinct_size); */ + /*fprintf(stderr, "\t\t\t\tAllocate precincts of a band (opj_tcd_precinct_t):%d\n",l_nb_precinct_size); */ memzero(l_band->precincts, l_nb_precinct_size); l_band->precincts_data_size = l_nb_precinct_size; } else if(l_band->precincts_data_size < l_nb_precinct_size) { - opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t*)opj_realloc( - l_band->precincts, /*3 * */ l_nb_precinct_size); + opj_tcd_precinct_t * new_precincts = (opj_tcd_precinct_t*)opj_realloc(l_band->precincts, /*3 * */ l_nb_precinct_size); if(!new_precincts) { opj_event_msg(manager, EVT_ERROR, "Not enough memory to handle band precints\n"); SAlloc::F(l_band->precincts); diff --git a/Src/PPEquip/Crcshsrv.cpp b/Src/PPEquip/Crcshsrv.cpp index b99de0654..9e3ae7cff 100644 --- a/Src/PPEquip/Crcshsrv.cpp +++ b/Src/PPEquip/Crcshsrv.cpp @@ -703,28 +703,6 @@ int ACS_CRCSHSRV::Helper_ExportGoods_V10(const int mode, bool goodsIdAsArticle, if(oneof2(mode, 0, 1)) { // @v10.6.7 p_writer->PutElement("name", r_cur_entry.Name); { - // @v11.4.4 { - /* @v11.4.5 if(goodsIdAsArticle) { - // @v10.9.11 { - if(r_cur_entry.Flags_ & AsyncCashGoodsInfo::fGMarkedType) { - const char * p_mark_type = 0; - switch(r_cur_entry.ChZnProdType) { - case GTCHZNPT_SHOE: p_mark_type = "FOOTWEAR"; break; - case GTCHZNPT_TEXTILE: p_mark_type = "LIGHT_INDUSTRY"; break; - case GTCHZNPT_CARTIRE: p_mark_type = "TYRES"; break; - case GTCHZNPT_PERFUMERY: p_mark_type = "PERFUMES"; break; - case GTCHZNPT_MILK: p_mark_type = "MILK"; break; - } - if(p_mark_type) - p_writer->PutElement("mark-type", p_mark_type); - } - // } @v10.9.11 - p_writer->StartElement("bar-code", "code", temp_buf.Z().Cat(r_cur_entry.ID)); - p_writer->PutElement("count", temp_buf.Z().Cat("1")); - p_writer->PutElement("default-code", true); - p_writer->EndElement(); // - }*/ - // } @v11.4.4 for(uint i = 0; i < barcodes.getCount(); i++) { BarcodeTbl::Rec bc = barcodes.at(i); if(sstrlen(bc.Code)) { @@ -742,6 +720,7 @@ int ACS_CRCSHSRV::Helper_ExportGoods_V10(const int mode, bool goodsIdAsArticle, case GTCHZNPT_MILK: p_mark_type = "MILK"; break; case GTCHZNPT_WATER: p_mark_type = "WATER"; break; // @v11.5.6 case GTCHZNPT_DRAFTBEER: p_mark_type = "DRAFT_BEER"; break; // @v11.9.2 + case GTCHZNPT_BEER: p_mark_type = "BEER"; break; // @v12.0.4 } if(p_mark_type) p_writer->PutElement("mark-type", p_mark_type); diff --git a/Src/PPEquip/EquipDll/Pirit.cpp b/Src/PPEquip/EquipDll/Pirit.cpp index 99c2049f7..fa67ec845 100644 --- a/Src/PPEquip/EquipDll/Pirit.cpp +++ b/Src/PPEquip/EquipDll/Pirit.cpp @@ -2550,7 +2550,6 @@ int PiritEquip::RunCheck(int opertype) CreateStr("", in_data); // #13 (tag 1073) Телефон(ы) платежного агента (для пл.агента/субагента, иначе пустой) CreateStr("", in_data); // #14 (tag 1074) Телефон(ы) оператора по приему платежей (для пл.агента/субагента, иначе пустой) CreateStr("030"/*GTCHZNPT_DRAFTBEER*/, in_data); // #15 (tag 1262) Идентификатор ФОИВ. Значение определяется ФНС РФ. Параметр используется только при регистрации ККТ в режиме ФФД 1.2. - // @v11.9.3 str.Z().Cat(checkdate(Check.Timestamp.d) ? Check.Timestamp.d : getcurdate_(), DATF_DMY|DATF_NODIV|DATF_CENTURY); // @v11.2.3 // @v11.2.7 str.Z().Cat("26032022"); // @v11.9.3 //str.Z().Cat(checkdate(Check.Timestamp.d) ? Check.Timestamp.d : getcurdate_(), DATF_DMY | DATF_NODIV | DATF_CENTURY); @@ -2567,7 +2566,8 @@ int PiritEquip::RunCheck(int opertype) // Параметр используется только при регистрации ККТ в режиме ФФД 1.2. // @v11.2.3 { { - str.Z(); + // @v12.0.4 str.Z(); + str.Z().Cat("mode=horeca"); // @v12.0.4 CreateStr(str, in_data); // #18 (tag 1265) Значение отраслевого реквизита. Значение определяется отраслевым НПА. // Параметр используется только при регистрации ККТ в режиме ФФД 1.2. } @@ -2687,7 +2687,7 @@ int PiritEquip::RunCheck(int opertype) CreateStr(str, in_data); // #15 (tag 1262) Идентификатор ФОИВ. Значение определяется ФНС РФ. Параметр используется только при регистрации ККТ в режиме ФФД 1.2. } // @v11.9.3 str.Z().Cat(checkdate(Check.Timestamp.d) ? Check.Timestamp.d : getcurdate_(), DATF_DMY|DATF_NODIV|DATF_CENTURY); // @v11.2.3 // @v11.2.7 - str.Z().Cat("26.03.2022"); // @v11.9.3 // @v12.0.3 @fix "26032022"-->"26.03.2022" + str.Z().Cat("26032022"); // @v11.9.3 CreateStr(str, in_data); // #16 (tag 1263) Дата документа основания. Допускается дата после 1999 года. // Должен содержать сведения об НПА отраслевого регулирования. Параметр используется только при регистрации ККТ в режиме ФФД 1.2. /* @v11.9.3 if(Check.CheckNum > 0) diff --git a/Src/PPEquip/Shtrihfr.cpp b/Src/PPEquip/Shtrihfr.cpp index 59b690349..266c4fc88 100644 --- a/Src/PPEquip/Shtrihfr.cpp +++ b/Src/PPEquip/Shtrihfr.cpp @@ -207,38 +207,8 @@ class SCS_SHTRIHFRF : public PPSyncCashSession { const bool IsDebugMode; uint8 Reserve[3]; // @alignment public: - SCS_SHTRIHFRF(PPID n, char * name, char * port) : PPSyncCashSession(n, name, port), - CashierPassword(0), AdmPassword(0), ResCode(RESCODE_NO_ERROR), ErrCode(SYNCPRN_NO_ERROR), - DeviceType(devtypeUndef), CheckStrLen(DEF_STRLEN), Flags(0), RibbonParam(0), SCardPaymEntryN(0), - IsDebugMode(LOGIC(CConfig.Flags & CCFLG_DEBUG)), ConnectionMode(connmodeUndef) - { - if(SCn.Flags & CASHF_NOTUSECHECKCUTTER) - Flags |= sfDontUseCutter; - RefToIntrf++; - SETIFZ(P_DrvFRIntrf, InitDriver()); - } - ~SCS_SHTRIHFRF() - { - if(Flags & sfConnected) { - switch(ConnectionMode) { - case connmodeCom: - case connmodeComV2: - if(!ExecFR(Disconnect)) - LogLastError(); - break; - case connmodeServer: - if(!ExecFR(ServerDisconnect)) - LogLastError(); - break; - default: - constexpr int ShtrihFR_ConnectionModeUndefined = 0; - assert(ShtrihFR_ConnectionModeUndefined); - break; - } - } - if(--RefToIntrf == 0) - ZDELETE(P_DrvFRIntrf); - } + SCS_SHTRIHFRF(PPID n, char * pName, char * pPort); + ~SCS_SHTRIHFRF(); virtual int PrintCheck(CCheckPacket * pPack, uint flags); virtual int PrintCheckCopy(const CCheckPacket * pPack, const char * pFormatName, uint flags); virtual int PrintSlipDoc(const CCheckPacket * pPack, const char * pFormatName, uint flags); @@ -278,33 +248,8 @@ class SCS_SHTRIHFRF : public PPSyncCashSession { int ExecFRPrintOper(int id); int AllowPrintOper(int id); void SetErrorMessage(); - void WriteLogFileToWriteTblErr(int tblNum, int rowNum, int fldNum, const char * pValue) - { - if(IsDebugMode) { - SString msg_fmt, msg, value; - (value = pValue).Transf(CTRANSF_OUTER_TO_INNER); - msg.Printf(PPLoadTextS(PPTXT_LOG_SHTRIH_WRITETBLERR, msg_fmt), tblNum, rowNum, fldNum, value.cptr()); - PPLogMessage(PPFILNAM_SHTRIH_LOG, msg, LOGMSGF_TIME|LOGMSGF_USER); - } - } - void LogDebug(const char * pFunc, int ifcId, const char * pArg) - { - if(IsDebugMode) { - SString temp_buf; - SString msg_buf; - if(!isempty(pFunc)) - msg_buf.Cat(pFunc); - if(ifcId >= 0 && P_DrvFRIntrf) { - P_DrvFRIntrf->GetNameByID(ifcId, temp_buf); - msg_buf.CatDivConditionally(',', 2, msg_buf.NotEmpty()).Cat(temp_buf); - } - if(!isempty(pArg)) { - msg_buf.CatDivConditionally(',', 2, msg_buf.NotEmpty()).Cat(pArg); - } - if(msg_buf.NotEmpty()) - PPLogMessage(PPFILNAM_SHTRIH_LOG, msg_buf, LOGMSGF_TIME|LOGMSGF_USER); - } - } + void WriteLogFileToWriteTblErr(int tblNum, int rowNum, int fldNum, const char * pValue); + void LogDebug(const char * pFunc, int ifcId, const char * pArg); // // Returns: // 0 only. In order to initialize return code @@ -490,7 +435,7 @@ class SCS_SHTRIHFRF : public PPSyncCashSession { }; enum ShtrihFlags { sfConnected = 0x0001, // установлена связь с Штрих-ФР, COM-порт занят - sfOpenCheck = 0x0002, // чек открыт + sfCheckOpened = 0x0002, // чек открыт sfCancelled = 0x0004, // операция печати чека прервана пользователем sfOldShtrih = 0x0008, // старая версия драйвера Штрих-ФР sfPrintSlip = 0x0010, // печать подкладного документа @@ -571,6 +516,40 @@ PPSyncCashSession * CM_SHTRIHFRF::SyncInterface() REGISTER_CMT(SHTRIHFRF, true, false); +SCS_SHTRIHFRF::SCS_SHTRIHFRF(PPID n, char * name, char * port) : PPSyncCashSession(n, name, port), + CashierPassword(0), AdmPassword(0), ResCode(RESCODE_NO_ERROR), ErrCode(SYNCPRN_NO_ERROR), + DeviceType(devtypeUndef), CheckStrLen(DEF_STRLEN), Flags(0), RibbonParam(0), SCardPaymEntryN(0), + IsDebugMode(LOGIC(CConfig.Flags & CCFLG_DEBUG)), ConnectionMode(connmodeUndef) +{ + if(SCn.Flags & CASHF_NOTUSECHECKCUTTER) + Flags |= sfDontUseCutter; + RefToIntrf++; + SETIFZ(P_DrvFRIntrf, InitDriver()); +} + +SCS_SHTRIHFRF::~SCS_SHTRIHFRF() +{ + if(Flags & sfConnected) { + switch(ConnectionMode) { + case connmodeCom: + case connmodeComV2: + if(!ExecFR(Disconnect)) + LogLastError(); + break; + case connmodeServer: + if(!ExecFR(ServerDisconnect)) + LogLastError(); + break; + default: + constexpr int ShtrihFR_ConnectionModeUndefined = 0; + assert(ShtrihFR_ConnectionModeUndefined); + break; + } + } + if(--RefToIntrf == 0) + ZDELETE(P_DrvFRIntrf); +} + /*virtual*/int SCS_SHTRIHFRF::Diagnostics(StringSet * pSs) // @v12.0.3 { int ok = 1; @@ -843,10 +822,6 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) double amt = fabs(R2(MONEYTOLDBL(pPack->Rec.Amount))); double sum = fabs(pPack->_Cash) + 0.001; double running_total = 0.0; - // @v10.1.11 double fiscal = 0.0; - // @v10.1.11 double nonfiscal = 0.0; - // @v10.1.11 pPack->HasNonFiscalAmount(&fiscal, &nonfiscal); - // @v10.1.11 { double real_fiscal = 0.0; double real_nonfiscal = 0.0; pPack->HasNonFiscalAmount(&real_fiscal, &real_nonfiscal); @@ -857,7 +832,6 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) const double amt_bnk = is_al ? r_al.Get(CCAMTTYP_BANK) : ((pPack->Rec.Flags & CCHKF_BANKING) ? _fiscal : 0.0); const double amt_cash = (PPConst::Flags & PPConst::fDoSeparateNonFiscalCcItems) ? (_fiscal - amt_bnk) : (is_al ? r_al.Get(CCAMTTYP_CASH) : (_fiscal - amt_bnk)); const double amt_ccrd = is_al ? r_al.Get(CCAMTTYP_CRDCARD) : (real_fiscal + real_nonfiscal - _fiscal); - // } @v10.1.11 PPID tax_sys_id = 0; CnObj.GetTaxSystem(NodeID, pPack->Rec.Dt, &tax_sys_id); // @v10.9.0 { @@ -888,7 +862,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) if(_fiscal != 0.0) { THROW(SetFR(CheckType, (flags & PRNCHK_RETURN) ? 2L : 0L)); THROW(ExecFRPrintOper(OpenCheck)); - // @v10.9.0 { + Flags |= sfCheckOpened; if(use_fn_op) { /* полеОбъектККМ.CheckType = 0; @@ -935,13 +909,11 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) THROW(ExecFRPrintOper(FNSendSTLVTag)); } } - // } @v10.9.0 } else { THROW(SetFR(DocumentName, "" /*sdc_param.Title*/)); THROW(ExecFRPrintOper(PrintDocumentTitle)); } - Flags |= sfOpenCheck; for(P_SlipFmt->InitIteration(pPack); P_SlipFmt->NextIteration(line_buf, &sl_param) > 0;) { if(sl_param.Flags & SlipLineParam::fRegFiscal) { CheckForRibbonUsing(SlipLineParam::fRegRegular|SlipLineParam::fRegJournal); @@ -1063,7 +1035,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) else { THROW(ExecFRPrintOper((flags & PRNCHK_RETURN) ? ReturnSale : Sale)); } - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; prn_total_sale = 0; } else if(sl_param.Kind == sl_param.lkBarcode) { @@ -1122,7 +1094,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetFR(Price, amt)); THROW(SetFR(Tax1, shtrih_vat_rate_ident)); // @v11.2.11 0-->shtrih_vat_rate_ident THROW(ExecFRPrintOper((flags & PRNCHK_RETURN) ? ReturnSale : Sale)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; running_total += amt; } else /*if(fiscal != 0.0)*/ { @@ -1130,7 +1102,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetFR(Price, _fiscal)); THROW(SetFR(Tax1, shtrih_vat_rate_ident)); // @v11.2.11 0-->shtrih_vat_rate_ident THROW(ExecFRPrintOper((flags & PRNCHK_RETURN) ? ReturnSale : Sale)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; running_total += _fiscal; } } @@ -1163,7 +1135,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) } THROW(SetFR(Tax1, 0L)); THROW(ExecFRPrintOper((flags & PRNCHK_RETURN) ? ReturnSale : Sale)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; } // Информация о скидке if(DeviceType == devtypeShtrih) @@ -1273,7 +1245,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetFR(ReceiptOutputType, 0)); THROW(ExecFRPrintOper(OutputReceipt)); } - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; ErrCode = SYNCPRN_ERROR_AFTER_PRINT; THROW(Cut(1)); THROW(SetFR(RegisterNumber, CHECK_NUMBER_REG)); @@ -1289,7 +1261,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) if(ErrCode != SYNCPRN_ERROR_AFTER_PRINT) { SString no_print_txt; PPLoadText(PPTXT_CHECK_NOT_PRINTED, no_print_txt); - ErrCode = (Flags & sfOpenCheck) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; + ErrCode = (Flags & sfCheckOpened) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; PPLogMessage(PPFILNAM_SHTRIH_LOG, CCheckCore::MakeCodeString(&pPack->Rec, 0, no_print_txt), LOGMSGF_TIME|LOGMSGF_USER); ok = 0; } @@ -1297,7 +1269,7 @@ int SCS_SHTRIHFRF::PrintCheck(CCheckPacket * pPack, uint flags) else { SetErrorMessage(); ExecFR(Beep); - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ErrCode = SYNCPRN_ERROR_WHILE_PRINT; ok = 0; } @@ -1323,14 +1295,14 @@ int SCS_SHTRIHFRF::OpenBox() if(Flags & sfCancelled) { Flags &= ~sfCancelled; if(ErrCode != SYNCPRN_ERROR_AFTER_PRINT) { - ErrCode = (Flags & sfOpenCheck) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; + ErrCode = (Flags & sfCheckOpened) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; ok = 0; } } else { SetErrorMessage(); ExecFR(Beep); - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ErrCode = SYNCPRN_ERROR_WHILE_PRINT; ok = 0; } @@ -1664,7 +1636,7 @@ int SCS_SHTRIHFRF::PrintReport(int withCleaning) cshr_pssw = CashierPassword; CashierPassword = AdmPassword; // - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; THROW(ExecFR(GetECRStatus)); THROW(GetFR(ECRMode, &mode)); if(withCleaning) { @@ -1686,8 +1658,8 @@ int SCS_SHTRIHFRF::PrintReport(int withCleaning) ok = (ExecFR(Beep), 0); } ENDCATCH - if(Flags & sfOpenCheck) { - Flags &= ~sfOpenCheck; + if(Flags & sfCheckOpened) { + Flags &= ~sfCheckOpened; CashierPassword = cshr_pssw; } return ok; @@ -1747,7 +1719,7 @@ int SCS_SHTRIHFRF::PrintIncasso(double sum, int isIncome) int ok = 1; ResCode = RESCODE_NO_ERROR; THROW(ConnectFR()); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; THROW(SetFR(Summ1, sum)); if(isIncome) { THROW(LineFeed(6, TRUE, FALSE)); @@ -1772,7 +1744,7 @@ int SCS_SHTRIHFRF::PrintIncasso(double sum, int isIncome) ok = (ExecFR(Beep), 0); } ENDCATCH - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; return ok; } @@ -2016,23 +1988,23 @@ int SCS_SHTRIHFRF::AnnulateCheck() // Проверка на незавершенную печать THROW(GetFR(ECRAdvancedMode, &adv_mode)); if(adv_mode == PRNMODE_AFTER_NO_PAPER) { - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; THROW(ExecFRPrintOper(ContinuePrint)); do { THROW(ExecFR(GetECRStatus)); THROW(GetFR(ECRAdvancedMode, &adv_mode)); } while(adv_mode == PRNMODE_PRINT); - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; cut = 1; } } // Проверка на наличие открытого чека, который надо аннулировать THROW(GetFR(ECRMode, &mode)); if(mode == FRMODE_OPEN_CHECK) { - Flags |= sfOpenCheck | sfCancelled; + Flags |= sfCheckOpened | sfCancelled; PPMessage(mfInfo|mfOK, PPINF_SHTRIHFR_CHK_ANNUL); THROW(ExecFRPrintOper(CancelCheck)); - Flags &= ~(sfOpenCheck | sfCancelled); + Flags &= ~(sfCheckOpened | sfCancelled); cut = 1; ok = 1; } @@ -2520,6 +2492,35 @@ int SCS_SHTRIHFRF::ExecFRPrintOper(int id) static bool IsModeOffPrint(int mode) { return oneof5(mode, FRMODE_OPEN_SESS, FRMODE_CLOSE_SESS, FRMODE_OPEN_CHECK, FRMODE_FULL_REPORT, FRMODE_LONG_EKLZ_REPORT) ? false : true; } +void SCS_SHTRIHFRF::WriteLogFileToWriteTblErr(int tblNum, int rowNum, int fldNum, const char * pValue) +{ + if(IsDebugMode) { + SString msg_fmt, msg, value; + (value = pValue).Transf(CTRANSF_OUTER_TO_INNER); + msg.Printf(PPLoadTextS(PPTXT_LOG_SHTRIH_WRITETBLERR, msg_fmt), tblNum, rowNum, fldNum, value.cptr()); + PPLogMessage(PPFILNAM_SHTRIH_LOG, msg, LOGMSGF_TIME|LOGMSGF_USER); + } +} + +void SCS_SHTRIHFRF::LogDebug(const char * pFunc, int ifcId, const char * pArg) +{ + if(IsDebugMode) { + SString temp_buf; + SString msg_buf; + if(!isempty(pFunc)) + msg_buf.Cat(pFunc); + if(ifcId >= 0 && P_DrvFRIntrf) { + P_DrvFRIntrf->GetNameByID(ifcId, temp_buf); + msg_buf.CatDivConditionally(',', 2, msg_buf.NotEmpty()).Cat(temp_buf); + } + if(!isempty(pArg)) { + msg_buf.CatDivConditionally(',', 2, msg_buf.NotEmpty()).Cat(pArg); + } + if(msg_buf.NotEmpty()) + PPLogMessage(PPFILNAM_SHTRIH_LOG, msg_buf, LOGMSGF_TIME|LOGMSGF_USER); + } +} + int SCS_SHTRIHFRF::LogLastError() { SString & r_msg_buf = SLS.AcquireRvlStr(); @@ -2606,7 +2607,7 @@ int SCS_SHTRIHFRF::AllowPrintOper(int id) else { // На всякий случай помечаем, что чек открыт (иначе при сбое операции открытия чека неизвестно: чек уже открыт или нет) if(mode == FRMODE_OPEN_CHECK) - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; // Ожидание заправки чековой ленты или выхода из режима, когда нельзя печатать чек while(ok && (oneof2(adv_mode, PRNMODE_NO_PRINT_NO_PAPER, PRNMODE_PRINT_NO_PAPER) || (last_res_code == RESCODE_MODE_OFF && IsModeOffPrint(mode)))) { int send_msg = 0, r; @@ -2698,10 +2699,18 @@ void SCS_SHTRIHFRF::SetErrorMessage() int ok = -1; SString temp_buf; SString msg_buf; - if(op == 100) { // 100 - предварителные операции перед проверкой марок по чеку. Может быть актуально для некоторых типов регистраторов. - ; + if(op == ppchzcopInit) { + THROW(SetFR(CheckType, 0L/*Продажа*/)); + THROW(ExecFRPrintOper(OpenCheck)); + Flags |= sfCheckOpened; + } + else if(op == ppchzcopCancel) { + if(Flags & sfCheckOpened) { + THROW(ExecFRPrintOper(CancelCheck)); + Flags &= ~(sfCheckOpened | sfCancelled); + } } - else if(op == 0) { + else if(op == ppchzcopCheck) { rResult.CheckResult = 0; rResult.Reason = 0; rResult.ProcessingResult = 0; @@ -2743,7 +2752,9 @@ void SCS_SHTRIHFRF::SetErrorMessage() else*/ if(ExtMethodsFlags & extmethfFNCheckItemBarcode) { const bool use_FNCheckItemBarcode2 = true; // Если false, то используем FNCheckItemBarcode - THROW(ConnectFR()); + if(!(Flags & sfCheckOpened)) { + THROW(ConnectFR()); + } // //THROW(SetFR(BarCode, pCode)); { diff --git a/Src/PPEquip/Synccash.cpp b/Src/PPEquip/Synccash.cpp index 5f1f3cb46..61fbc7684 100644 --- a/Src/PPEquip/Synccash.cpp +++ b/Src/PPEquip/Synccash.cpp @@ -140,7 +140,7 @@ class SCS_SYNCCASH : public PPSyncCashSession { enum DevFlags { sfConnected = 0x0001, // установлена связь с ККМ, COM-порт занят - sfOpenCheck = 0x0002, // чек открыт + sfCheckOpened = 0x0002, // чек открыт sfCancelled = 0x0004, // операция печати чека прервана пользователем sfPrintSlip = 0x0010, // печать подкладного документа sfDontUseCutter = 0x0020, // не использовать отрезчик чеков @@ -564,20 +564,20 @@ int SCS_SYNCCASH::AnnulateCheck() GetStatus(status); // Проверка на незавершенную печать if(status & PRNMODE_AFTER_NO_PAPER) { - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; THROW(ExecPrintOper(DVCCMD_CONTINUEPRINT, Arr_In.Z(), Arr_Out)); do { GetStatus(status); } while(status & PRNMODE_PRINT); - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; } // Проверка на наличие открытого чека, который надо аннулировать // @v10.1.0 GetStatus(status); if(status & FRMODE_OPEN_CHECK) { - Flags |= (sfOpenCheck | sfCancelled); + Flags |= (sfCheckOpened | sfCancelled); PPMessage(mfInfo|mfOK, PPINF_SHTRIHFR_CHK_ANNUL, 0); THROW(ExecPrintOper(DVCCMD_ANNULATE, Arr_In.Z(), Arr_Out)); - Flags &= ~(sfOpenCheck | sfCancelled); + Flags &= ~(sfCheckOpened | sfCancelled); ok = 1; } CATCHZOK @@ -590,7 +590,7 @@ int SCS_SYNCCASH::PrintFiscalCorrection(const PPCashMachine::FiscalCorrection * SString temp_buf; ResCode = RESCODE_NO_ERROR; THROW(Connect()); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; Arr_In.Z(); /* struct FiscalCorrection { @@ -662,7 +662,7 @@ int SCS_SYNCCASH::PrintFiscalCorrection(const PPCashMachine::FiscalCorrection * ok = 0; } ENDCATCH - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; return ok; } @@ -792,7 +792,7 @@ int SCS_SYNCCASH::PrintCheck(CCheckPacket * pPack, uint flags) PROFILE_END } } - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; for(P_SlipFmt->InitIteration(pPack); P_SlipFmt->NextIteration(line_buf, &sl_param) > 0;) { Arr_In.Z(); if(sl_param.Flags & SlipLineParam::fRegFiscal) { @@ -900,7 +900,7 @@ int SCS_SYNCCASH::PrintCheck(CCheckPacket * pPack, uint flags) THROW(PutPrescription(prescr)); // @v11.8.0 // @v11.9.3 (one call) THROW(ExecPrintOper(DVCCMD_PRINTFISCAL, Arr_In, Arr_Out)); PROFILE_END - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; prn_total_sale = 0; } else if(sl_param.Kind == sl_param.lkBarcode) { @@ -951,14 +951,14 @@ int SCS_SYNCCASH::PrintCheck(CCheckPacket * pPack, uint flags) THROW(ArrAdd(Arr_In, DVCPARAM_QUANTITY, 1L)); THROW(ArrAdd(Arr_In, DVCPARAM_PRICE, amt)); THROW(ExecPrintOper(DVCCMD_PRINTFISCAL, Arr_In, Arr_Out)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; running_total += amt; } else /*if(fiscal != 0.0)*/ { THROW(ArrAdd(Arr_In, DVCPARAM_QUANTITY, 1L)); THROW(ArrAdd(Arr_In, DVCPARAM_PRICE, _fiscal)); THROW(ExecPrintOper(DVCCMD_PRINTFISCAL, Arr_In, Arr_Out)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; running_total += _fiscal; } PROFILE_END @@ -992,7 +992,7 @@ int SCS_SYNCCASH::PrintCheck(CCheckPacket * pPack, uint flags) // Отдел THROW(ArrAdd(Arr_In, DVCPARAM_DEPARTMENT, (division > 16 || division < 0) ? 0 : division)); THROW(ExecPrintOper(DVCCMD_PRINTFISCAL, Arr_In, Arr_Out)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; } // Информация о скидке THROW(PrintDiscountInfo(pPack, flags)); @@ -1028,7 +1028,7 @@ int SCS_SYNCCASH::PrintCheck(CCheckPacket * pPack, uint flags) } // } @v11.3.6 THROW(ExecPrintOper(DVCCMD_CLOSECHECK, Arr_In, Arr_Out)); // Всегда закрываем чек - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; ErrCode = SYNCPRN_ERROR_AFTER_PRINT; Arr_In.Z(); THROW(ArrAdd(Arr_In, DVCPARAM_CHECKNUM, 0)); @@ -1048,14 +1048,14 @@ int SCS_SYNCCASH::PrintCheck(CCheckPacket * pPack, uint flags) if(ErrCode != SYNCPRN_ERROR_AFTER_PRINT) { SString no_print_txt; PPLoadText(PPTXT_CHECK_NOT_PRINTED, no_print_txt); - ErrCode = (Flags & sfOpenCheck) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; + ErrCode = (Flags & sfCheckOpened) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; PPLogMessage(PPFILNAM_SHTRIH_LOG, CCheckCore::MakeCodeString(&pPack->Rec, 0, no_print_txt), LOGMSGF_TIME|LOGMSGF_USER); ok = 0; } } else { SetErrorMessage(); - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ErrCode = SYNCPRN_ERROR_WHILE_PRINT; ok = 0; } @@ -1230,7 +1230,7 @@ int SCS_SYNCCASH::PrintReport(int withCleaning) int ok = 1; ResCode = RESCODE_NO_ERROR; THROW(Connect()); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; Arr_In.Z(); if(withCleaning) { THROW(ExecPrintOper(DVCCMD_ZREPORT, Arr_In, Arr_Out)); @@ -1248,7 +1248,7 @@ int SCS_SYNCCASH::PrintReport(int withCleaning) ok = 0; } ENDCATCH - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; return ok; } @@ -1641,7 +1641,7 @@ int SCS_SYNCCASH::PrintIncasso(double sum, int isIncome) ResCode = RESCODE_NO_ERROR; int ok = 1; THROW(Connect()); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; if(isIncome) { Arr_In.Z(); THROW(ArrAdd(Arr_In, DVCPARAM_CHECKTYPE, DEPOSITCHECK)); @@ -1672,7 +1672,7 @@ int SCS_SYNCCASH::PrintIncasso(double sum, int isIncome) ok = 0; } ENDCATCH - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; return ok; } @@ -1689,13 +1689,13 @@ int SCS_SYNCCASH::OpenBox() if(Flags & sfCancelled) { Flags &= ~sfCancelled; if(ErrCode != SYNCPRN_ERROR_AFTER_PRINT) { - ErrCode = (Flags & sfOpenCheck) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; + ErrCode = (Flags & sfCheckOpened) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; ok = 0; } } else { SetErrorMessage(); - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ErrCode = SYNCPRN_ERROR_WHILE_PRINT; ok = PPErrorZ(); } @@ -1747,7 +1747,7 @@ int SCS_SYNCCASH::AllowPrintOper() // @v10.1.0 (избыточная команда - выше была уже вызвана) GetStatus(status); if(status & NO_PAPER) { if(status & FRMODE_OPEN_CHECK) - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; while(status & NO_PAPER) { int send_msg = 0, r; PPSetError(PPERR_SYNCCASH_NO_CHK_RBN); diff --git a/Src/PPEquip/atoldrv.cpp b/Src/PPEquip/atoldrv.cpp index e5cfab8ae..67a8a145c 100644 --- a/Src/PPEquip/atoldrv.cpp +++ b/Src/PPEquip/atoldrv.cpp @@ -97,14 +97,14 @@ class SCS_ATOLDRV : public PPSyncCashSession { if(Flags & sfCancelled) { Flags &= ~sfCancelled; if(ErrCode != SYNCPRN_ERROR_AFTER_PRINT) { - ErrCode = (Flags & sfOpenCheck) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; + ErrCode = (Flags & sfCheckOpened) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; ok = 0; } } else { SetErrorMessage(); DoBeep(); - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ErrCode = SYNCPRN_ERROR_WHILE_PRINT; ok = 0; } @@ -775,7 +775,7 @@ class SCS_ATOLDRV : public PPSyncCashSession { enum AtolDrvFlags { sfConnected = 0x0001, // установлена связь с устройством, COM-порт занят - sfOpenCheck = 0x0002, // чек открыт + sfCheckOpened = 0x0002, // чек открыт sfCancelled = 0x0004, // операция печати чека прервана пользователем sfPrintSlip = 0x0008, // печать подкладного документа sfDontUseCutter = 0x0010, // не использовать отрезчик чеков @@ -887,7 +887,7 @@ SCS_ATOLDRV::~SCS_ATOLDRV() /*virtual*/int SCS_ATOLDRV::PreprocessChZnCode(int op, const char * pCode, double qtty, int uomId, uint uomFragm, CCheckPacket::PreprocessChZnCodeResult & rResult) // @v11.2.12 { - if(op == 0) { // Другие операции этот блок менять не должны! + if(op == ppchzcopCheck) { // Другие операции этот блок менять не должны! rResult.Z(); } int ok = 1; @@ -896,7 +896,7 @@ SCS_ATOLDRV::~SCS_ATOLDRV() StateBlock stb; THROW(Connect(&stb)); if(P_Fptr10 && P_Fptr10->IsValid() && P_Fptr10->ProcessJsonProc) { - if(op == 100) { // 100 - предварителные операции перед проверкой марок по чеку. Может быть актуально для некоторых типов регистраторов. + if(op == ppchzcopInit) { { SJson js(SJson::tOBJECT); js.InsertString("type", "cancelMarkingCodeValidation"); @@ -908,7 +908,7 @@ SCS_ATOLDRV::~SCS_ATOLDRV() THROW(CallJsonProc(&js, temp_buf)); } } - else if(op == 0) { // Проверка марки + else if(op == ppchzcopCheck) { { SJson js(SJson::tOBJECT); js.InsertString("type", "beginMarkingCodeValidation"); @@ -1068,12 +1068,12 @@ SCS_ATOLDRV::~SCS_ATOLDRV() } while(mcv_status < 0 && try_no < max_tries); } } - else if(op == 1) { // 1 - акцепт марки. должна быть вызвана непосредственно после вызова PreprocessChZnCode(0, ...) + else if(op == ppchzcopAccept) { SJson js(SJson::tOBJECT); js.InsertString("type", "acceptMarkingCode"); THROW(CallJsonProc(&js, temp_buf)); } - else if(op == 2) { // 2 - отказ от акцепта марки. должна быть вызвана непосредственно после вызова PreprocessChZnCode(0, ...) + else if(op == ppchzcopReject) { SJson js(SJson::tOBJECT); js.InsertString("type", "declineMarkingCode"); THROW(CallJsonProc(&js, temp_buf)); @@ -1392,7 +1392,7 @@ int SCS_ATOLDRV::AllowPrintOper(uint id) // (иначе при сбое операции открытия чека неизвестно: чек уже открыт или нет) THROW(GetProp(CheckState, &chk_state)); if(chk_state != CHKST_CLOSE) - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; // Ожидание заправки чековой ленты или выхода из режима, когда нельзя печатать чек while(ok && last_res_code == RESCODE_NOPAPER || (last_res_code == RESCODE_MODE_OFF && IsModeOffPrint(mode))) { int send_msg = 0, r = 0; @@ -2097,7 +2097,7 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetProp(CheckType, (flags & PRNCHK_RETURN) ? 2L : 1L)); THROW(ExecOper(OpenCheck)); } - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; debug_log_buf.Space().CatChar('{'); for(P_SlipFmt->InitIteration(pPack); P_SlipFmt->NextIteration(line_buf, &sl_param) > 0;) { if(sl_param.Flags & SlipLineParam::fRegFiscal) { @@ -2290,7 +2290,7 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetProp(Department, (sl_param.DivID > 16 || sl_param.DivID < 0) ? 0 : static_cast(sl_param.DivID))); THROW(ExecOper((flags & PRNCHK_RETURN) ? Return : Registration)); } - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; prn_total_sale = false; } else if(sl_param.Kind == sl_param.lkBarcode) { @@ -2378,7 +2378,7 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetProp(Price, pp)); THROW(ExecOper((flags & PRNCHK_RETURN) ? Return : Registration)); } - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; running_total += amt; } } @@ -2415,7 +2415,7 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) THROW(SetProp(Department, (division > 16 || division < 0) ? 0 : division)); THROW(ExecOper((flags & PRNCHK_RETURN) ? Return : Registration)); } - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; } // Информация о скидке THROW(PrintDiscountInfo(pPack, flags)); @@ -2450,7 +2450,7 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) THROW(ExecOper(CloseCheck)); THROW(Exec(ResetMode)); } - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; ErrCode = SYNCPRN_ERROR_AFTER_PRINT; if(!(Flags & sfDontUseCutter)) { CutPaper(0); @@ -2464,7 +2464,7 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) if(ErrCode != SYNCPRN_ERROR_AFTER_PRINT) { SString no_print_txt; PPLoadText(PPTXT_CHECK_NOT_PRINTED, no_print_txt); - ErrCode = (Flags & sfOpenCheck) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; + ErrCode = (Flags & sfCheckOpened) ? SYNCPRN_CANCEL_WHILE_PRINT : SYNCPRN_CANCEL; PPLogMessage(PPFILNAM_ATOLDRV_LOG, pPack ? CCheckCore::MakeCodeString(&pPack->Rec, 0, no_print_txt) : "", LOGMSGF_TIME|LOGMSGF_USER); ok = 0; } @@ -2472,17 +2472,17 @@ int SCS_ATOLDRV::PrintCheck(CCheckPacket * pPack, uint flags) else { SetErrorMessage(); DoBeep(); - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ErrCode = SYNCPRN_ERROR_WHILE_PRINT; PPLogMessage(PPFILNAM_ATOLDRV_LOG, 0, LOGMSGF_LASTERR_TIME_USER); ok = 0; } if(P_Fptr10) { - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) P_Fptr10->CancelReceiptProc(fph); } else if(P_Disp) { - if(Flags & sfOpenCheck) + if(Flags & sfCheckOpened) ExecOper(CancelCheck); Exec(ResetMode); } @@ -2552,7 +2552,7 @@ int SCS_ATOLDRV::PrintReport(int withCleaning) PPSyncCashSession::GetCurrentUserName(operator_name); operator_name.Transf(CTRANSF_INNER_TO_OUTER); // - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; if(P_Fptr10) { void * fph = P_Fptr10->Handler; //libfptr_set_param_str(fptr, 1021, L"Кассир Иванов И."); @@ -2591,8 +2591,8 @@ int SCS_ATOLDRV::PrintReport(int withCleaning) } ok = 0; ENDCATCH - if(Flags & sfOpenCheck) { - Flags &= ~sfOpenCheck; + if(Flags & sfCheckOpened) { + Flags &= ~sfCheckOpened; CashierPassword = cshr_pssw; } return ok; @@ -2673,7 +2673,7 @@ int SCS_ATOLDRV::PrintIncasso(double sum, int isIncome) else if(P_Disp) { THROW(SetProp(Mode, MODE_REGISTER)); THROW(ExecOper(SetMode)); - Flags |= sfOpenCheck; + Flags |= sfCheckOpened; THROW(SetProp(Summ, sum)); THROW(ExecOper(isIncome ? CashIncome : CashOutcome)); } @@ -2694,7 +2694,7 @@ int SCS_ATOLDRV::PrintIncasso(double sum, int isIncome) if(P_Disp) { THROW(Exec(ResetMode)); } - Flags &= ~sfOpenCheck; + Flags &= ~sfCheckOpened; return ok; } diff --git a/Src/PPEquip/frontol.cpp b/Src/PPEquip/frontol.cpp index d9ace3daf..88f7e60a6 100644 --- a/Src/PPEquip/frontol.cpp +++ b/Src/PPEquip/frontol.cpp @@ -618,6 +618,9 @@ int ACS_FRONTOL::ExportData(int updOnly) if(gds_info.ChZnProdType == GTCHZNPT_DRAFTBEER) { mark_type = 18; } + else if(gds_info.ChZnProdType == GTCHZNPT_BEER) { // @v12.0.4 + mark_type = 17; + } } // } @v11.9.3 tail.Cat(mark_type).Semicol(); // #55 Признак алкогольной продукции // @v11.9.3 1L-->mark_type diff --git a/Src/PPLib/Chkpan.cpp b/Src/PPLib/Chkpan.cpp index 4e3d0fdb0..d0622f451 100644 --- a/Src/PPLib/Chkpan.cpp +++ b/Src/PPLib/Chkpan.cpp @@ -7333,13 +7333,16 @@ IMPL_HANDLE_EVENT(CheckPaneDialog) if(InitCashMachine() && P_CM) { SString msg_buf; //PPChZnPrcssr::ReconstructOriginalChZnCode(const GtinStruc & rS, SString & rBuf) - int r = P_CM->SyncPreprocessChZnCode(0, /*mark*/reconstructed_original, 1.0, 0/*uomId*/, 0, chzn_result); - msg_buf.CatEq("SyncPreprocessChZnCode-result", r).CR(); - msg_buf.CatEq("check-result", chzn_result.CheckResult).CR(); - msg_buf.CatEq("reason", chzn_result.Reason).CR(); - msg_buf.CatEq("processing-result", chzn_result.ProcessingResult).CR(); - msg_buf.CatEq("processing-code", chzn_result.ProcessingCode).CR(); - msg_buf.CatEq("status", chzn_result.Status).CR(); + if(P_CM->SyncPreprocessChZnCode(PPSyncCashSession::ppchzcopInit, /*mark*/reconstructed_original, 1.0, 0/*uomId*/, 0, chzn_result)) { + int r = P_CM->SyncPreprocessChZnCode(PPSyncCashSession::ppchzcopCheck, /*mark*/reconstructed_original, 1.0, 0/*uomId*/, 0, chzn_result); + P_CM->SyncPreprocessChZnCode(PPSyncCashSession::ppchzcopCancel, /*mark*/reconstructed_original, 1.0, 0/*uomId*/, 0, chzn_result); + msg_buf.CatEq("SyncPreprocessChZnCode-result", r).CR(); + msg_buf.CatEq("check-result", chzn_result.CheckResult).CR(); + msg_buf.CatEq("reason", chzn_result.Reason).CR(); + msg_buf.CatEq("processing-result", chzn_result.ProcessingResult).CR(); + msg_buf.CatEq("processing-code", chzn_result.ProcessingCode).CR(); + msg_buf.CatEq("status", chzn_result.Status).CR(); + } PPChZnPrcssr::InputMark(mark, &reconstructed_original, msg_buf); } } diff --git a/Src/PPLib/Cshses.cpp b/Src/PPLib/Cshses.cpp index e7313d63b..44966d727 100644 --- a/Src/PPLib/Cshses.cpp +++ b/Src/PPLib/Cshses.cpp @@ -157,7 +157,7 @@ int PPSyncCashSession::PreprocessCCheckForOfd12(const OfdFactors & rOfdf, CCheck int pczcr_pre = 0; { CCheckPacket::PreprocessChZnCodeResult chzn_pp_result; - pczcr_pre = PreprocessChZnCode(100, chzn_code, 1.0, 0/*uomId*/, 0, chzn_pp_result); + pczcr_pre = PreprocessChZnCode(ppchzcopInit, chzn_code, 1.0, 0/*uomId*/, 0, chzn_pp_result); } if(pczcr_pre != 0) { for(uint pos = 0; pPack->EnumLines(&pos, &ccl) > 0;) { @@ -170,12 +170,12 @@ int PPSyncCashSession::PreprocessCCheckForOfd12(const OfdFactors & rOfdf, CCheck double ratio = 0.0; if(goods_obj.TranslateGoodsUnitToBase(goods_rec, SUOM_LITER, &ratio) > 0) { double chzn_qtty = fabs(ccl.Quantity) * ratio; - int pczcr = PreprocessChZnCode(101, chzn_code, chzn_qtty, SUOM_LITER, uom_fragm, chzn_pp_result); + int pczcr = PreprocessChZnCode(ppchzcopSurrogateCheck, chzn_code, chzn_qtty, SUOM_LITER, uom_fragm, chzn_pp_result); // @v11.9.10 { if(/*pczcr > 0*/true) { if(/*chzn_pp_result.Status == 1*/true) { chzn_pp_result.LineIdx = pos; - int accept_op = 1; // 1 - accept, 2 - reject + const int accept_op = ppchzcopAccept; pczcr = PreprocessChZnCode(accept_op, chzn_code, chzn_qtty, 0/*uomId*/, uom_fragm, chzn_pp_result); PPSyncCashSession::LogPreprocessChZnCodeResult(pczcr, accept_op, chzn_code, chzn_qtty, chzn_pp_result); // @v11.2.3 if(pczcr > 0) @@ -184,7 +184,7 @@ int PPSyncCashSession::PreprocessCCheckForOfd12(const OfdFactors & rOfdf, CCheck else { ok = 2; chzn_pp_result.LineIdx = pos; - int accept_op = 2; // 1 - accept, 2 - reject + const int accept_op = ppchzcopReject; pczcr = PreprocessChZnCode(accept_op, chzn_code, chzn_qtty, 0/*uomId*/, uom_fragm, chzn_pp_result); PPSyncCashSession::LogPreprocessChZnCodeResult(pczcr, accept_op, chzn_code, chzn_qtty, chzn_pp_result); // @v11.2.3 // @v11.7.0 if(pczcr > 0) @@ -206,7 +206,7 @@ int PPSyncCashSession::PreprocessCCheckForOfd12(const OfdFactors & rOfdf, CCheck PPUnit u_rec; if(goods_obj.FetchUnit(goods_rec.UnitID, &u_rec) > 0 && u_rec.Fragmentation > 0 && u_rec.Fragmentation < 100000) uom_fragm = u_rec.Fragmentation; - int pczcr = PreprocessChZnCode(0, chzn_code, chzn_qtty, 0/*uomId*/, uom_fragm, chzn_pp_result); + int pczcr = PreprocessChZnCode(ppchzcopCheck, chzn_code, chzn_qtty, 0/*uomId*/, uom_fragm, chzn_pp_result); PPSyncCashSession::LogPreprocessChZnCodeResult(pczcr, 0, chzn_code, chzn_qtty, chzn_pp_result); // @debug { //pczcr = 0; @@ -215,7 +215,7 @@ int PPSyncCashSession::PreprocessCCheckForOfd12(const OfdFactors & rOfdf, CCheck if(pczcr > 0) { if(chzn_pp_result.Status == 1) { chzn_pp_result.LineIdx = pos; - int accept_op = 1; // 1 - accept, 2 - reject + const int accept_op = ppchzcopAccept; pczcr = PreprocessChZnCode(accept_op, chzn_code, chzn_qtty, 0/*uomId*/, uom_fragm, chzn_pp_result); PPSyncCashSession::LogPreprocessChZnCodeResult(pczcr, accept_op, chzn_code, chzn_qtty, chzn_pp_result); // @v11.2.3 if(pczcr > 0) @@ -224,7 +224,7 @@ int PPSyncCashSession::PreprocessCCheckForOfd12(const OfdFactors & rOfdf, CCheck else { ok = 2; chzn_pp_result.LineIdx = pos; - int accept_op = 2; // 1 - accept, 2 - reject + const int accept_op = ppchzcopReject; pczcr = PreprocessChZnCode(accept_op, chzn_code, chzn_qtty, 0/*uomId*/, uom_fragm, chzn_pp_result); PPSyncCashSession::LogPreprocessChZnCodeResult(pczcr, accept_op, chzn_code, chzn_qtty, chzn_pp_result); // @v11.2.3 // @v11.7.0 if(pczcr > 0) diff --git a/Src/PPTEST/DATA/chzn-marks.txt b/Src/PPTEST/DATA/chzn-marks.txt index 1d9083793..ac2bdf6d6 100644 --- a/Src/PPTEST/DATA/chzn-marks.txt +++ b/Src/PPTEST/DATA/chzn-marks.txt @@ -1,3 +1,6 @@ +010464009192047221PlMZXSi800514000093b8yd +010464009192047221zNOsKU:800514000093Q4wR +010464009192047221aiV0 #pragma hdrstop -/*static*/uint64 SRecPageManager::MakeRowId(uint pageSize, uint pageSeq, uint offset) +/*static*/uint SRecPageManager::Helper_SplitRowId_GetOffsetBits(uint64 rowId, uint pageSize) { - uint64 result = 0; - const uint bits_offs = (32 - SBits::Clz(pageSize)) + 1; - const uint bits_page = RowIdBitWidth - bits_offs; - assert((1ULL << bits_offs) >= pageSize); - if(pageSeq == 0) { - ; // @error - } - else if(pageSeq >= (1ULL << bits_page)) { - ; // @error - } - else if(offset >= (1ULL << bits_offs)) { - ; // @error - } - else if(offset >= pageSize) { - ; // @error + uint result = 0U; + const uint pobw = static_cast((rowId >> (RowIdBitWidth-4)) & 0xFULL) + 9; + THROW(pobw >= 9 && (pobw - 9) < 16); // @todo @err + if(pageSize > 0) { + result = SBits::CeilLog2(pageSize);//(32 - SBits::Clz(pageSize)) - 1; + THROW(result == pobw); // @todo @err } else { - result = (static_cast(pageSeq) << bits_offs) | (static_cast(offset)); + result = pobw; } + CATCH + result = 0U; + ENDCATCH return result; } -/*static*/int SRecPageManager::SplitRowId(uint64 rowId, uint pageSize, uint * pPageSeq, uint * pOffset) +/*static*/uint64 SRecPageManager::MakeRowId(uint pageSize, uint pageSeq, uint offset) +{ + assert(pageSize >= 512); + assert((pageSize % 512) == 0); + uint64 result = 0; + const uint bits_offs = SBits::CeilLog2(pageSize); //(32 - SBits::Clz(pageSize)) - 1; // pobw + const uint bits_page = GetPageBits(bits_offs); + assert((1ULL << bits_offs) >= pageSize); + assert(bits_offs >= 9); + assert((bits_offs - 9) < 16); + THROW(pageSeq > 0); // @todo @err + THROW(pageSeq < (1ULL << bits_page)); // @todo @err + THROW(offset < (1ULL << bits_offs)); // @todo @err + THROW(offset < pageSize); // @todo @err + result = (static_cast(bits_offs - 9) << (RowIdBitWidth-4) | (static_cast(pageSeq) << bits_offs) | (static_cast(offset))); + CATCH + result = 0ULL; + ENDCATCH + return result; +} + +/*static*/int SRecPageManager::SplitRowId_WithPageSizeCheck(uint64 rowId, uint pageSize, uint * pPageSeq, uint * pOffset) { int ok = 1; - const uint bits_offs = (32 - SBits::Clz(pageSize)) + 1; - const uint bits_page = RowIdBitWidth - bits_offs; - constexpr uint64 seq_mask = (~0ULL >> (64-RowIdBitWidth)); - const uint64 ofs_mask = (~0ULL >> (64-bits_offs)); - uint page_seq = static_cast((rowId & seq_mask) >> bits_offs); - uint offset = static_cast(rowId & ofs_mask); - ASSIGN_PTR(pPageSeq, page_seq); - ASSIGN_PTR(pOffset, offset); - if(page_seq == 0) { - ok = 0; // @error - } - else if(page_seq >= (1ULL << bits_page)) { - ok = 0; // @error - } - else if(offset >= (1ULL << bits_offs)) { - ok = 0; // @error - } - else if(offset >= pageSize) { - ok = 0; // @error + const uint bits_offs = Helper_SplitRowId_GetOffsetBits(rowId, pageSize); + THROW(bits_offs); + { + const uint bits_page = GetPageBits(bits_offs); + constexpr uint64 seq_mask = (~0ULL >> (64-(RowIdBitWidth-4))); + const uint64 ofs_mask = (~0ULL >> (64-bits_offs)); + const uint page_seq = static_cast((rowId & seq_mask) >> bits_offs); + const uint offset = static_cast(rowId & ofs_mask); + ASSIGN_PTR(pPageSeq, page_seq); + ASSIGN_PTR(pOffset, offset); + THROW(page_seq > 0); // @todo @err + THROW(page_seq < (1ULL << bits_page)); // @todo @err + THROW(offset < (1ULL << bits_offs)); // @todo @err + THROW(offset < pageSize); // @todo @err } + CATCHZOK return ok; } + +/*static*/int SRecPageManager::SplitRowId(uint64 rowId, uint * pPageSeq, uint * pOffset) +{ + return SplitRowId_WithPageSizeCheck(rowId, 0, pPageSeq, pOffset); +} + SRecPageManager::SRecPageManager(uint32 pageSize) : PageSize(pageSize), LastSeq(0) { } @@ -62,46 +79,52 @@ SRecPageManager::~SRecPageManager() { } -int SRecPageManager::Write(uint64 * pRowId, uint pageType, const void * pData, size_t dataLen) +int SRecPageManager::WriteToPage(SDataPageHeader * pPage, uint64 rowId, const void * pData, size_t dataLen) { int ok = 1; - SDataPageHeader::RecPrefix pfx; - pfx.SetPayload(dataLen, 0); - SDataPageHeader * p_page = 0;//QueryPageForWriting(pageType, dataLen); - const SRecPageFreeList::Entry * p_free_entry = 0; + uint seq = 0; uint offset = 0; - //SDataPageHeader * SRecPageManager::QueryPageForWriting(uint32 pageType, uint32 reqSize) + THROW(pPage); + THROW(SRecPageManager::SplitRowId(rowId, &seq, &offset)); + assert(seq == pPage->Seq); // ! { - //SDataPageHeader * p_result = 0; - p_free_entry = Fl.Get(pageType, dataLen); - if(!p_free_entry) { - SDataPageHeader * p_new_page = AllocatePage(pageType); - if(p_new_page) { - p_free_entry = Fl.Get(pageType, dataLen); - //assert(p_free_entry->Seq == p_new_page->Seq); - } - } - uint seq = 0; - if(p_free_entry && SRecPageManager::SplitRowId(p_free_entry->RowId, PageSize, &seq, &offset)) { - p_page = GetPage(seq); - } - //return p_result; - } - if(p_page) { SRecPageFreeList::Entry new_free_entry; - assert(offset >= sizeof(*p_page) && offset < p_page->TotalSize); - uint64 rowid = p_page->Write(offset, pData, dataLen, &new_free_entry); - if(rowid) { - assert(rowid == p_free_entry->RowId); - Fl.Remove(pageType, rowid); - if(new_free_entry.RowId && new_free_entry.FreeSize > 3) { - Fl.Put(pageType, p_page->Seq, new_free_entry.FreeSize); - } - ASSIGN_PTR(pRowId, rowid); + assert(offset >= sizeof(*pPage) && offset < pPage->TotalSize); + uint64 post_write_rowid = pPage->Write(offset, pData, dataLen, &new_free_entry); + THROW(post_write_rowid); + assert(post_write_rowid == rowId); + Fl.Remove(pPage->Type, post_write_rowid); + if(new_free_entry.RowId && new_free_entry.FreeSize > 3) { + Fl.Put(pPage->Type, pPage->Seq, new_free_entry.FreeSize); } - else - ok = 0; } + CATCHZOK + return ok; +} + +int SRecPageManager::Write(uint64 * pRowId, uint pageType, const void * pData, size_t dataLen) +{ + int ok = 1; + //SDataPageHeader::RecPrefix pfx; + //pfx.SetPayload(dataLen, 0); + SDataPageHeader * p_page = 0;//QueryPageForWriting(pageType, dataLen); + uint seq = 0; + uint offset = 0; + const SRecPageFreeList::Entry * p_free_entry = Fl.Get(pageType, dataLen); + if(!p_free_entry) { + SDataPageHeader * p_new_page = AllocatePage(pageType); + if(p_new_page) { + p_free_entry = Fl.Get(pageType, dataLen); + //assert(p_free_entry->Seq == p_new_page->Seq); + } + } + THROW(p_free_entry); + THROW(SRecPageManager::SplitRowId(p_free_entry->RowId, &seq, &offset)); + THROW(p_page = GetPage(seq)); + THROW(p_page->Seq == seq); // @todo @err + THROW(WriteToPage(p_page, p_free_entry->RowId, pData, dataLen)); + ASSIGN_PTR(pRowId, p_free_entry->RowId); + CATCHZOK return ok; } @@ -154,7 +177,7 @@ SDataPageHeader * SRecPageManager::QueryPageForReading(uint64 rowId, uint32 page uint ofs = 0; if(rowId) { uint seq = 0; - if(SplitRowId(rowId, PageSize, &seq, &ofs)) { + if(SplitRowId(rowId, &seq, &ofs)) { p_result = GetPage(seq); if(p_result && pageType && p_result->Type != pageType) { ReleasePage(p_result); @@ -686,7 +709,9 @@ const SRecPageFreeList::Entry * SRecPageFreeList::Get(uint32 type, uint32 reqSiz { SDataPageHeader::Stat stat; TSVector free_list; - THROW(p_page->GetStat(stat, &free_list)); + while(false) { + THROW(p_page->GetStat(stat, &free_list)); + } } CATCHZOK return ok;