// !autopilot.txtの,Orient部分のデータを自動生成するマクロ // // M. Endo // 05/04/03 3.6.0専用に改造.VR Viewのマクロ機能を利用. //--------------------------------------------------------------------------- //- グローバル変数 ---------------------------------------------------------- //--------------------------------------------------------------------------- Public M_Pic = 0 // 実時間のケース(1)か定常のケースか(0)のフラグ Public vr_viewer // Window ID of the VR Viewer Public Vorigin = 42 // 変数の設定が始まる行 Public Ver = 200 // 入力ファイルのバージョン //--------------------------------------------------------------------------- //- メインルーチン ---------------------------------------------------------- //--------------------------------------------------------------------------- //------------------------------------- Windowの状態チェック vr_viewer = GETID("PHOENICS - VR Viewer","PHOENICS Manager") ifb vr_viewer < 0 Msgbox("VR Viewerを起動して下さい") exitexit Endif Ctrlwin(vr_viewer, activate) //------------------------------------- !autopilotがなければ作る datfile = FOPEN("!Autopilot_set.txt", F_READ) Ifb datfile <0 fclose(datfile) datfile = FOPEN("!Autopilot_set.txt", F_WRITE) tmp = FOPEN("!Make_Autopilot.uws", F_READ) i = 40 While 1 cline = Fget(tmp, i) i = i+1 If Pos("ここから下はひな形", cline) >0 then Break Wend While 1 cline = Fget(tmp, i) i = i+1 If Length(cline) = 0 then Break FPUT(datfile, COPY(cline, 3, 999)) Wend Fclose(tmp) Endif fclose(datfile) //------------------------------------- Vorigin取得 Vorigin = FindVorigin() datfile = FOPEN("!Autopilot_set.txt", F_READ or F_WRITE) //------------------------------------- Main windowの大きさを記録する w_width = STATUS(vr_viewer, ST_WIDTH) w_height = STATUS(vr_viewer, ST_HEIGHT) dmy = FGET(datfile, 3) dmy = COPY(dmy, 1,11)+FORMAT(w_width, 4,0)+" "+FORMAT(w_height, 4,0)+COPY(dmy, 21, 999) FPUT(datfile, dmy, 3) //------------------------------------- 変数はPressureに変える if IsOn(0,3) = 0 then Control(0,3) //------------------------------------- 変数の番号を取得 Control(3,3) variables = open_window("Viewer Options","") number = Getitem(variables, ITM_LIST) for i = 0 to 15 dmy = FGET(datfile, Vorigin+i) for j = 0 to number-1 ifb POS(ALL_ITEM_LIST[j], dmy)>0 str1 = COPY(dmy, 1,14) + Format(j+1, 2, 0) str2 = COPY(dmy,17,999) FPUT(datfile, str1+str2, Vorigin+i) break endif next next Sckey(variables, VK_Alt, VK_F4) Fclose(datfile) //------------------------------------- マクロ記録 tmpfile = FOPEN("!Auto", F_WRITE) FPUT(tmpfile, " ") fclose(tmpfile) Control(2.5, -1.5) macwindow = open_window("macro functions", "") ifb chkbtn(macwindow, "start from default") = 0 // Runモードなら clkitem(macwindow, "Yes") // Saveモードに切り替え endif clkitem(macwindow, "browse for file") filewindow = open_window("名前を付けて保存", "") sendstr(filewindow, "!Auto", 1, 1) clkitem(filewindow, "保存") while status(filewindow, ST_ACTIVE)>0; wend clkitem(macwindow, "OK") confwindow = open_window("macro message", "") clkitem(confwindow, "OK") //------------------------------------- マクロの最終行を書き換える datfile = FOPEN("!Auto", F_READ or F_WRITE) lines = fget(datfile, -1) fput(datfile, "EXIT", lines) fclose(datfile) //--------------------------------------------------------------------------- //- 共通ライブラリー -------------------------------------------------------- //--------------------------------------------------------------------------- Procedure PicSet(VMin, VMax, Varn) //---------------------------------------- // 変数Varnにセット,(VMin, VMax)のレンジにセットする // Ver.3.6.0専用 // Control(3,3) variables = Open_Window("Viewer options", "") mouseorg(variables, 1) Clkitem(variables, Varn, clk_list) Ifb Val(VMin) < Val(Vmax) BTN(LEFT,CLICK,186,112,30) sendstr(variables, VMin, 1, 1) BTN(LEFT,CLICK,186,191,30) sendstr(variables, VMax, 2, 1) Endif Sckey(variables, VK_Alt, VK_F4) While Getid("Viewer options", "") > 0; Wend // Windowが閉じるまで待つ Fend Function Open_Window(id_str1, id_str2) //------------------------------------ // id_strで表されるウィンドウのIDが確定するまでループ // 戻り値 : ウィンドウID // While 1 Result = Getid(id_str1, id_str2) If Result > 0 Then Break Wend Sleep(0.1) Fend Function CPU_Busy(Load) //--------------------------------------------------- // CPUの負荷がLoadになるまでループ // 戻り値 : CPU負荷 // While 1 Result = CPUUSERATE() If Result < Load Then Break Wend Sleep(0.1) Fend Function IsOn(x,y) //-------------------------------------------------------- // ボタンが押されているかを調査して返す. // (x, y) : 調査するボタン // 戻り値 : On = 1 Off = 0 id = GETID("VR VIEWER","ControlWnd") MOUSEORG(id,1) c = PEEKCOLOR(10+x*30, 80+y*30) if c = 0 then c = 1 else c = 0 Result = c Fend Procedure Control(x, y) //--------------------------------------------------- // Control Windowのボタンを押す. // (x, y) : 押すボタン id = GETID("VR VIEWER","ControlWnd") MOUSEORG(id,1) BTN(LEFT,CLICK, 20+x*30, 90+y*30, 50) Fend S Function Get_zmax() //------------------------------------------------------- // q1ファイルを開き,zの最大値を調べて返す. data = Fopen("q1") //------------------------------zの最大値を取得 i = 0 While 1 i = i + 1 If Pos("> DOM", Fget(data, i))>0 Then Break Wend Result = Val(Copy(Fget(data, i), 52, 12)) Fclose(data) Fend Function FindVorigin() //---------------------------------------------------- // !Autopilot_set.txtを開き,Voriginを返す. data = Fopen("!Autopilot_set.txt") lines = fget(data,-1) for i = 1 to lines If Pos("!変数名", Fget(data, i))>0 Then Break next Result = i+1 if i = lines then msgbox("入力ファイルにエラーがあります") Fclose(data) Fend //ここから下はひな形なので,編集しないように //# UWSC専用設定データファイル 数値を置くカラムの位置は変えないでね.##### //#### Version 200 # //Window =1012 793 # Main windowの大きさ //dz = 0.4 # (x-y)面スライスを作る間隔 //force = 1 # 強制的にsteady caseと判断する // // // //!変数名-------!Print-!最小-------!最大-------! //Pressure 0 N N 0 0 //X-Velocity 0 N 0 0 //Y-Velocity 0 N 0 0 //Z-Velocity 0 N 0 0 //Temperature 0 N N 0 0 //DEN1 0 N 0 0 //VFOL 0 N 0 0 //PRPS 0 N 0 0 //SURN 0 N 0 0 //Velocity 0 NNN 0 0 //MACH 0 N N 0 0 //C1 0 N N 0 0 //C2 0 N N 0 0 //C3 0 N 0 0 // | ||| // | ||+ z方向スライスを表示するかどうかのスイッチ // | |+- ベクトルを表示するかどうかのスイッチ // | +-- 印刷するかどうかのスイッチ // +---- 変数の出てくる場所を示す(自動的に取得される) // // 変数レンジの最小と最大を同じにすると自動設定となる