static void DB_payout_rpt(void) { uint8 temp; uint32 changedAmount,temp32; uint32 billPayAmount; uint32 coinPayAmount = 0; memset(sendbuf,0,sizeof(sendbuf)); sendbuf[MT + 1] = recvbuf[MT + 1]; sendbuf[MT + 2] = recvbuf[MT + 2]; temp = recvbuf[MT + 2]; billPayAmount = INTEG32(recvbuf[MT + 3],recvbuf[MT + 4], recvbuf[MT + 5],recvbuf[MT + 6]); coinPayAmount = INTEG32(recvbuf[MT + 7],recvbuf[MT + 8], recvbuf[MT + 9],recvbuf[MT + 10]); if(temp & OBJ_BILL){ changedAmount = MDB_bill_payout(billPayAmount); sendbuf[MT + 3] = H0UINT32(changedAmount); sendbuf[MT + 4] = H1UINT32(changedAmount); sendbuf[MT + 5] = L0UINT32(changedAmount); sendbuf[MT + 6] = L1UINT32(changedAmount); } if(temp & OBJ_COIN){ changedAmount = MDB_coin_payout(coinPayAmount); //coinchanged sendbuf[MT + 7] = H0UINT32(changedAmount); sendbuf[MT + 8] = H1UINT32(changedAmount); sendbuf[MT + 9] = L0UINT32(changedAmount); sendbuf[MT + 10] = L1UINT32(changedAmount); } //billamount temp32 = MDB_getBillRecvAmount(); sendbuf[MT + 11] = H0UINT32(temp32); sendbuf[MT + 12] = H1UINT32(temp32); sendbuf[MT + 13] = L0UINT32(temp32); sendbuf[MT + 14] = L1UINT32(temp32); //coinAmount temp32 = MDB_getCoinRecvAmount(); sendbuf[MT + 15] = H0UINT32(temp32); sendbuf[MT + 16] = H1UINT32(temp32); sendbuf[MT + 17] = L0UINT32(temp32); sendbuf[MT + 18] = L1UINT32(temp32); DB_package(DB_MT_ACTION_RPT,MT + 19); DB_uart1Send(); }
static void DB_cost_rpt(void) { uint8 temp; uint32 costAmount = 0,temp32; memset(sendbuf,0,sizeof(sendbuf)); sendbuf[MT + 1] = recvbuf[MT + 1]; sendbuf[MT + 2] = recvbuf[MT + 2]; temp = recvbuf[MT + 2] ; temp = temp; costAmount = INTEG32(recvbuf[MT + 3],recvbuf[MT + 4], recvbuf[MT + 5],recvbuf[MT + 6]); costAmount = MDB_billCost(costAmount); //先扣纸币器 costAmount = MDB_coinCost(costAmount);// 再扣硬币器 //billamount temp32 = MDB_getBillRecvAmount(); sendbuf[MT + 3] = H0UINT32(temp32); sendbuf[MT + 4] = H1UINT32(temp32); sendbuf[MT + 5] = L0UINT32(temp32); sendbuf[MT + 6] = L1UINT32(temp32); //coinAmount temp32 = MDB_getCoinRecvAmount(); sendbuf[MT + 7] = H0UINT32(temp32); sendbuf[MT + 8] = H1UINT32(temp32); sendbuf[MT + 9] = L0UINT32(temp32); sendbuf[MT + 10] = L1UINT32(temp32); DB_package(DB_MT_ACTION_RPT,MT + 11); DB_uart1Send(); }
/* * Class: com_easivend_evprotocol_VboxProtocol * Method: EV_portRegister * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_com_easivend_evprotocol_VboxProtocol_VboxReadMsg (JNIEnv *env, jclass cls, jint fd, jint timeout) { jstring msg; char *text = NULL; cJSON *root,*entry,*jsonarr,*jsonobj; VBOX_MSG *vmsg; unsigned char *buf,in,temp8,temp81,textbuf[32],i; vmsg = VBOX_readMsg(fd,(uint32)timeout); root=cJSON_CreateObject(); entry = cJSON_CreateObject(); cJSON_AddItemToObject(root, JSON_HEAD,entry); cJSON_AddNumberToObject(entry,JSON_TYPE,VBOX_TYPE); if(vmsg == NULL){ cJSON_AddNumberToObject(entry,"mt",VBOX_TIMEOUT); } else{ cJSON_AddNumberToObject(entry,"port",vmsg->port); if(vmsg->res == 0){ cJSON_AddNumberToObject(entry,"mt",VBOX_TIMEOUT); } else if(vmsg->res == 1){ cJSON_AddNumberToObject(entry,"mt",vmsg->mt); cJSON_AddNumberToObject(entry,"sn",vmsg->sn); cJSON_AddNumberToObject(entry,"ver",vmsg->ver); cJSON_AddNumberToObject(entry,"F7",vmsg->F7); buf = (unsigned char *)vmsg->recvbuf;in = 5; switch(vmsg->mt){ case VBOX_POLL:case VBOX_ACK_RPT:case VBOX_NAK_RPT: in = 5; break; case VBOX_VMC_SETUP: cJSON_AddNumberToObject(entry,"hd_num",buf[in++]); cJSON_AddNumberToObject(entry,"pos_num",buf[in++]); cJSON_AddNumberToObject(entry,"magic1",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"scale_factor",buf[in++]); cJSON_AddNumberToObject(entry,"decimal_places",buf[in++]); cJSON_AddNumberToObject(entry,"feature",INTEG32(buf[in + 0],buf[in + 1],buf[in + 2],buf[in + 3])); in += 4; break; case VBOX_PAYIN_RPT: cJSON_AddNumberToObject(entry,"dt",buf[in++]); cJSON_AddNumberToObject(entry,"value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; break; case VBOX_PAYOUT_RPT: cJSON_AddNumberToObject(entry,"device",buf[in++]); cJSON_AddNumberToObject(entry,"value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"type",buf[in++]); break; case VBOX_VENDOUT_RPT: cJSON_AddNumberToObject(entry,"device",buf[in++]); cJSON_AddNumberToObject(entry,"status",buf[in++]); cJSON_AddNumberToObject(entry,"hd_id",buf[in++]); cJSON_AddNumberToObject(entry,"type",buf[in++]); cJSON_AddNumberToObject(entry,"cost",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"huodao",buf[in++]); break; case VBOX_REQUEST: temp8 = buf[in++]; cJSON_AddNumberToObject(entry,"type",temp8); break; case VBOX_ADMIN_RPT: temp8 = buf[in++]; cJSON_AddNumberToObject(entry,"type",temp8); if(temp8 == 2){ cJSON_AddNumberToObject(entry,"data1",buf[in++]); cJSON_AddNumberToObject(entry,"data2",buf[in++]); } break; case VBOX_ACTION_RPT: temp8 = buf[in++]; cJSON_AddNumberToObject(entry,"action",temp8); if(temp8 == 1){ cJSON_AddNumberToObject(entry,"seconds",buf[in++]); cJSON_AddNumberToObject(entry,"hd_id",buf[in++]); cJSON_AddNumberToObject(entry,"type",buf[in++]); cJSON_AddNumberToObject(entry,"cost",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; } else if(temp8 == 2){ cJSON_AddNumberToObject(entry,"seconds",buf[in++]); cJSON_AddNumberToObject(entry,"value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"type",buf[in++]); } else if(temp8 == 5){ cJSON_AddNumberToObject(entry,"value",buf[in++]); } break; case VBOX_BUTTON_RPT: temp8 = buf[in++]; cJSON_AddNumberToObject(entry,"type",temp8); if(temp8 == 0 || temp8 == 4){ cJSON_AddNumberToObject(entry,"value",buf[in++]); } else if(temp8 == 1 || temp8 == 2){ cJSON_AddNumberToObject(entry,"device",buf[in++]); cJSON_AddNumberToObject(entry,"value",buf[in++]); } break; case VBOX_STATUS_RPT: temp8 = buf[in++]; cJSON_AddNumberToObject(entry,"check_st",(temp8 >> 6) & 0x03); cJSON_AddNumberToObject(entry,"bv_st",(temp8 >> 4) & 0x03); cJSON_AddNumberToObject(entry,"cc_st",(temp8 >> 2) & 0x03); cJSON_AddNumberToObject(entry,"vmc_st",(temp8 >> 0) & 0x03); cJSON_AddNumberToObject(entry,"post_st",buf[in++]); cJSON_AddNumberToObject(entry,"change",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"tem1",buf[in++]); cJSON_AddNumberToObject(entry,"tem2",buf[in++]); cJSON_AddNumberToObject(entry,"tem3",buf[in++]); cJSON_AddNumberToObject(entry,"tem4",buf[in++]); cJSON_AddNumberToObject(entry,"tem_st",buf[in++]); cJSON_AddNumberToObject(entry,"auto_payout",buf[in++]); break; case VBOX_HUODAO_RPT: cJSON_AddNumberToObject(entry,"device",buf[in++]); temp8 = 5 + 1 + 2; temp8 = vmsg->recvlen > temp8 ?vmsg->recvlen - temp8: 0; cJSON_AddItemToObject(entry,"huodao",jsonarr = cJSON_CreateArray()); for(i = 0;i < temp8;i++){ cJSON_AddItemToArray(jsonarr,jsonobj = cJSON_CreateObject()); cJSON_AddNumberToObject(jsonobj,"no",i + 1); temp81 = buf[in++]; cJSON_AddNumberToObject(jsonobj,"state",(temp81 & (0x01 << 6)) ? 1 : 0); cJSON_AddNumberToObject(jsonobj,"remain",(temp81 & 0x3F)); } break; case VBOX_COST_RPT: cJSON_AddNumberToObject(entry,"device",buf[in++]); cJSON_AddNumberToObject(entry,"value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"type",buf[in++]); break; case VBOX_INFO_RPT: temp8 = buf[in++]; cJSON_AddNumberToObject(entry,"type",temp8); if(temp8 == 3){ cJSON_AddNumberToObject(entry,"total_value",INTEG16(buf[in+0],buf[in+1]));in+=2; } else if(temp8 == 4){ temp8 = 0; } else if(temp8 == 5){ cJSON_AddNumberToObject(entry,"year",INTEG16(buf[in+0],buf[in+1]));in+=2; cJSON_AddNumberToObject(entry,"month",buf[in++]); cJSON_AddNumberToObject(entry,"day",buf[in++]); cJSON_AddNumberToObject(entry,"hour",buf[in++]); cJSON_AddNumberToObject(entry,"min",buf[in++]); cJSON_AddNumberToObject(entry,"sec",buf[in++]); cJSON_AddNumberToObject(entry,"xq",buf[in++]); } else if(temp8 == 6){ temp8 = 0; } else if(temp8 == 10){ temp8 = 0; cJSON_AddNumberToObject(entry,"device",buf[in++]); temp8 = 5 + 1 + 1 + 2; temp8 = vmsg->recvlen > temp8 ?vmsg->recvlen - temp8: 0; cJSON_AddItemToObject(entry,"sp_id",jsonarr = cJSON_CreateArray()); for(i = 0;i < temp8;i++){ cJSON_AddItemToArray(jsonarr,jsonobj = cJSON_CreateObject()); //cJSON_AddNumberToObject(jsonobj,"no",i + 1); //cJSON_AddNumberToObject(jsonobj,"sp_id",buf[in++]); cJSON_AddNumberToObject(jsonobj,"id",buf[in++]); } } else if(temp8 == 12){ temp8 = 0; cJSON_AddNumberToObject(entry,"device",buf[in++]); temp8 = 5 + 1 + 1 + 2; temp8 = vmsg->recvlen > temp8 ?vmsg->recvlen - temp8: 0; cJSON_AddItemToObject(entry,"sp_price",jsonarr = cJSON_CreateArray()); for(i = 0;i < (temp8 / 2);i++){ cJSON_AddItemToArray(jsonarr,jsonobj = cJSON_CreateObject()); //cJSON_AddNumberToObject(jsonobj,"no",i + 1); //cJSON_AddNumberToObject(jsonobj,"sp_price",INTEG16(buf[in + 0],buf[in + 1]));in += 2; cJSON_AddNumberToObject(jsonobj,"id",INTEG16(buf[in + 0],buf[in + 1]));in += 2; } } else{ temp8 = 0; } break; default:break; } } else{