Commit 38559f8f by eddy ramirez

Subir nuevo archivo

parent cf37e173
var x;
var xon_off = "off";
var hor_on_off = 0;
var bot_led1 = 0;
var bot_led2 = 0;
var bot_led3 = 0;
//var dis1,tp1,hr1,tp2,pin1;
x=$(document);
x.ready(inicializarEventos);
function inicializarEventos()
{
var xx;
xx=$(document);
xx.mousemove(moverMouse);
xx=$("#but01");
xx.click(Boton01);
xx=$("#luz_envio01");
xx.click(Luz_Envio_led);
xx=$("#hor_but_on_off");
xx.click(but_hor_fun1);
xx=$("#hor_fun03");
xx.click(but_hor_fun3);
xx=$("#hor_fun05");
xx.click(but_hor_fun5);
xx=$("#bled1");
xx.click(led1);
xx=$("#bled2");
xx.click(led2);
xx=$("#bled3");
xx.click(led3);
inicio();
setInterval(sensores_todo,500);
//setInterval(sensor2_luz,500);
//setInterval(sensor_hor,500);
}
function moverMouse(event)
{
var x1;
x1=$("#wb_wb_corx");
x1.css('color', 'red');
x1.text("coordenada x="+event.clientX);
x1=$("#wb_wb_cory");
x1.css('color', '#C0FF57');
x1.text("coordenada y="+event.clientY);
}
function inicio(){
var inw;
var x1=$("#but01");
var t;
var xm=createXmlHttpRequestObject();
//var t1=$("#retorno1");
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
inw=parseInt(xm.responseXML.getElementsByTagName('act')[0].childNodes[0].nodeValue);
if(inw==0){
xon_off="off";
//x1.html('<button id="but01">Pulse para Encender<hr> <img src="img/led_negro.png"></button>');
x1.css({'background-image': 'url("img/Led_negro.png")'});
}
else {
xon_off="on";
//x1.html('<button id="but01">Pulse para Apagar<hr> <img src="img/led_verde.png"></button>');
x1.css({'background-image': 'url("img/Led_verde.png")'});
}
//t1.html('<div id="retorno1">Valor de adc='+xon_off+'</div>');
}
}
};
xm.open('GET','OnOff.xml',true);
//xm.send($('#led_data').serialize());
xm.send(null);
//****************************************************************
t=$("#bled1");
if(bot_led1==0){
t.css({'background-image': 'url("img/Led_negro.png")'});
}
else{
t.css({'background-image': 'url("img/Led_amarillo.png")'});
}
t=$("#bled2");
if(bot_led2==0){
t.css({'background-image': 'url("img/Led_negro.png")'});
}
else{
t.css({'background-image': 'url("img/Led_rojo.png")'});
}
t=$("#bled3");
if(bot_led3==0){
t.css({'background-image': 'url("img/Led_negro.png")'});
}
else{
t.css({'background-image': 'url("img/Led_naranja.png")'});
}
}
function Boton01(){
var t=$(this);
var ld=$("#ld1");
var t1=$("#retorno1");
if(xon_off=="off"){
//t.html('<button id="but01">Pulse para Apagar<hr> <img src="img/led_verde.png"></button>');
t.css({'background-image': 'url("img/Led_verde.png")'});
xon_off="on";
ld.attr("value",xon_off);
}
else{
//t.html('<button id="but01">Pulse para Encender<hr> <img src="img/led_negro.png"></button>');
t.css({'background-image': 'url("img/Led_negro.png")'});
xon_off="off";
ld.attr("value",xon_off);
}
t1.html('<div id="retorno1">Valor de adc='+xon_off+'</div>')
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('POST','led1.xml',true);
xm.send($('#on_off_data').serialize());
}
function Luz_Envio_led(){
var va_rojo,va_verde,va_azul,va_uv;
var va_f_rojo,va_f_verde,va_f_azul,va_f_uv;
va_rojo=$("#luz_in_rojo");
va_verde=$("#luz_in_verde");
va_azul=$("#luz_in_azul");
va_uv=$("#luz_in_uv");
va_f_rojo=$("#lrojo");
va_f_verde=$("#lverde");
va_f_azul=$("#lazul");
va_f_uv=$("#luv");
va_f_rojo.attr("value",va_rojo.val());
va_f_verde.attr("value",va_verde.val());
va_f_azul.attr("value",va_azul.val());
va_f_uv.attr("value",va_uv.val());
var xm=createXmlHttpRequestObject();
xm.onreadystatechange=function(){
if(xm.readyState==4){
if(xm.status==200){
}
}
};
xm.open('POST','form_luztodo.xml',true);
xm.send($('#luz_form_envio').serialize());
}
function but_hor_fun1(){
var bt1;
var lbt1;
lbt1=$("#lhor_on");
bt1=$("#hor_but_on_off");
//bt1.attr("value","ttttt");
if(hor_on_off==0){
hor_on_off=1;
lbt1.attr("value",hor_on_off);
bt1.attr("value","Apagar");
}
else{
hor_on_off=0;
lbt1.attr("value",hor_on_off);
bt1.attr("value","Encender");
}
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('POST','hor_en.xml',true);
xm.send($('#form_hor_encender').serialize());
}
function led1(){
var t=$(this);
if(bot_led1==0){
t.css({'background-image': 'url("img/Led_amarillo.png")'});
bot_led1=1;
}
else{
t.css({'background-image': 'url("img/Led_negro.png")'});
bot_led1=0;
}
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('GET','/btled1.xml',true);
xm.send(null);
}
function led2(){
var t=$(this);
if(bot_led2==0){
t.css({'background-image': 'url("img/Led_rojo.png")'});
bot_led2=1;
}
else{
t.css({'background-image': 'url("img/Led_negro.png")'});
bot_led2=0;
}
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('GET','/btled2.xml',true);
xm.send(null);
}
function led3(){
var t=$(this);
if(bot_led3==0){
t.css({'background-image': 'url("img/Led_naranja.png")'});
bot_led3=1;
}
else{
t.css({'background-image': 'url("img/Led_negro.png")'});
bot_led3=0;
}
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('GET','/btled3.xml',true);
xm.send(null);
}
/*
function but_hor_fun2(){
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('GET','hor_fun02.xml',true);
xm.send(null);
}
*/
function but_hor_fun3(){
var idfre;
var lfre;
if(hor_on_off==1){
idfre=$("#hor_in_fre");
lfre=$("#lfun3");
lfre.attr("value",idfre.val());
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('POST','hor_fun03.xml',true);
xm.send($("#form_hor_fun03").serialize());
}
}
function but_hor_fun5(){
var idfre;
var lfre;
if(hor_on_off==1){
idfre=$("#hor_in_fre");
lfre=$("#lfun5");
lfre.attr("value",idfre.val());
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('POST','hor_fun05.xml',true);
xm.send($("#form_hor_fun05").serialize());
}
}
function sensores1(){
var tom;
var dom;
var sel=0;
var oon;
oon=xon_off;
if(oon=="on"){
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function(){
if(xm.readyState==4){
if(xm.status==200){
tom=xm.responseXML.getElementsByTagName('rojo')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_rojo");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('verde')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_verde");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('azul')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_azul");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('uv')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_uv");
dom.text(tom);
/*
tom=xm.responseXML.getElementsByTagName('tpa')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_t1");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('tpb')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_t2");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('hr')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_hr1");
dom.text(tom);
*/
}
}
};
xm.open('GET','sensores.xml',true);
xm.send(null);
}
}
function sensor2_luz(){
var tom;
var dom;
var sel=0;
var oon;
oon=xon_off;
if(oon=="on"){
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function(){
if(xm.readyState==4){
if(xm.status==200){
tom=xm.responseXML.getElementsByTagName('tp1')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_tp1");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('tp2')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_tp2");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('hr1')[0].childNodes[0].nodeValue;
dom=$("#wb_luz_t_hr1");
dom.text(tom);
}
}
};
xm.open('GET','sensores1_2.xml',true);
xm.send(null);
}
}
function sensor_hor(){
var tom;
var dom;
var sel=0;
var oon;
oon=xon_off;
if(oon=="on"){
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function(){
if(xm.readyState==4){
if(xm.status==200){
tom=xm.responseXML.getElementsByTagName('adc1')[0].childNodes[0].nodeValue;
dom=$("#hor_adc1");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('adc2')[0].childNodes[0].nodeValue;
dom=$("#hor_adc2");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('adc3')[0].childNodes[0].nodeValue;
dom=$("#hor_adc3");
dom.text(tom);
tom=xm.responseXML.getElementsByTagName('adc4')[0].childNodes[0].nodeValue;
dom=$("#hor_adc4");
dom.text(tom);
}
}
};
xm.open('GET','sensores1_3.xml',true);
xm.send(null);
}
}
function Motor_f1(){
var xm=createXmlHttpRequestObject();
xm.onreadystatechange = function() {
if(xm.readyState == 4) {
if(xm.status == 200) {
}
}
};
xm.open('GET','M_f1.xml',true);
xm.send(null);
}
function sensores_todo(){
sensores1();
sensor2_luz();
setTimeout(sensor_hor(),100);
}
function createXmlHttpRequestObject() {
if(window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else if(window.ActiveXObject) {
//Available MSXML object IDs
var progId = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'];
//Iterate through MSXML object IDs
for(var i in progId)
{
try
{
//Instantiate the highest version of MSXML
return new ActiveXObject(progId[i]);
}
catch(e)
{
}
}
}
return null;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment