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

📄 global.c

📁 欣技8000 资料 很适用的资料
💻 C
字号:
/*
filename:	Global.c
purpose:	define the global parameter and function
author:		wx
date:		2003-3-20
*/

#include "8000lib.h"
#include  <ucos.h>
#include "global.h"

int    nStatus;                  // current state : current function or menu
int    nSelection;               // current selection of the menu

SETTINGS   SysParam;
int    modify_flag;              // if the SysParam was modifid 0: no 1:modified

int  ok_beep[] = { 23,25, 0,0 }; // define the beep sequence for OK
int  err_beep[] = { 22,10, 20,10, 22,10, 20,10, 0,0 }; // define the beep sequence for ERR
int  init_beep[] = { 20,50, 0,5, 20,50, 0,5, 20,50, 0,5, 0,0};//define the beep sequence for end of transimission

char   temp[10]; // Operator Code
int    oper_file; // operator file
int    prov_file; // provider file
int    cust_file; // customer file
int    good_file; // good file
int    ishee_file; // input sheet file
int    oshee_file; // output sheet file
int    repeat_file; //a temp file 
int    input_file; // input file
int    output_file; //output file

char   err;

// define Barcode decode table
BYTE   DefaultBCR [23] = 
               { 0x9b, 0xc9, 0x00, 0x00, 0x00, 0x21, 0x54, 0x80, 0x00, 0x9d,
                 0x3d, 0x50, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
                 0x66, 0x03, 0x03 };

// system fault routine
static void system_fault (void);

/***************************************************************************/
/* This function will be execute only when the program restart (not resume)*/
/* Actually this function is called from the main() in USER.c              */ 
/***************************************************************************/
void SysInit (void)
    {
    int  i, j;
    char f_name[100];

    clr_scr ();
    beep_ok();
    SetCursor (CURSOR_OFF);
    SetFont (2);

    //close all the DAT & DBF files
    for (i=1; i<=32; i++)
        {
        close (i);
        close_DBF (i);
        }

	//init operator file 
	strcpy(f_name,"OPER");
	if ((oper_file = create_DBF(f_name, 20)) > 0)
	{
		create_index(oper_file, 1, 0, 4);
	}
	else oper_file = open_DBF(f_name);

	//init customer file
	strcpy(f_name,"CUST");
	if ((cust_file = create_DBF(f_name, 20)) > 0)
	{
		create_index(cust_file, 1, 0, 4);
	}
	else cust_file = open_DBF(f_name);

	//init provider file
	strcpy(f_name,"PROV");
	if ((prov_file = create_DBF(f_name, 20)) > 0)
	{
		create_index(prov_file, 1, 0, 4);
	}
	else prov_file = open_DBF(f_name);

	//init good file
	strcpy(f_name,"GOOD");
	if ((good_file = create_DBF(f_name, 20)) > 0)
	{
		create_index(good_file, 1, 0, 4);
	}
	else good_file = open_DBF(f_name);

	//init inputsheet file
	strcpy(f_name,"ISHEE");
	if ((ishee_file = create_DBF(f_name, 20)) > 0)
	{
		create_index(ishee_file, 1, 0, 4);
	}
	else ishee_file = open_DBF(f_name);

	//init ouputsheet file
	strcpy(f_name,"OSHEE");
	if ((oshee_file = create_DBF(f_name, 20)) > 0)
	{
		create_index(oshee_file, 1, 0, 4);
	}
	else oshee_file = open_DBF(f_name);

	//init input file
	strcpy(f_name,"INPUT");
	input_file = open(f_name);

	//init output file
	strcpy(f_name,"OUTPUT");
	output_file = open(f_name);

    ReadSettings();
    temp[0]=0x00;
    nSelection = 1;
	modify_flag = 0;
    WelcMenu (1);
}

void DispString (int x, int y, char *str, int mode)
{

    if (y < 0 || y > MaxRow)
        return;
    SetVideoMode (mode);
    gotoxy (x, y);
    printf ("%s", str);
    SetVideoMode (0);
}

/*
display a english ling
*/
void DispLine(int line, char *str, int mode)
{
	int y;
	if(line < 1 || line > 4) 
		return;
	y = line * 2 - 1;
	SetVideoMode (mode);
    gotoxy (0, y);
    printf ("%s", str);
    SetVideoMode (0);
}

/*
display a simplify chinese string line 
*/
void SCDispLine(int line, char *str, int mode)
{
	int y;
	if(line < 1 || line > 4) 
		return;
	y = line * 2 - 1;
	SetVideoMode (mode);
    gotoxy (0, y);
    scputs (str);
    SetVideoMode (0);
}

static void system_fault (void)
{
    char *s;
    clr_scr ();
    strcpy(s,"System fault");
    DispString (0, 1, s, 0);
    strcpy(s,"Call service");
    DispString (0, 5, s, 0);
    while (1);
}

void ShowDate (void)
{
    int    i;
	int    font;
    char   t[20];
    char   zTime [16];
    char   szBuf[20];
    get_time (zTime);
    for (i=0; i<4; i++)
        szBuf [i] = zTime [i];
    szBuf [i++] = '/';
    szBuf [i++] = zTime [4];
    szBuf [i++] = zTime [5];
    szBuf [i++] = '/';
    szBuf [i++] = zTime [6];
    szBuf [i++] = zTime [7];
    szBuf [i] = 0;
    t[0]=zTime[8];
    t[1]=zTime[9];
    t[2]=':';
    t[3]=zTime[10];
    t[4]=zTime[11];
    t[5]=':';
    t[6]=zTime[12];
    t[7]=zTime[13];
    t[8]=0;

	font = GetFont();
	SetFont(1);
    gotoxy(4,7);
    printf("%s",szBuf);
	//gotoxy(12,7);
	//printf("%s",t);
	SetFont(font);

}
/*
write settings to flash
*/
void SaveSettings (void)
{
    unsigned long  Addr;                 
    EraseSector ((void *)0xf60000); 
	Addr = 0xf60000;
    WriteFlash ((void *)Addr, &SysParam, 24); 
}

/*
read settings from flash
*/
void ReadSettings (void)
{
    BYTE       *TestFlash;
    SETTINGS   *ptSettings;
    char       *pt;

    TestFlash = (BYTE *)0xF60000;

    ptSettings = (SETTINGS *) TestFlash;// system settings
    SysParam = *ptSettings;

    if (SysParam.ioper < 0 || SysParam.ioper > 1)
        SysParam.ioper = 1;

    if (SysParam.ishee < 0 || SysParam.ishee > 1)
        SysParam.ishee = 1;

	if (SysParam.iprov < 0 || SysParam.iprov > 1)
        SysParam.iprov = 1;

    if (SysParam.inum < 0 || SysParam.inum > 1)
        SysParam.inum  = 1;

    if (SysParam.iserial < 0 || SysParam.iserial> 1)
        SysParam.iserial = 1;

    if (SysParam.ooper < 0 || SysParam.ooper > 1)
        SysParam.ooper = 1;

    if (SysParam.oshee < 0 || SysParam.oshee > 1)
        SysParam.oshee = 1;

	if (SysParam.ocust < 0 || SysParam.ocust > 1)
        SysParam.ocust = 1;

    if (SysParam.onum < 0 || SysParam.onum > 1)
        SysParam.onum  = 1;

    if (SysParam.oserial < 0 || SysParam.oserial> 1)
        SysParam.oserial = 1;

    if (SysParam.language < 0 || SysParam.language > 1)
        SysParam.language = 0;

    if (SysParam.workstyle < 0 || SysParam.workstyle > 1)
        SysParam.workstyle = 1;
}

⌨️ 快捷键说明

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