/* * ***************************************************************** * * * * * Copyright (c) Fast Corporation, 1998 * * * * * * 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. * * * * * ***************************************************************** */ /* CSC901、FV904 ストロボ入力サンプルプログラム */ /* メインルーチン SSTRBINP.C */ /*[作成者]A.Kameda */ /* 目的: 関数: 履歴: Ver 1.0 98/01/06 Ver 1.1 99/10/29 FV904でも使用できるのでヘルプを修正 注記:m_menu.hをインクルードして下さい。 m_menu.c,m_note.cをリンクして下さい。 注記: */ /* * Include compiler runtime library */ /* * Include CSC90X library */ #include "f_video.h" /* ビデオ制御ライブラリ */ #include "f_image.h" /* メモリ操作ライブラリ */ #include "f_gui.h" /* カーソル/パッド関連ライブラリ */ #include "f_pinf.h" /* システムパラメータ更新/参照ライブラリ */ #include "f_stdlib.h" /* メモリ割当ライブラリ */ #include "f_graph.h" /* グラフィック表示ライブラリ */ #include "f_file.h" /* ファイルシステムライブラリ */ #include "f_stdio.h" /* 標準入出力関連ライブラリ */ #include "f_time.h" /* 時刻サービスライブラリ */ #include "f_dido.h" /* フォトカプラ絶縁型I/Oライブラリ */ /* * Include CSC90X common local */ #include "m_menu.h" /* パッド関連 */ #define UP_MARGIN 5 /* 上縁からキーまでのドット数 */ #define DOWN_MARGIN 5 /* 下縁からキーまでのドット数 */ #define LEFT_MARGIN 5 /* 左縁からキーまでのドット数 */ #define RIGHT_MARGIN 5 /* 右縁からキーまでのドット数 */ #define ROW_CENTER_MARGIN 5 /* 行方向のキー間ドット数 */ #define COLUMN_CENTER_MARGIN 5 /* 列方向のキー間ドット数 */ #define PAD_START_XPOS 50 #define PAD_START_YPOS 20 #define MSG_DISP_X 50 /* メッセージ表示座標X */ #define MSG_DISP_Y 100 /* メッセージ表示座標Y */ /* 設定メニュー */ #define SET_ITEM_N 2 static char *set_menu_table[][KIND_LANGUAGE] = { { "" , "設定" }, { "" , "処理時間" }, { "" , "カメラ調整" } }; /* DIDO関連 */ #define DI_NON 0x00000000 /* 処理なし */ #define DI_TRIGGER 0x00000001 /* トリガ */ #define DI_QUIT 0x00000002 /* 終了 */ /* * データ */ static int Gb_disp_time; /* 処理時間表示 */ static int Gb_module_no; /* DIDOモジュールNo */ static int last_pattern = DI_NON; /* * プロトタイプ宣言 */ void main( void ); void main_menu_disp( void ); void SST_set_pad( void ); void SST_local( void ); void SST_remote( void ); void disp_help( void ); static void SST_video_setting_proc( int, int, PARADIGM * ); static void SST_video_setting( void ); static void SST_strobo_set( void ); static void SST_strobo_freerun( void ); static void SST_strobo_freeze( int ); static void SST_strobo_stop( void ); static int SST_dido_open( void ); static void SST_dido_close( void ); static int SST_dido_read_trigger( void ); /* * プロトタイプ宣言 */ /* m_note.c */ extern int message_note( void ); /* * メニュー項目 */ static char *top_main_menu[][KIND_LANGUAGE] = { { " SET ", " 設 定 " }, { " LOCAL ", " ローカル " }, { " REMOTE ", " リモート " } }; #define INIT_CUR_POS_X 255 #define INIT_CUR_POS_Y 239 /*---------------------------------------------------------------------------*/ /* * メイン */ void main() { int status; int xpos; int ypos; int s_xpos; int s_ypos; /* 初期メッセージ表示 */ if( NORMAL_RETURN != message_note() ) return; /* パラメータ初期化 */ xpos = INIT_CUR_POS_X; ypos = INIT_CUR_POS_Y; /* 入力ビデオ制御 */ Lib_input_video_control( GRAY_PLANE ); /* ビデオ出力表示項目制御 */ Lib_display_control( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); /* ビデオ表示項目クリア */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); /* カーソル初期化 */ Lib_init_cursor(); /* メインメニューの表示 */ main_menu_disp(); /* マウスカーソルの表示 */ Lib_draw_cursor( INIT_CUR_POS_X, INIT_CUR_POS_Y ); /* メニュー制御 */ for( ; ; ) { status = 0; /* マウス位置読みとり */ status = 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 == status ) { if( xpos > MENU_1_XS && xpos < MENU_1_XE && ypos > MENU_1_YS && ypos < MENU_1_YE ) { /* 設定 */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); SST_set_pad(); Lib_move_cursor( xpos, ypos ); Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); 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 ); SST_local(); Lib_move_cursor( xpos, ypos ); Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); main_menu_disp(); } else if( xpos > MENU_3_XS && xpos < MENU_3_XE && ypos > MENU_3_YS && ypos < MENU_3_YE ) { /* リモート */ Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); SST_remote(); Lib_move_cursor( xpos, ypos ); Lib_memory_clear( LINE_PLANE | CHAR_PLANE ); 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(); Lib_move_cursor( xpos, ypos ); main_menu_disp(); } else if( xpos > MENU_E_XS && xpos < MENU_E_XE && ypos > MENU_E_YS && ypos < MENU_E_YE ) { /* 終了 */ break; } } } } /* * メインメニュー表示 */ static void main_menu_disp( void ) { int iLanguage; /* 日本語/英語表示文字列切替情報取得 */ iLanguage = Lib_get_disp_language(); /* 整列キー表示 -> ( m_menu.c ) */ SUB_menu_disp4he( (char *)top_main_menu[0][iLanguage], (char *)top_main_menu[1][iLanguage], (char *)top_main_menu[2][iLanguage], (char *)NULL ); } /*---------------------------------------------------------------------------*/ /* * ヘルプ表示 */ void disp_help( void ) { Lib_chrdisp( 10, 8, "【機能\概要】 SSTRBINP" ); Lib_chrdisp( 11, 10, "ストロボ入力を行うサンプルプログラムです。" ); Lib_chrdisp( 11, 12, "[設  定]:カメラのピント、絞りの調整を行います。" ); Lib_chrdisp( 11, 13, "[ローカル]:トラックボール操作よりストロボ入力を" ); Lib_chrdisp( 11, 14, " 行います。" ); Lib_chrdisp( 11, 15, "[リモート]:外部機器からのトリガーによって" ); Lib_chrdisp( 11, 16, " ストロボ入力を行います。" ); Lib_chrdisp( 11, 18, "トリガーはDIDOにより入力し、" ); Lib_chrdisp( 11, 19, " DI0:トリガー" ); Lib_chrdisp( 11, 20, " DI1:リモート終了" ); Lib_chrdisp( 11, 21, "として信号が割り付けられています。" ); Lib_chrdisp( 11, 23, "CSC901シリーズ、FV904で使用できます。" ); } /*--- メニュー関連 ----------------------------------------------------------*/ /* * 設定メニュー */ void SST_set_pad() { int process, no; int pad_level; PVAL value[SET_ITEM_N]; int row[SET_ITEM_N+1], column; int item_n, i; int width, height; int language; language = Lib_get_disp_language(); /* レイアウトの設定 */ item_n = SET_ITEM_N; Lib_get_standard_key_size( &width, &height ); for( row[0] = UP_MARGIN+4, i = 1; i < ( item_n + 1 ); i++ ) row[i] = row[i-1] + height + COLUMN_CENTER_MARGIN + 4; column = LEFT_MARGIN + 4; /* パッドのオープン */ pad_level = Lib_view_open(); /* タイトル設定 */ Lib_view_set_title( pad_level, set_menu_table[0][language] ); /* 入力値設定 */ i=0; value[i].on_off_type = Gb_disp_time; /* 処理時間 */ i=0; /* 処理時間 */ Lib_view_set_uniq_alter( pad_level, column, row[i], set_menu_table[i+1][language], value[i].on_off_type, i ); i++; /* カメラ調整 */ Lib_view_set_null( pad_level, column, row[i], set_menu_table[i+1][language], i ); /* ユーザ固有プログラムの登録 */ i=0; /* 処理時間 */ i++; Lib_set_paradigm( pad_level, i, START_TIMING, SST_video_setting_proc ); /* パッド・サイズの設定 */ Lib_view_set_size( pad_level, PAD_START_XPOS, PAD_START_YPOS, UP_MARGIN+4, LEFT_MARGIN+4 ); /* パッドの表示 */ if( NORMAL_RETURN == Lib_draw_menu( pad_level ) ) { for ( process = ON ; OFF != process ; ) { /* カーサからのコマンド入力 */ if( ERROR_RETURN != ( no = Lib_process_menu( pad_level, value ) ) ) { switch( no ) { case PAD_EXECUTE: i=0; Gb_disp_time = value[i].on_off_type; /* 処理時間 */ case PAD_CANCEL: process = OFF; break; } } } Lib_erase_menu( pad_level ); } /* パッドのクローズ */ Lib_view_close( pad_level ); } /* * パラダイム カメラ調整 */ static void SST_video_setting_proc( timing, numb, val ) int timing; int numb; PARADIGM val[]; { int shelter_id; shelter_id = Lib_shelter_plane( 0, 0, ( Lib_get_fx_size()-1 ), ( Lib_get_fy_size()-1 ), CHAR_PLANE ); SST_video_setting(); Lib_recover_plane( shelter_id ); } /* * カメラ調整 */ static void SST_video_setting() { int status; int xpos, ypos; Lib_invdisp(1, 1, "左/右ボタンを押すと終了します" ); Lib_erase_cursor(); SST_strobo_freerun(); for( ; ; ) { status = Lib_see_current_position( &xpos, &ypos ); if( 0 != status ) break; } /* ストロボ終了 */ SST_strobo_stop(); Lib_draw_cursor( 100, 50 ); Lib_chrdisp(1, 1, "               " ); } /*--- 実行 ------------------------------------------------------------------*/ /* * ローカル * トラックボールによる入力 */ void SST_local() { int xpos, ypos; /* ストロボ設定 */ SST_strobo_set(); Lib_display_message( MSG_DISP_X, MSG_DISP_Y, "画像取込開始", "準備が出来たら[確認]を押してください" ); Lib_see_current_position( &xpos, &ypos ); Lib_erase_cursor(); if( ON == Gb_disp_time ) Lib_strtclk_count(); /* ストロボフリーズ */ SST_strobo_freeze( TRANSMIT ); if( ON == Gb_disp_time ) Lib_time_disp( 0, 0 ); /* ストロボの終了 */ SST_strobo_stop(); Lib_draw_cursor( xpos, ypos ); Lib_display_message( MSG_DISP_X, MSG_DISP_Y, "画像取込終了", "確認してください" ); Lib_memory_clear( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_freerun(); } /* * リモート * DIDOによる入力 * DI0:トリガ * DI1:リモート終了 */ void SST_remote() { int process, status; int xpos, ypos; int dummy_x, dummy_y; /* DIDOオープン */ if( ERROR_RETURN == SST_dido_open() ) { /* モジュールが存在しない */ Lib_display_message( MSG_DISP_X, MSG_DISP_Y, "エラー", "モジュールが存在しません。" ); return; } Lib_see_current_position( &xpos, &ypos ); Lib_erase_cursor(); /* ストロボ設定 */ SST_strobo_set(); for( process = ON; OFF != process; ) { status = Lib_see_current_position( &dummy_x, &dummy_y ); if( 0 != status ) process = OFF; switch( SST_dido_read_trigger() ) { case DI_TRIGGER: /* トリガ検出 */ if( ON == Gb_disp_time ) Lib_strtclk_count(); /* ストロボフリーズ */ SST_strobo_freeze( TRANSMIT ); if( ON == Gb_disp_time ) Lib_time_disp( 0, 0 ); case DI_NON: /* 検出しない */ break; case DI_QUIT: /* 終了検出 */ case ERROR_RETURN: /* 異常終了 */ process = OFF; break; } } /* ストロボの終了 */ SST_strobo_stop(); /* DIDOクローズ */ SST_dido_close(); Lib_memory_clear( GRAY_PLANE | LINE_PLANE | CHAR_PLANE ); Lib_freerun(); Lib_draw_cursor( xpos, ypos ); } /*--- ストロボ関連 ----------------------------------------------------------*/ /* * ストロボ設定 */ static void SST_strobo_set() { Lib_set_strobo( O_C_TYPE, SET_ANY_FIELD ); Lib_time_delay( 33 ); } /* * ストロボフリーラン */ static void SST_strobo_freerun() { /* ストロボ設定 */ Lib_set_strobo( O_C_TYPE, SET_1ST_FIELD ); /* ストロボ開始 */ Lib_ctrl_strobo( START_STROBO ); Lib_freerun(); } /* * ストロボフリーズ */ static void SST_strobo_freeze( flag ) int flag; /* 入 力:画像転送フラグ */ { Lib_strobo_freeze( flag ); } /* * ストロボの終了 */ static void SST_strobo_stop() { Lib_ctrl_strobo( STOP_STROBO ); } /*--- DIDO関連 ----------------------------------------------------------*/ /* * DIDOオープン */ static int SST_dido_open() /* [戻り値] NORMAL_RETURN : 正常終了 ERROR_RETURN : 異常終了 [注 記] モジュールNoは0のみ */ { int rtn; rtn = ERROR_RETURN; if( 0 < Lib_open_dido() ) { Gb_module_no = 0; /* DIDOモジュールNo */ rtn = NORMAL_RETURN; } return rtn; } /* * DIDOクローズ */ static void SST_dido_close() { Lib_close_dido(); } /* * DIDOトリガ読みだし */ static int SST_dido_read_trigger() /* [戻り値] DI_TRIGGER : トリガ検出 DI_QUIT : 終了検出 DI_NON : 検出しない(処理なし) ERROR_RETURN : 異常終了 */ { int rtn; int bit_pattern; int trig_pattern; rtn = NORMAL_RETURN; if( NORMAL_RETURN == Lib_read_dido( Gb_module_no, &bit_pattern ) ) { trig_pattern = bit_pattern & DI_TRIGGER; if( DI_TRIGGER == trig_pattern ) { /* トリガ検出 */ if( last_pattern != trig_pattern ) { last_pattern = trig_pattern; rtn = DI_TRIGGER; } else rtn = DI_NON; } else if( DI_QUIT == (bit_pattern & DI_QUIT) ) { /* 終了 */ last_pattern = DI_NON; rtn = DI_QUIT; } else { last_pattern = DI_NON; rtn = DI_NON; } } else rtn = ERROR_RETURN; return rtn; } /*---------------------------------------------------------------------------*/