/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1997 * * * * * * All Rights Reserved. Unpublished rights reserved under * * * the copyright laws of the Japan. * * * * * * The software contained on this media is proprietary to * * * and embodies the confidential technology of Fast * * * Corporation. Possession, use, duplication or * * * dissemination of the software and media is authorized only * * * pursuant to a valid written license from Fast Corporation. * * * * * ***************************************************************** */ /* 902+FVC01 2値ランダムトリガ入力(CH0) FVC01RDB.C */ /*[作成者]A.Sekimori */ /* 目的:FVC01を搭載した902シリーズ+XC-55/55B or CS8530-01 で動作するサンプルプログラムです。 関数: 履歴: Ver 1.0 2001/01/19 注記:m_menu.hをインクルードして下さい。 m_menu.c及びm_note.cをリンクして下さい。 */ /* * Include compiler runtime library */ #include #include /* * Include CSC90X library */ #include "f_stdlib.h" #include "f_time.h" #include "f_gui.h" #include "f_stdio.h" #include "f_graph.h" #include "f_image.h" #include "f_pinf.h" #include "f_video.h" #include "f_system.h" /* * Include CSC90X common local */ #include "m_menu.h" /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void disp_help( void ); void input_set( int *, int * ); void set_exposure_time( int, int, PARADIGM * ); void set_bin_level( int, int, PARADIGM * ); void through_input( int, int, PARADIGM * ); void input( int, int ); extern int message_note( void ); /* * メニュー項目 */ #define LANG_N 2 #define MAIN_MENU_N 2 static const char *str_main_menu[MAIN_MENU_N][LANG_N] = { { " SET ", " 入力設定 " }, { " INPUT ", " 画像入力 " } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 #define MIN_TIME 10 /* 最小露光時間 */ #define MAX_TIME 250000 /* 最大露光時間 */ #define MIN_LEVEL 0 /* 2値レベル最小値 */ #define MAX_LEVEL 255 /* 2値レベル最大値 */ PVAL value[3]; int pad_level; int xpos; int ypos; /* * メイン */ void main( void ) { int sts; int s_xpos; int s_ypos; int exp_time; /* 露光時間 */ int bin_level; /* チャネル0の2値レベル */ /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; /* パラメタ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; s_xpos = INIT_CUR_POS_X; s_ypos = INIT_CUR_POS_Y; exp_time = 33000; bin_level = 128; /* 入力ビデオ制御 */ Lib_input_video_control( BIN_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); /* CH0ランダム・トリガ・モード設定 */ Lib_set_video_input_mode( RANDOM_XC_MODE, 0 ); /* チャネルの設定 */ Lib_video_channel( 0 ); /* 露光時間設定 */ Lib_set_exposure( exp_time ); /* 2値化レベル設定 */ Lib_video_bin_level( bin_level ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE | GRAY_PLANE | BIN_PLANE ); /* カーソル初期化 */ Lib_init_cursor(); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /* メニュー制御 */ for (;;) { sts = 0; /* マウス位置読みとり */ sts = Lib_see_current_position( &xpos, &ypos ); if ( s_xpos != xpos || s_ypos != ypos ) { /* マウス表示位置移動 */ Lib_move_cursor( xpos, ypos ); s_xpos = xpos; s_ypos = ypos; } /* 処理振り分け */ if( CURSOR_EXECUTE == sts ) { if ( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); input_set( &exp_time, &bin_level ); /*入力設定*/ main_menu_disp(); } else if ( xpos > MENU_2_XS && xpos < MENU_2_XE && ypos > MENU_2_YS && ypos < MENU_2_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); input( exp_time, bin_level ); /*画像入力*/ main_menu_disp(); } else if ( xpos > MENU_H_XS && xpos < MENU_H_XE && ypos > MENU_H_YS && ypos < MENU_H_YE ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); disp_help(); /* ヘルプ */ main_menu_disp(); } else if ( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { break; /* 終了 */ } } } /* ノーマルモードに戻す */ Lib_set_video_input_mode( NORMAL_VIDEO_MODE, 0 ); } /* * メインメニュー表示 */ static void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)str_main_menu[0][iLanguage], (char *)str_main_menu[1][iLanguage], (char *)NULL, (char *)NULL ); } /* * ヘルプ表示 */ static void disp_help( void ) { Lib_chrdisp( 10, 8, "【機能\概要】 FVC01RDB.EXE" ); Lib_chrdisp( 11, 10, "ランダムトリガにて2値画像を入力するサンプルです。" ); Lib_chrdisp( 11, 11, "カメラは1台(CH0)固定です。" ); Lib_chrdisp( 11, 13, "【入力設定】露光時間、2値レベルを設定します。" ); Lib_chrdisp( 11, 15, "【画像入力】画像を入力し、モニタに表\示します。" ); Lib_chrdisp( 11, 17, "FVC01を搭載した902シリーズ+XC-55/55B or CS8530-01" ); Lib_chrdisp( 11, 19, "で使用できます。" ); } /***** 入力設定 *****/ void input_set( exp_time, bin_level ) int *exp_time; /* 露光時間 */ int *bin_level; /* チャネル0の2値レベル */ { int no; Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); pad_level = Lib_view_open(); /* パッドのオープン */ Lib_view_set_title( pad_level, "入力設定" ); /* パッドタイトルの登録 */ /* 各属性メニューの登録 */ Lib_view_set_uniq_numeral( pad_level, 5, 5, "露光時間" , *exp_time , MIN_TIME , MAX_TIME , 0 ); Lib_view_set_uniq_numeral( pad_level, 5, 35, "2値レベル", *bin_level, MIN_LEVEL, MAX_LEVEL, 1 ); Lib_view_set_null ( pad_level, 5, 65, "フリーラン", 2 ); Lib_set_paradigm( pad_level, 0, WHOLE_TIMING, set_exposure_time ); Lib_set_paradigm( pad_level, 1, WHOLE_TIMING, set_bin_level ); Lib_set_paradigm( pad_level, 2, START_TIMING, through_input ); /* パッドの表示位置の登録 */ Lib_view_set_size( pad_level, 80, 80, 5, 5 ); Lib_draw_menu( pad_level ); /* メニューパッドの表示 */ if ( ERROR_RETURN != ( no = Lib_process_menu( pad_level, value ) ) ) /* メニュー値の取得 */ { switch( no ) { case 101: /*「実行」が選択された */ *exp_time = value[0].value_type; *bin_level = value[1].value_type; break; case 102: /*「取り消し」が選択された */ break; } } Lib_erase_menu( pad_level ); /* メニューパッドの消去 */ Lib_view_close( pad_level ); /* パッドのクローズ */ Lib_cls( ( LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); } /***** 露光時間設定(パラダイム) *****/ void set_exposure_time( Timing, Numb, val ) int Timing; int Numb; PARADIGM val[]; { if ( Timing == START_TIMING ) { Lib_erase_menu( pad_level ); Lib_input_video_control( GRAY_PLANE ); Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* 露光時間設定 */ Lib_set_exposure( (int)val[0].long_type ); /* 画像の入力 */ Lib_freeze( TRANSMIT ); } else if ( Timing == PROCESS_TIMING ) { /* 露光時間設定 */ Lib_set_exposure( (int)val[0].long_type ); Lib_freeze( TRANSMIT ); } else if ( Timing == END_TIMING ) { Lib_memory_clear( LINE_PLANE | CHAR_PLANE | GRAY_PLANE ); Lib_input_video_control( BIN_PLANE ); Lib_display_control( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_draw_menu( pad_level ); } } /***** 2値レベル設定(パラダイム) *****/ void set_bin_level( Timing, Numb, val ) int Timing; int Numb; PARADIGM val[]; { if ( Timing == START_TIMING ) { Lib_erase_menu( pad_level ); Lib_memory_clear( BIN_PLANE ); /* 露光時間設定 */ Lib_set_exposure( value[0].value_type ); /* 2値化レベル設定 */ Lib_video_bin_level( (int)val[0].long_type ); Lib_freeze( TRANSMIT ); } else if ( Timing == PROCESS_TIMING ) { /* 2値化レベル設定 */ Lib_video_bin_level( (int)val[0].long_type ); Lib_freeze( TRANSMIT ); } else if ( Timing == END_TIMING ) { Lib_memory_clear( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_draw_menu( pad_level ); } } /***** 濃淡スルー画像入力(パラダイム) *****/ void through_input( Timing, Numb, val ) int Timing; int Numb; PARADIGM val[]; { int idc; idc = Lib_shelter_plane( 0, 0, (Lib_get_dx_size() - 1), (Lib_get_dy_size() - 1), CHAR_PLANE ); Lib_cls( ( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); Lib_input_video_control( GRAY_PLANE ); Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_erase_cursor(); Lib_chrdisp( 1, 1, "キャンセル・キー押下で終了" ); /* 露光時間設定 */ Lib_set_exposure( value[0].value_type ); /* ランダムトリガモードでの濃淡画像の入力 */ for ( ; ; ) { if ( CURSOR_CANCEL == Lib_see_current_position_real( &xpos, &ypos ) ) break; else Lib_freeze( TRANSMIT ); } Lib_cls( ( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); Lib_input_video_control( BIN_PLANE ); Lib_display_control( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_look_current_position( &xpos, &ypos ); Lib_draw_cursor( xpos, ypos ); Lib_recover_plane( idc ); } /***** 画像入力 *****/ void input( exp_time, bin_level ) int exp_time; /* 露光時間 */ int bin_level; /* 2値化レベル */ { Lib_cls( ( BIN_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); /* 露光時間設定 */ Lib_set_exposure( exp_time ); /* 2値化レベル設定 */ Lib_video_bin_level( bin_level ); Lib_strtclk_count(); Lib_freeze( TRANSMIT ); /*画像入力*/ Lib_time_disp( 0, 455 ); Lib_display_keyinput( 415, 0, "CH0画像" ); Lib_cls( ( BIN_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); }