/* * ***************************************************************** * * * * * 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. * * * * * ***************************************************************** */ /* CSC903 2値ランダムトリガ入力(2CH同時) 903RDMB.C */ /*[作成者]A.Sekimori */ /* 目的: 関数: 履歴: Ver 1.0 2000/12/26 Ver 2.0 2001/01/19 システムVer1.30よりノーマル←→ランダムトリガ切替時の 待ち時間は不要となった。 注記: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_mode_set( int *, int *, int * ); void set_exposure_time( int, int, PARADIGM * ); void set_bin_level( int, int, int, PARADIGM * ); void through_input( int, int, int, PARADIGM * ); void input( int, 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[7]; int bmem0,bmem1; int pad_level; int xpos; int ypos; /* * メイン */ void main( void ) { int sts; int s_xpos; int s_ypos; int exp_time; /* 露光時間 */ int bl_0; /* チャネル0の2値レベル */ int bl_1; /* チャネル1の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; bl_0 = 128; bl_1 = 128; /* カーソル初期化 */ Lib_init_cursor(); /* カレントメモリ番号の取得 */ bmem0 = Lib_get_bin_memory(); /* 同時入力時のCH1用画像メモリの確保 */ if ( ERROR_RETURN != ( bmem1 = Lib_alloc_bin_memory() ) ) { /* 入力ビデオ制御 */ Lib_input_video_control( BIN_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); /* ランダム・トリガ・同時取り込みモード設定 */ Lib_set_both_mode( RANDOM_TRG_SW_BIN, 0, bmem0, bmem1 ); /* 露光時間設定 */ Lib_set_exposure( exp_time ); /* 2値化レベルの設定 */ Lib_video_channel( 0 ); Lib_random_bin_level( bl_0 ); Lib_video_channel( 1 ); Lib_random_bin_level( bl_1 ); Lib_video_channel( 0 ); /* ビデオ表示項目クリア */ Lib_memory_clear( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); /* メインメニューの表示 */ 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_mode_set( &exp_time, &bl_0, &bl_1 ); /*入力設定*/ 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, bl_0, bl_1 ); /*画像入力*/ 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 ); Lib_set_video_input_mode( NORMAL_VIDEO_MODE, 1 ); } else Lib_display_message( 120, 200, "エラー", "画像メモリが確保できません" ); Lib_free_bin_memory( bmem1 ); } /* * メインメニュー表示 */ 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, "【機能\概要】 903RDMB.903" ); Lib_chrdisp( 11, 10, "ランダムトリガにて2値画像をカメラ2台同時" ); Lib_chrdisp( 11, 11, "取込で入力するサンプルです。" ); Lib_chrdisp( 11, 13, "【入力設定】 露光時間、2値レベルを設定します。" ); Lib_chrdisp( 11, 15, "【画像入力】 画像を入力し、モニタに表\示します。" ); Lib_chrdisp( 11, 17, "なお、このサンプルはCSC903専用です。" ); } /***** 入力設定 *****/ void input_mode_set( exp_time, bl_0, bl_1 ) int *exp_time; /* 露光時間 */ int *bl_0; /* チャネル0の2値レベル */ int *bl_1; /* チャネル1の2値レベル */ { int no; int ch; 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_comment ( pad_level, 5, 40, "CH0" , 1 ); Lib_view_set_uniq_numeral( pad_level, 10, 75, "2値レベル", *bl_0, MIN_LEVEL, MAX_LEVEL, 2 ); Lib_view_set_null ( pad_level, 10, 110, "フリーラン", 3 ); Lib_view_set_comment ( pad_level, 5, 145, "CH1" , 4 ); Lib_view_set_uniq_numeral( pad_level, 10, 180, "2値レベル", *bl_1, MIN_LEVEL, MAX_LEVEL, 5 ); Lib_view_set_null ( pad_level, 10, 215, "フリーラン", 6 ); Lib_set_paradigm ( pad_level, 0, WHOLE_TIMING, set_exposure_time ); Lib_set_xparadigm( pad_level, 2, WHOLE_TIMING, set_bin_level ); Lib_set_xparadigm( pad_level, 3, START_TIMING, through_input ); Lib_set_xparadigm( pad_level, 5, WHOLE_TIMING, set_bin_level ); Lib_set_xparadigm( pad_level, 6, 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; *bl_0 = value[2].value_type; *bl_1 = value[5].value_type; break; case 102: /*「取り消し」が選択された */ break; } } Lib_erase_menu( pad_level ); /* メニューパッドの消去 */ Lib_view_close( pad_level ); /* パッドのクローズ */ } /***** 露光時間設定(パラダイム) *****/ void set_exposure_time( Timing, Numb, val ) int Timing; int Numb; PARADIGM val[]; { int ch; 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_xvideo_channel( WAITING, 0 ); /* 露光時間設定 */ 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( GRAY_PLANE | LINE_PLANE | CHAR_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( Menu_no, Timing, Numb, val ) int Menu_no; int Timing; int Numb; PARADIGM val[]; { int ch; if ( Timing == START_TIMING ) { Lib_erase_menu( pad_level ); if ( 2 == Menu_no ) ch = 0; else if ( 5 == Menu_no ) ch = 1; /* ランダム・トリガ・モード設定 */ Lib_set_video_input_mode( RANDOM_XC_MODE, ch ); Lib_memory_clear( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_xvideo_channel( WAITING, ch ); /* 露光時間設定 */ Lib_set_exposure( value[0].value_type ); /* 2値化レベル設定 */ Lib_random_bin_level( (int)val[0].long_type ); Lib_freeze( TRANSMIT ); } else if ( Timing == PROCESS_TIMING ) { Lib_random_bin_level( (int)val[0].long_type ); Lib_freeze( TRANSMIT ); } else if ( Timing == END_TIMING ) { /* ランダム・トリガ・同時取り込みモード設定 */ Lib_set_both_mode( RANDOM_TRG_SW_BIN, 0, bmem0, bmem1 ); Lib_memory_clear( BIN_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_xvideo_channel( WAITING, 0 ); Lib_draw_menu( pad_level ); } } /***** 濃淡スルー画像入力(パラダイム) *****/ void through_input( Menu_no, Timing, Numb, val ) int Menu_no; int Timing; int Numb; PARADIGM val[]; { int ch; 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_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_input_video_control( GRAY_PLANE ); Lib_erase_cursor(); if ( 3 == Menu_no ) ch = 0; else if ( 6 == Menu_no ) ch = 1; /* ランダム・トリガ・モード設定 */ Lib_set_video_input_mode( RANDOM_XC_MODE, ch ); /* チャネルの切り替え */ Lib_video_channel( ch ); 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_set_both_mode( RANDOM_TRG_SW_BIN, 0, bmem0, bmem1 ); 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, bl_0, bl_1 ) int exp_time; /* 露光時間 */ int bl_0; /* 2値化レベル */ int bl_1; /* 2値化レベル */ { Lib_cls( ( BIN_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); /*Lib_display_control( BIN_PLANE | LINE_PLANE | CHAR_PLANE );*/ /* 露光時間設定 */ Lib_set_exposure( exp_time ); /* 2値化レベルの設定 */ Lib_xvideo_channel( WAITING, 0 ); Lib_random_bin_level( bl_0 ); Lib_xvideo_channel( WAITING, 1 ); Lib_random_bin_level( bl_1 ); Lib_xvideo_channel( WAITING, 0 ); Lib_strtclk_count(); Lib_freeze( NOT_TRANSMIT ); /*画像入力*/ Lib_time_disp( 0, 455 ); Lib_xvideo_transmit( bmem0, BIN_PLANE ); Lib_display_keyinput( 415, 0, "CH0画像" ); Lib_xvideo_transmit( bmem1, BIN_PLANE ); Lib_display_keyinput( 415, 0, "CH1画像" ); Lib_cls( ( BIN_PLANE | LINE_PLANE | CHAR_PLANE ), BLACK_COLOR ); /*Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE );*/ }