OSDN Git Service

20080820
authorsendan <sendan@b9d4a4f1-8ba9-4454-8150-46c023f248aa>
Wed, 20 Aug 2008 05:31:12 +0000 (05:31 +0000)
committersendan <sendan@b9d4a4f1-8ba9-4454-8150-46c023f248aa>
Wed, 20 Aug 2008 05:31:12 +0000 (05:31 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/linuxcw@10 b9d4a4f1-8ba9-4454-8150-46c023f248aa

linuxcw/almemsys/randdata.c
linuxcw/cwrand/anunnec.c
linuxcw/cwrand/cwrand.c
linuxcw/cwrand/optin.c
linuxcw/cwrand/prototype.h
linuxcw/libcw/cw_default_memset_roman.c
linuxcw/libcw/note_no.c

index 8d70f6c..d3cb20f 100644 (file)
@@ -13,12 +13,19 @@ return (int)tv.tv_usec;
 
 int randdata(int min, int max)
 {
-int a;
+int a, in_max;
 time_t t;
 
+if(min >= max){
+   min = 0;
+   max = 1;
+   }
+
+in_max = (max - min) + 1;
+
 t = utimesec();
 srandom((unsigned int)t);
-a = min + (int) ((double)max * random() / (RAND_MAX + 1.0));
+a = min + (int) ((double)in_max * random() / (RAND_MAX + 1.0));
 
 #ifdef RANDDATA_BUG
 printf("RANDDATA_BUG: randdata.c: utime=%d, randam=%d\n", t, a);
@@ -33,12 +40,8 @@ return a;
 // int co;
 
 // for(co = 0; co < 100; co++){
-//    printf("%d,", randdata(0, 20));
-//    printf("%d,", randdata(0, 20));
-//    printf("%d,", randdata(0, 20));
-//    printf("%d,", randdata(0, 20));
-//    printf("%d\n", randdata(0, 20));
-//    }
+//   printf("%d\n", randdata(3, 7));
+//   }
 
 // return 0;
 // }
index 2d4daa9..6045a23 100644 (file)
@@ -12,7 +12,7 @@
 int anunnec(int char_no, int exa_mode)
 {
 int co;
-int list[17] = { 38, 40, 41, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55 };
+int list[17] = { 40, 42, 43, 44, 46, 47 };
 
 for(co = 0; co < 17; co++){
    if(char_no == list[co]){
index 0b43177..e2cc4f6 100644 (file)
@@ -11,7 +11,7 @@
 int main(int argc, char ** argv)
 {
 int fd;
-int moji, no, co, co2, inrand, mode, exa_mode;
+int moji, no, co, co2, co3, co4, inrand, mode, exa_mode, bb, kk;
 int start_rand, stop_rand;
 char cha;
 char sw[2];
@@ -25,9 +25,11 @@ cha = 0x00;
 inrand = 0;
 mode = 0;
 exa_mode = 0;
+bb = 1;
+kk = 1;
 
 start_rand = 0;  // default の乱数の最小値
-stop_rand = 55;  // default の乱数の最大値
+stop_rand = 48;  // default の乱数の最大値
 
 
 buf = (char *)calloc(2, sizeof(char));
@@ -44,7 +46,7 @@ cw_default_memset(&cw_len);
 // デフォルトの信号の長さ(3)と周波数(2)を設定
 cw_defaultset(&cw_len, 700, 130);
 
-optin(argc, argv, &cw_len, &moji, &no, &mode, &exa_mode, &start_rand, &stop_rand);
+optin(argc, argv, &cw_len, &moji, &no, &mode, &exa_mode, &start_rand, &stop_rand, &bb, &kk);
 
 // beepデバイスファイルを開いてFDを得る
 fd = beep_fdopen(fd);
@@ -71,17 +73,21 @@ for(co2 = 0; co2 < no; co2++){
          memset(swap, 0x00, 2);
 
          if(mode == 0 || mode == 2){
-            printf("%c     %s\n", cha, cw_len.roman.note_sign[inrand]);
+            printf("%d  %c     %s\n", co2, cha, cw_len.roman.note_sign[inrand]);
+            }
+         for(co4 = 0; co4 < kk; co4++){
+            cw_sign(&cw_len, fd, cha);
+            cw_sign(&cw_len, fd, ' ');
             }
-         cw_sign(&cw_len, fd, cha);
-         cw_sign(&cw_len, fd, ' ');
          }
       else {
          co = co - 1;
          }
 
       }
-   cw_sign(&cw_len, fd, '*');
+   for(co3 = 0; co3 < bb; co3++){
+      cw_sign(&cw_len, fd, '*');
+      }
 
    if(mode == 1 || mode == 2){
       printf("%s\n", buf);
index 6de6f78..1e558af 100644 (file)
@@ -9,7 +9,7 @@
 #include"almemsys.h"
 
 
-int optin(int argc, char * argv[], cw_length * cw_len, int * moji, int * co, int * mode, int * exa_mode, int *start, int * stop)
+int optin(int argc, char * argv[], cw_length * cw_len, int * moji, int * co, int * mode, int * exa_mode, int *start, int * stop, int * bb, int * kk)
 {
 char i;
 int sp, to;
@@ -22,7 +22,7 @@ to = 0;
 * mode = 0;
 * exa_mode = 0;
 
-while((i = (char)getopt(argc, argv, "v:s:c:m:t:-:"))!= EOF){
+while((i = (char)getopt(argc, argv, "v:s:b:k:c:m:t:-:"))!= EOF){
    switch(i){
       case 'c':
                 #ifdef CWRAND_BUG
@@ -50,6 +50,18 @@ while((i = (char)getopt(argc, argv, "v:s:c:m:t:-:"))!= EOF){
                 to = strtol(optarg, (char **)NULL, 10);
                 cw_toneset(cw_len, to);
                 break; 
+      case 'b':
+                #ifdef CWRAND_BUG
+                printf("cw break time set. <%s>\n", optarg);
+                #endif
+                * bb = strtol(optarg, (char **)NULL, 10);
+                break; 
+      case 'k':
+                #ifdef CWRAND_BUG
+                printf("cw return set. <%s>\n", optarg);
+                #endif
+                * kk = strtol(optarg, (char **)NULL, 10);
+                break; 
       case '-':
                 if(0 == memcmp(optarg, "help", 4)){
                     printf("cwrand は、欧文モールス信号の学習の為の道具です。\n");
@@ -57,6 +69,10 @@ while((i = (char)getopt(argc, argv, "v:s:c:m:t:-:"))!= EOF){
                     printf("       cwrand は以下のオプションに対応しています。\n");
                     printf("\n");
                     printf("cwrand -c <Frequency> -m <Nomber> -s <Speed> -t <tone>\n");
+                    printf("\n");
+                    printf("-b <記号間の時間x倍数>\n");
+                    printf("-k <同じ符号の繰り返し数>\n");
+                    printf("\n");
                     printf("--help           ヘルプの表示\n");
                     printf("--print1         一行ずつ表示します\n");
                     printf("--print2         いち文字ずつ表示します\n");
@@ -64,7 +80,6 @@ while((i = (char)getopt(argc, argv, "v:s:c:m:t:-:"))!= EOF){
                     printf("--figure         数字のみを出力します\n");
                     printf("--roman          ローマ字のみを出力します\n");
                     printf("--sign           記号のみを出力します。\n");
-                    printf("--hibrid         HH、ARなどの複合符号。\n");
                     exit(1);
                     }
 
@@ -112,13 +127,6 @@ while((i = (char)getopt(argc, argv, "v:s:c:m:t:-:"))!= EOF){
                     * start = 36;
                     * stop = 48;
                     }
-                else if(0 == memcmp(optarg, "hibrid", 6)){
-                    #ifdef CWRAND_BUG
-                    printf("sign mode. \n");
-                    #endif
-                    * start = 49;
-                    * stop = 55;
-                    }
 
                 else{
                     }
index 9d93c7a..108dcdd 100644 (file)
@@ -1,4 +1,4 @@
 
-int optin(int argc, char * argv[], cw_length * cw_len, int * moji, int * co, int * mode, int * exa_mode, int * start, int * stop);
+int optin(int argc, char * argv[], cw_length * cw_len, int * moji, int * co, int * mode, int * exa_mode, int * start, int * stop, int * bb, int * kk);
 int anunnec(int char_no, int exa_mode);
 
index d07714b..a8dc7cc 100644 (file)
@@ -65,18 +65,10 @@ memcpy(cw_len->roman.note_sign[44], "-...-", 5); cw_len->roman.char_sign[44] = '
 memcpy(cw_len->roman.note_sign[45], "-..-.", 5); cw_len->roman.char_sign[45] = '/';
 memcpy(cw_len->roman.note_sign[46], ".-.-.", 5); cw_len->roman.char_sign[46] = '+';
 memcpy(cw_len->roman.note_sign[47], ".-..-.", 6); cw_len->roman.char_sign[47] = '"';
-memcpy(cw_len->roman.note_sign[48], "-..-", 4); cw_len->roman.char_sign[48] = 'x';
-// 複合、キャラとの対応はなし。
-memcpy(cw_len->roman.note_sign[49], "........", 8); cw_len->roman.char_sign[49] = '^';  // HH
-memcpy(cw_len->roman.note_sign[50], "-...-", 5); cw_len->roman.char_sign[50] = '^';     // BT =
-memcpy(cw_len->roman.note_sign[51], ".-.-.", 5); cw_len->roman.char_sign[51] = '^';     // AR +
-memcpy(cw_len->roman.note_sign[52], ".-...", 5); cw_len->roman.char_sign[52] = '^';     // AS
-memcpy(cw_len->roman.note_sign[53], "-.--.", 5); cw_len->roman.char_sign[53] = '^';     // KN
-memcpy(cw_len->roman.note_sign[54], "-.--.", 5); cw_len->roman.char_sign[54] = '^';     // VA
-memcpy(cw_len->roman.note_sign[55], "...-.-", 6); cw_len->roman.char_sign[55] = '^';    // SK
+memcpy(cw_len->roman.note_sign[48], ".--.-.", 6); cw_len->roman.char_sign[48] = '@';
 // 操作記号
-memcpy(cw_len->roman.note_sign[56], " ", 1); cw_len->roman.char_sign[56] = ' ';  // 文字間の空白
-memcpy(cw_len->roman.note_sign[57], "*", 1); cw_len->roman.char_sign[57] = '*';  // ワード間の空白
+memcpy(cw_len->roman.note_sign[49], " ", 1); cw_len->roman.char_sign[49] = ' ';  // 文字間の空白
+memcpy(cw_len->roman.note_sign[50], "*", 1); cw_len->roman.char_sign[50] = '*';  // ワード間の空白
 
 
 return 0;
index 46f1c83..02de319 100644 (file)
@@ -10,7 +10,7 @@ int co, max;
 max = (int)strlen(note);
 
 if(max > BUFF_LENG){
-   return 58;
+   return 50;
    }
 
 for(co = 0; co < CHAR_LENG; co++){
@@ -19,7 +19,7 @@ for(co = 0; co < CHAR_LENG; co++){
       }
    }
 
-return 58;
+return 50;
 }