目次

2009年2月12日木曜日

moxaに書き込むコード 09' その[2]

最終的にmoxaに書き込んだコードの全文です。
//for A

serialInit(9600);
pinMode(0, true);
digitalWrite(0,true);
ain1 = analogRead(1);
radioInit(0xDDDD, 0, 11, 2);

var checkb= 1;
var checkc= 1;
var checkd= 1;
var CR = String.fromCharCode(13);
var CRLF = String.fromCharCode(13, 10);
var c = "C192.168.0.111:3000";
var h = "HOST: 192.168.0.111";
var con = "Content-Type: application/x-wwwform-urlencoded";
var p1 = "POST /encounter/ab HTTP/1.1";
var p2 = "POST /encounter/ac HTTP/1.1";
var p3 = "POST /encounter/ad HTTP/1.1";



while(true) {

function onRadioReceive(seq,src,pan,data,rss) {
if (data == 'b' && checkb == 1){
serialSend(c + CR);
serialSend(p1 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checkb = 0;
checkc = 1;
checkd = 1;
}else if(data == 'c' && checkc == 1){
serialSend(c + CRLF);
serialSend(p2 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checkb = 1;
checkc = 0;
checkd = 1;

}else if(data == 'd' && checkd == 1){
serialSend(c + CRLF);
serialSend(p3 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkb = 1;
checkd = 0;

}else{
}

}
radioSend(0xFFFF, 'a');
}


//for B

serialInit(9600);
pinMode(0, true);
digitalWrite(0,true);
ain1 = analogRead(1);
radioInit(0xDDDD, 0, 11, 2);

var checka= 1;
var checkc= 1;
var checkd= 1;
var CR = String.fromCharCode(13);
var CRLF = String.fromCharCode(13, 10);
var c = "C192.168.0.111:3000";
var h = "HOST: 192.168.0.111";
var con = "Content-Type: application/x-wwwform-urlencoded";
var p1 = "POST /encounter/ba HTTP/1.1";
var p2 = "POST /encounter/bc HTTP/1.1";
var p3 = "POST /encounter/bd HTTP/1.1";

while(true) {

function onRadioReceive(seq,src,pan,data,rss) {
if (data == 'a' && checka == 1){
serialSend(c + CR);
serialSend(p1 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 0;
checkc = 1;
checkd = 1;
}else if(data == 'c' && checkc == 1){
serialSend(c + CR);
serialSend(p2 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkc = 0;
checkd = 1;

}else if(data == 'd' && checkd == 1){
serialSend(c + CR);
serialSend(p3 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkc = 1;
checkd = 0;

}else{
}

}
radioSend(0xFFFF, 'b');
}


//for C

serialInit(9600);
pinMode(0, true);
digitalWrite(0,true);
ain1 = analogRead(1);
radioInit(0xDDDD, 0, 11, 2);

var checka= 1;
var checkb= 1;
var checkd= 1;
var CR = String.fromCharCode(13);
var CRLF = String.fromCharCode(13, 10);
var c = "C192.168.0.111:3000";
var h = "HOST: 192.168.0.111";
var con = "Content-Type: application/x-wwwform-urlencoded";
var p1 = "POST /encounter/ca HTTP/1.1";
var p2 = "POST /encounter/cb HTTP/1.1";
var p3 = "POST /encounter/cd HTTP/1.1";

while(true) {

function onRadioReceive(seq,src,pan,data,rss) {
if (data == 'a' && checka == 1){
serialSend(c + CR);
serialSend(p1 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 0;
checkb = 1;
checkd = 1;
}else if(data == 'b' && checkb == 1){
serialSend(c + CR);
serialSend(p2 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkb = 0;
checkd = 1;

}else if(data == 'd' && checkd == 1){
serialSend(c + CR);
serialSend(p3 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkb = 1;
checkd = 0;

}else{
}

}
radioSend(0xFFFF, 'c');
}


//for D

serialInit(9600);
pinMode(0, true);
digitalWrite(0,true);
ain1 = analogRead(1);
radioInit(0xDDDD, 0, 11, 2);

var checka= 1;
var checkb= 1;
var checkc= 1;
var CRLF = String.fromCharCode(13, 10);
var c = "C192.168.0.111:3000";
var h = "HOST: 192.168.0.111";
var con = "Content-Type: application/x-wwwform-urlencoded";
var p1 = "POST /encounter/da HTTP/1.1";
var p2 = "POST /encounter/db HTTP/1.1";
var p3 = "POST /encounter/dc HTTP/1.1";

while(true) {

function onRadioReceive(seq,src,pan,data,rss) {
if (data == 'a' && checka == 1){
serialSend(c + CR);
serialSend(p1 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 0;
checkb = 1;
checkc = 1;
}else if(data == 'b' && checkb == 1){
serialSend(c + CR);
serialSend(p2 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkb = 0;
checkc = 1;

}else if(data == 'c' && checkd == 1){
serialSend(c + CR);
serialSend(p3 + CRLF);
serialSend(h + CRLF);
serialSend(con + CRLF + CRLF);
checka = 1;
checkb = 1;
checkc = 0;

}else{
}

}
radioSend(0xFFFF, 'd');
}

0 件のコメント: