PHPのプログラム
先ほどのプログラム
走り終わるのを時間待ちして,
時間待ちでは信頼性が低いので,
while (file_get_contents("http://192.168.0.100/?00=S") + 0 == 0)
;
Sコマンドは,
リスト3 位置検出ルーチンを付加
#! /usr/local/bin/php
<?php
$url = "http://192.168.0.100/";
for (;;) {
file_get_contents($url."?00=C");
file_get_contents($url."?01=D");
file_get_contents($url."?02=D");
file_get_contents($url."?03=C");
while (file_get_contents($url."?04=S") + 0 == 0)
;
file_get_contents($url."?00=A");
file_get_contents($url."?01=A");
file_get_contents($url."?02=A");
file_get_contents($url."?03=A");
file_get_contents($url."?04=c");
file_get_contents($url."?03=d");
file_get_contents($url."?02=d");
file_get_contents($url."?01=c");
while (file_get_contents($url."?00=S") + 0 == 0)
;
file_get_contents($url."?04=A");
file_get_contents($url."?03=A");
file_get_contents($url."?02=A");
file_get_contents($url."?01=A");
}
?>
なお,
ポイントも動かそう
ポイントの制御も,
リスト4のプログラムでは,
リスト4 引き込み線。車輪が絶縁レールをまたぐ瞬間があるため,
#! /usr/local/bin/php
<?php
$url = "http://192.168.0.100/";
#
# +--------|---------+
# | |
# +---03---|<<<02<<<<p1
# <<<<<<<|<<<00<<<|
#
file_get_contents($url."?01=p");
file_get_contents($url."?00=D");
file_get_contents($url."?02=D");
while (file_get_contents($url."?03=S") + 0 == 0)
;
file_get_contents($url."?00=A");
file_get_contents($url."?02=A");
sleep(5); # wait in station
#
# +>>>>>>>>|---------+
# | |
# +<<<03<<<|---02---<p1
# -------|---00---|
#
file_get_contents($url."?01=P");
file_get_contents($url."?03=D");
sleep(5); # make sure of leaving rail 02
while (file_get_contents($url."?02=S") + 0 == 0)
;
file_get_contents($url."?03=A");
sleep(5); # wait in station
#
# +--------|>>>>>>>>>+
# | |
# +---03---|<<<02<<<<p1
# -------|---00---|
#
file_get_contents($url."?01=P");
file_get_contents($url."?02=D");
sleep(5); # make sure of leaving rail 03
while (file_get_contents($url."?03=S") + 0 == 0)
;
file_get_contents($url."?02=A");
sleep(5); # wait in station
#
# +>>>>>>>>|---------+
# | |
# +<<<03<<<|---02---<p1
# -------|---00---|
#
file_get_contents($url."?01=P");
file_get_contents($url."?03=D");
sleep(5); # make sure of leaving rail 02
while (file_get_contents($url."?02=S") + 0 == 0)
;
file_get_contents($url."?03=A");
sleep(5); # wait in station
#
# +--------|>>>>>>>>>+
# | |
# +---03---|<<<02<<<<p1
# -------|---00---|
#
file_get_contents($url."?01=P");
file_get_contents($url."?02=D");
sleep(5); # make sure of leaving rail 03
while (file_get_contents($url."?03=S") + 0 == 0)
;
file_get_contents($url."?02=A");
sleep(5); # wait in station
#
# +<<<<<<<<|---------+
# | |
# +>>>03>>>|>>>02>>><p1
# >>>>>>|---00---|
#
file_get_contents($url."?01=p");
file_get_contents($url."?03=d");
file_get_contents($url."?02=d");
while (file_get_contents($url."?00=S") + 0 == 0)
;
file_get_contents($url."?03=A");
file_get_contents($url."?02=A");
?>
リスト4の実行結果を動画で見てみましょう。
引き込み線プログラムの実行
車両が進むまで待って,