根据官方源码重复记录的内容

主函数

int main (int argc, char ** argv)
{
    int status;
    int choice;
    int do_next;    /* 0=continue, 1=mdi, 2=stop */
    int block_delete;
    char buffer[80];
    int tool_flag;
    int gees[RS274NGC_ACTIVE_G_CODES];
    int ems[RS274NGC_ACTIVE_M_CODES];
    double sets[RS274NGC_ACTIVE_SETTINGS];
    char default_name[] SET_TO "rs274ngc.var";
    int print_stack;

    if (argc > 3)
    {
        fprintf(stderr, "Usage \"%s\"\n", argv[0]);
        fprintf(stderr, "   or \"%s <input file>\"\n", argv[0]);
        fprintf(stderr, "   or \"%s <input file> <output file>\"\n", argv[0]);
        exit(1);
    }

    do_next SET_TO 2;    /* 2=stop */
    block_delete SET_TO OFF;
    print_stack SET_TO OFF;
    tool_flag SET_TO 0;
    strcpy(_parameter_file_name, default_name);
    _outfile SET_TO stdout;                       /* may be reset below */

    for(; ;)
    {
        fprintf(stderr, "enter a number:\n");
        fprintf(stderr, "1 = start interpreting\n");
        fprintf(stderr, "2 = choose parameter file ...\n");
        fprintf(stderr, "3 = read tool file ...\n");
        fprintf(stderr, "4 = turn block delete switch %s\n",
            ((block_delete IS OFF) ? "ON" : "OFF"));
        fprintf(stderr, "5 = adjust error handling...\n");
        fprintf(stderr, "enter choice => ");
        fgets(buffer, 80, stdin);
        if (sscanf(buffer, "%d", &choice) ISNT 1)
        {
            continue;
        }
        if (choice IS 1)
            break;
        else if (choice IS 2)
        {
            if (designate_parameter_file(_parameter_file_name) ISNT 0)
                exit(1);
        }
        else if (choice IS 3)
        {
            if (read_tool_file("") ISNT 0)
                exit(1);
            tool_flag SET_TO 1;
        }
        else if (choice IS 4)
            block_delete SET_TO ((block_delete IS OFF) ? ON : OFF);
        else if (choice IS 5)
            adjust_error_handling(argc, &print_stack, &do_next);
    }
    fprintf(stderr, "executing\n");
    if (tool_flag IS 0)
    {
        if (read_tool_file("rs274ngc.tool_default") ISNT 0)
            exit(1);
    }

    if (argc IS 3)
    {
        _outfile SET_TO fopen(argv[2], "w");
        if (_outfile IS NULL)
        {
            fprintf(stderr, "could not open output file %s\n", argv[2]);
            exit(1);
        }
    }

    if ((status SET_TO rs274ngc_init()) ISNT RS274NGC_OK)
    {
        report_error(status, print_stack);
        exit(1);
    }
    
    if (argc IS 1)
    {
        status SET_TO interpret_from_keyboard(block_delete, print_stack);
        
    }
    else  /* if (argc IS 2 or argc IS 3) */
    {

        status SET_TO rs274ngc_open(argv[1]);
        if (status ISNT RS274NGC_OK)         /* do not need to close since not open */
        {
            report_error(status, print_stack);
            exit(1);
        }

        status SET_TO interpret_from_file(do_next, block_delete, print_stack);

        rs274ngc_file_name(buffer, 5);            /* called to exercise the function */
        rs274ngc_file_name(buffer, 79);           /* called to exercise the function */
        rs274ngc_close();
    }

    rs274ngc_line_length();                       /* called to exercise the function */
    rs274ngc_sequence_number();                   /* called to exercise the function */
    rs274ngc_active_g_codes(gees);                /* called to exercise the function */
    rs274ngc_active_m_codes(ems);                 /* called to exercise the function */
    rs274ngc_active_settings(sets);               /* called to exercise the function */
    rs274ngc_exit();                              /* saves parameters */
    exit(status);

    return 0;
}

int main()中调用顺序 

(1)if ((status SET_TO rs274ngc_init()) ISNT RS274NGC_OK)

(2)  if (argc IS 1) {  status SET_TO interpret_from_keyboard(block_delete, print_stack); }

(3)和(4) status SET_TO interpret_from_file(do_next, block_delete, print_stack);进去

内涵status SET_TO rs274ngc_read(NULL);和 status SET_TO rs274ngc_execute();

一,通过rs274ngc_init()函数进行初始化,初始化内容包括读取rs274ngc.var和rs274ngc.tool_default文件,坐标,G模态组,M模态组以及其他G代码运行需要的状态量。

    int rs274ngc_init()        /* NO ARGUMENTS */
    {
        static char name[] SET_TO "rs274ngc_init";
        int k;              // starting index in parameters of origin offsets
        int status;
        char filen
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寒听雪落

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值