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

📄 creatprt.c

📁 在Unix平台下完成的电力系统广发使用的IEC103规约的程序
💻 C
字号:
/*
 ***********************************************************************
 *                      NARI   Software                                *
 *            Automatic Realtime Remote Interface software             *
 *      Copyright (c) 1996, Nanjing Automation Research Institute      *
 *                   All Rights Reserved                               *
 *                                                                     *
 *                                                                     *
 * Name        : iecrdb.c                                             *
 *                                                                     *
 * Programmer  :                                                       *
 *                                                                     *
 * Description : DYNAMIC is used as a dynamic connection operation     *
 *                                                                     *
 ***********************************************************************/

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <memory.h>
#include <malloc.h>
#include <sys/time.h>
#include <time.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <errno.h>
#include <sys/termio.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <unistd.h>
#include <math.h>


char  *readline();

main(argc,argv)
int argc;
char *argv[];
{
FILE  *fp,*fp1,*fp2;
int   i,j,k,ret,num,value,cpu,dot,init,y;
char  *no,*ptr;
char  tmpstr[500],tmpstr1[500];
char  filename2[100],filename1[100],filename[100],str[500],str1[500],str2[500],str3[500];

     strcpy(filename,argv[1]);
     strcpy(filename1,argv[1]);
     strcat(filename1,".rpt");
     fp = fopen(filename,"r");
     if (fp == NULL) {
        printf("File %s not exist\n",filename);
        fclose(fp);
        exit(-1);
     }
     else {
        fp1 = fopen(filename1,"w");
        if (fp1 == NULL) {
          printf("File %s not exist\n",filename1);
          fclose(fp1);
          exit(-1);
        }
        else{
          fprintf(fp1,"┌─────────────────────────────┬───────────────────┐\n");
          fprintf(fp1,"│                              保护定值表                  │       年    月   日    时    分    秒│\n");
          fprintf(fp1,"└─────────────────────────────┴───────────────────┘\n");

          init = 1;
          while( ( no=readline(tmpstr,256,fp) ) != NULL ){
             sscanf(tmpstr,"%d   %d   %s     \n",&cpu,&dot,str);
             if(dot == 0){
                if(init == 0 )
                   fprintf(fp1,"└──┴────────────────────────────────┴─────┴───────┘\n");
                if(init == 1) init = 0;

                fprintf(fp1,"┌──┬────────────────────────────────┬─────┬───────┐\n");
                fprintf(fp1,"│序号│%-64s│  定   值 │   备     注  │\n",str);
             }
             else{
                fprintf(fp1,"├──┼────────────────────────────────┼─────┤              │\n");
                fprintf(fp1,"│%-4d│%-64s│          │              │\n",dot,str);
             }
          }
          fprintf(fp1,"└──┴────────────────────────────────┴─────┴───────┘\n");
          rewind(fp);
          fprintf(fp1,"FOREGROUND att len type style    x   y   nodename tagname\n");
          fprintf(fp1,"             0  16    3     1    9   1         *1 *1.DESCRIPT\n");
          fprintf(fp1,"             0   4    1    32   64   1         *1 SYSDATE.YEAR\n");
          fprintf(fp1,"             0   2    1    32   72   1         *1 SYSDATE.MONTH\n");
          fprintf(fp1,"             0   2    1    32   77   1         *1 SYSDATE.DAY\n");
          fprintf(fp1,"             0   2    1    32   83   1         *1 SYSDATE.HOUR\n");
          fprintf(fp1,"             0   2    1    32   89   1         *1 SYSDATE.MINUTE\n");
          fprintf(fp1,"             0   2    1    32   95   1         *1 SYSDATE.SECOND\n");

          y=3;
          while( ( no=readline(tmpstr,256,fp) ) != NULL ){
             sscanf(tmpstr,"%d   %d   %s     \n",&cpu,&dot,str);
             if(dot == 0) {
                y=y+3;
                continue;
             }
             fprintf(fp1,"             0   8    2     2   75   %-10d*1 *1.SET%d[%d]\n",y,cpu,dot);
             y=y+2;
          }
          fclose(fp);
          fclose(fp1);
        }
     }
}


char  *readline(str,size,file)
char  *str;
int   size;
FILE  *file;
{
  char  *ret;

  ret = fgets(str,size,file);
  while( ret != NULL ){
     if( !strcmp(str,"") || !strcmp(str,"\n") )
        ret = fgets(str,size,file);
     else if( str[0] == '/' && str[1] == '/' )
        ret = fgets(str,size,file);
     else break;
  }
  return(ret);
}

⌨️ 快捷键说明

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