⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rx_init.c

📁 中国石油二期加油站IC系统后台通讯软件
💻 C
字号:
/*
***********************************************************************************************************
													  Amos
										  The Real_Time Operation System
												   Multi Task
								 (c) Copyright 1998-2002, ShangYaoHui, Shenzhen
											  All Right Reserved
												  VERSION 6.01

" By  : 商耀挥(ShangYaoHui)
 create time: 2002-7-2 23:08:43  
***********************************************************************************************************
*/

/************ head file list *************/
/* header include files -- defines (.h) */
#include "envopt.h"        /* environment options */
#include "envdep.h"        /* environment dependent */
#include "envind.h"        /* environment independent */

#include "gen.h"           /* general */
#include "cm5.h"           /* common functions */
#include "ssi.h"           /* system services */

/* header/extern include files (.x) */

#include "gen.x"           /* general */
#include "cm5.x"           /* common functions */
#include "ssi.x"           /* system services */

#include "cm_llist.h"
#include "cm_llist.x"

#ifdef WIN32
	#include "winbase.h"
#endif

#include "rx.h"
#include "rx.x"

#include "rx_msg.h"
#include "rx_msg.x"

#include "lb.h"
#include "lb.x"

#include "lb_cm.h"
#include "lb_cm.x"



#include "lb_recv.h"
#include "lb_recv.x"
#include "lb_xmit.h"
#include "lb_xmit.x"
#include "lb_msg.h"
#include "lb_msg.x"

#include "lb_bdy1.h"
#include "lb_bdy1.x"
#include "lb_bdy2.h"
#include "lb_bdy2.x"
#include "lb_bdy4.h"
#include "lb_bdy3.h"
#include "lb_bdy3.x"
#include "lb_bdy4.h"
#include "lb_bdy4.h"
#include "lb_bdy4.x"
#include "lb_bdy5.h"
#include "lb_bdy5.x"

/************* const define **************/

/******** import variable declare ********/

/******* gloable variable declare ********/

U8	g_oilTypeMap[OILTYPE_NUM] =
{
	90, 
	93,
	97,
	100,
	110,
	120,
	135,
	190,
	193,
	197
} ;


RxCb_s rxCb;
/*********** function declare ************/
S16 rxWndInit(HINSTANCE hInstance, HINSTANCE hPreInstance);
extern S16 AlActvTsk(Pst * pst, Buffer * mbuf);

/********** function prototype ***********/

S16 rxInit(HINSTANCE hInstance, HINSTANCE hPreInstance)
{
	RxCmdEntry_s * entry;
	TranCb_s * tran;
	FILE * priceFile;
	U8 buf[2];

	SInit();


	rxWndInit(hInstance, hPreInstance);
 /* modify by shang 2002-7-14 23:17:49 */
 #if 0 /* last code */
	rxCb.machNum = getMachNum();

	if(ROK != SGetSBuf(0, 0, (Data**)&rxCb.machTbl, sizeof(MachCb_s) * rxCb.machNum))
	{
		RXLOGERROR(0, 0, 0, "error");
		RETVALUE(RFAILED);
	}
	lbTmrInit();
	SRegActvTsk(ENTLB, 0, TTNORM, PRIOR0, LbActvTsk);
	SRegTmr(ENTLB, 0, 1, lbTmrHandle);

	for(machId = 0; machId < rxCb.machNum; machId++)
	{
		rxCb.machTbl[machId].scCommCb = getScCommCb(machId);
		rxCb.machTbl[machId].sideNum = getSideNum(machId);

		rxCb.machTbl[machId].indTmr.tmr.tmrEvnt = TMR_NONE;
		rxCb.machTbl[machId].rqstTmr.tmr.tmrEvnt = TMR_NONE;
		rxCb.machTbl[machId].queryTmr.tmr.tmrEvnt = TMR_NONE;


		for(sideId = 0 ; sideId < rxCb.machTbl[machId].sideNum; sideId++)
		{
			rxCb.machTbl[machId].machSide[sideId].crrntGunId = 0xff;
			rxCb.machTbl[machId].machSide[sideId].sideStat = -1;
			rxCb.machTbl[machId].machSide[sideId].gunNum = getGunNum(machId);
			if(ROK != SGetSBuf(0, 0, (Data**)&rxCb.machTbl[machId].machSide[sideId].gunCbTbl, sizeof(GunCb_s) * rxCb.machTbl[machId].machSide[sideId].gunNum))
			{
				RXLOGERROR(0, 0, 0, "error");
				RETVALUE(RFAILED);
			}
			for(gunId = 0; gunId < rxCb.machTbl[machId].machSide[sideId].gunNum; gunId++)
			{
				rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].oilType = 
				getOilType(machId, (U8)sideId, (U8)gunId);   

				rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].gunId = gunId;

				rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].crrntPrice = 
				getPrice(rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].oilType);

				rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].lastPrice = 
				rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].crrntPrice;

				rxCb.machTbl[machId].machSide[sideId].gunCbTbl[gunId].gunStat = GUN_DOWN;
			}
		}

		lbSchdTmr(machId, QUERY_TMR_INTERVAL, QUERY_TMR, START_TMR);

	}


#if 0
	SRegActvTsk(ENTSC, 0, TTPERM, PRIOR0, ScRecvActvTsk);
	SRegActvTsk(ENTSC, 1, TTNORM, PRIOR0, ScXmitActvTsk);

	SRegActvTsk(ENTLB, 0, TTNORM, PRIOR0, LbActvTsk);

	SRegActvTsk(ENTAL, 0, TTPERM, PRIOR0, AlIndActvTsk);
	SRegActvTsk(ENTAL, 1, TTPERM, PRIOR0, AlReqActvTsk);
#endif
 #else /* new code */
 	cmLListInit(&rxCb.pEquCfgList);
	cmLListInit(&rxCb.rqstList);

	memset(&rxCb, 0, sizeof(RxCb_s ));
	rxCb.indTmr.tmr.tmrEvnt = TMR_NONE;
	rxCb.queryTmr.tmr.tmrEvnt = TMR_NONE;
	rxCb.rqstTmr.tmr.tmrEvnt = TMR_NONE;
	
	rxCb.tranKeyTbl[0][0] = 0x7d;
	rxCb.tranKeyTbl[0][1] = 0x37;
	rxCb.tranKeyTbl[0][2] = 0x12;
	rxCb.tranKeyTbl[0][3] = 0xfc;
	rxCb.tranKeyTbl[0][4] = 0xee;
	rxCb.tranKeyTbl[0][5] = 0x4b;
	rxCb.tranKeyTbl[0][6] = 0x8d;
	rxCb.tranKeyTbl[0][7] = 0x08;
	rxCb.tranKeyTbl[0][8] = 0x24;
	rxCb.tranKeyTbl[0][9] = 0x27;
	rxCb.tranKeyTbl[0][10] = 0x22;
	rxCb.tranKeyTbl[0][11] = 0xfb;
	rxCb.tranKeyTbl[0][12] = 0x77;
	rxCb.tranKeyTbl[0][13] = 0x1b;
	rxCb.tranKeyTbl[0][14] = 0x22;
	rxCb.tranKeyTbl[0][15] = 0xc8;
	
	rxCb.tranKeyTbl[1][0] = 0xb4;
	rxCb.tranKeyTbl[1][1] = 0x39;
	rxCb.tranKeyTbl[1][2] = 0x2f;
	rxCb.tranKeyTbl[1][3] = 0x9a;
	rxCb.tranKeyTbl[1][4] = 0x5c;
	rxCb.tranKeyTbl[1][5] = 0xd3;
	rxCb.tranKeyTbl[1][6] = 0xf5;
	rxCb.tranKeyTbl[1][7] = 0x04;
	rxCb.tranKeyTbl[1][8] = 0x94;
	rxCb.tranKeyTbl[1][9] = 0x7d;
	rxCb.tranKeyTbl[1][10] = 0x58;
	rxCb.tranKeyTbl[1][11] = 0x81;
	rxCb.tranKeyTbl[1][12] = 0x89;
	rxCb.tranKeyTbl[1][13] = 0x56;
	rxCb.tranKeyTbl[1][14] = 0x10;
	rxCb.tranKeyTbl[1][15] = 0x28;


	rxCb.cfg.enableIBankApp = TRUE;
	rxCb.cfg.enableIBankAppTime[0] = 0x20; 
	rxCb.cfg.enableIBankAppTime[1] = 0x00; 
	rxCb.cfg.enableIBankAppTime[2] = 0x01; 
	rxCb.cfg.enableIBankAppTime[3] = 0x01; 
	rxCb.cfg.enableIBankAppTime[4] = 0x00; 
	rxCb.cfg.enableIBankAppTime[5] = 0x00; 
	rxCb.cfg.enableIBankAppTime[6] = 0x00; 
	rxCb.cfg.enableUse2IBankCard = TRUE;


	rxCb.cfg.enableUse2Time[0] = 0x20;
	rxCb.cfg.enableUse2Time[1] = 0x00;
	rxCb.cfg.enableUse2Time[2] = 0x01;
	rxCb.cfg.enableUse2Time[3] = 0x01;
	rxCb.cfg.enableUse2Time[4] = 0x00;
	rxCb.cfg.enableUse2Time[5] = 0x00;
	rxCb.cfg.enableUse2Time[6] = 0x00;

	rxCb.cfg.bankId[0] = 0x01;
	rxCb.cfg.bankId[1] = 0x02;

	rxCb.cfg.crrntKeyIndex = 0x01;
	rxCb.cfg.tranKeyVer = 2;



    cmHashListInit(&rxCb.BlkListHl, 1024, 0, FALSE, CM_HASH_KEYTYPE_DEF, 0, 0);
    cmHashListInit(&rxCb.GreyListIBankHl, 1024, 0, TRUE, CM_HASH_KEYTYPE_DEF, 0, 0);
    cmHashListInit(&rxCb.GreyListPoneyHl, 1024, 0, TRUE, CM_HASH_KEYTYPE_DEF, 0, 0);
    cmHashListInit(&rxCb.GreyListProteroHl, 1024, 0, TRUE, CM_HASH_KEYTYPE_DEF, 0, 0);

	memcpy(rxCb.cfg.crrntTranKey, rxCb.tranKeyTbl[rxCb.cfg.tranKeyVer-1], 16);
	
	lbTmrInit();
	SRegActvTsk(ENTLB, 0, TTNORM, PRIOR0, LbActvTsk);
	SRegActvTsk(ENTAL, 0, TTNORM, PRIOR0, AlActvTsk);
	SRegTmr(ENTLB, 0, 1, lbTmrHandle);
	mkdir("d:/rx_log");
	

	rxCb.first = TRUE;

	priceFile = fopen(PRICE_FILE_NAME, "rb");
	if(priceFile == NULLP)
	{
		PriceFormat_s format;
		U32 i;
		memset(&format, 0, sizeof(PriceFormat_s));

		for(i = 0; i < OILTYPE_NUM; i++)
		{
			format.price[i].oilType = g_oilTypeMap[i];
			format.price[i].price = 0x0001;
		}
		priceFile = fopen(PRICE_FILE_NAME, "wb");
		fwrite(&format, 1, sizeof(PriceFormat_s), priceFile);
		fclose(priceFile);
	}
	else
	{
		fclose(priceFile);
	}

	
	LBGETCMDENTRY(0, IND_DIR, entry);
	LBGETTRAN(entry, 0, tran);
	lbIndGetStationCodeMsg(0, tran, 0);

	lbSchdTmr(QUERY_TMR_INTERVAL, QUERY_TMR, START_TMR);
		
	buf[0] = 0x0d;
	buf[1] = 0;

	DownData(0, 2, buf);
	LBLOG("系统启动", 0, 0);


 #endif /* end modify */
 /* modify by shang is over 2002-7-14 23:17:49*/

	RETVALUE(ROK);
}



S16 rxWndInit(HINSTANCE hInstance, HINSTANCE hPreInstance)
{
	RETVALUE(ROK);
}





/******************* modify histroy list *******************
001. create at: 2002-7-2 23:08:43 by Shangyaohui

****************** modify histroy list end ****************/



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -