`
mayufenga1
  • 浏览: 53980 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

obix 协议 通过http协议读写举例

 
阅读更多

1,后台建立obix协议。

 2.建立一个bw 可写的节点

3,获取节点值get

http://10.7.10.15/obix/config/Sampler/pw

4:设置节点值:

http://10.7.10.15/obix/config/Sampler/pw/set/<bool val="true" />

 

下雨了,先回家,等接好图在详细写下,整个过程。

1省了:无法上传图片。

2省了:无法上传图片

3下面是页面内容:

<script type='text/javascript' src='/ord?file:^obixWatch.js'></script>
<script type='text/javascript' src='/ord?file:^jquery.js'></script>
<script type='text/javascript' language='Javascript'>

  var obixWatch = new ObixWatch();
  
  /**
   * Called when the page is loaded
   */
  function start()
  {
    // Build the items to Watch
    var item1 = { uri: '/obix/config/Test/Light1/out/', 
                  handler: watchCallback, 
                  dispName: 'VAV1', 
                  inBody: '',
                  pickle: document.getElementById('abc001') 
                };
    
    var item2 = { uri: '/obix/config/Test/Light2/out/', 
                  handler: watchCallback, 
                  dispName: 'VAV2', 
                  inBody: '',
                  pickle: document.getElementById('abc002') 
                };
    
    var item3 = { uri: '/obix/config/Test/Light3/out/', 
                  handler: watchCallback, 
                  dispName: 'VAV3', 
                  inBody: '',
                  pickle: document.getElementById('abc003') 
                };
	 var item4 = { uri: '/obix/config/Test/Motor/out/', 
				  handler: watchCallback2, 
				  dispName: 'VAV4', 
				  inBody: '',
				  pickle: document.getElementById('abc004') 
	         };
	 var item5 = { uri: '/obix/config/Test/IR_IN/out/', 
		  handler: watchCallback3, 
		  dispName: 'VAV5', 
		  inBody: '',
		  pickle: document.getElementById('abc005') 
	 };
	  var item6 = { uri: '/obix/config/Test/Restive/out/', 
		  handler: watchCallback4, 
		  dispName: 'VAV6', 
		  inBody: '',
		  pickle: document.getElementById('abc006') 
	 };

    // Add the items to Watch                
    obixWatch.addURIs([item1, item2, item3,item4,item5,item6]);
    
    // Start the Watch
    obixWatch.startWatch();

 
  }
  
  /**
   * Called when the page is unloaded
   */
  function stop()
  {
    obixWatch.stopWatch();
  }
  
  /**
   * Call back when the oBIX Watch is updated
   */
  function watchCallback(uriItem, node)
  {
    // Update the inner HTML element with the 'display' part of oBIX
    uriItem.pickle.innerHTML = node.getAttribute('val');  
	var num=node.getAttribute('val'); 
	if(num==5.0){
	    uriItem.pickle.innerHTML ="<img src='images/light_yes.jpg'/>";  
	}
	else{
	    uriItem.pickle.innerHTML ="<img src='images/light_no.jpg'/>";  
	}
  }

    function watchCallback2(uriItem, node)
  {
    // Update the inner HTML element with the 'display' part of oBIX
    uriItem.pickle.innerHTML = node.getAttribute('val');  
	var flag=node.getAttribute('val'); 
	if(flag=="true"){
	    uriItem.pickle.innerHTML ="<img src='images/fenji_yes.jpg'/>";  
	}
	else{
	    uriItem.pickle.innerHTML ="<img src='images/fenji_no.jpg'/>";  
	}
  }
     function watchCallback3(uriItem, node)
  {
    // Update the inner HTML element with the 'display' part of oBIX
    uriItem.pickle.innerHTML = node.getAttribute('val');  
	var flag=node.getAttribute('val'); 
	if(flag=="true"){
	    uriItem.pickle.innerHTML ="有感觉物体存在";  
	}
	else{
	    uriItem.pickle.innerHTML ="没有感觉物体";  
	}
  }
   function watchCallback4(uriItem, node)
  {
    // Update the inner HTML element with the 'display' part of oBIX
    
	var flag=node.getAttribute('val'); 
	   uriItem.pickle.innerHTML = node.getAttribute('val');  
  }


  function ajaxRequest(){
   $.ajax({
   type: "POST",
   url: "/obix/config/Test2/Bw1/set/",
   data: '<bool val="false" />',
   success: function(msg){
     //alert( "data: " + msg );
   }
   });
  }

   function ajaxRequest3(method,httpurl,arg1,arg2){
	  $.ajax({
    type: method,
    url: httpurl,
    data: '<'+ arg1+' val="'+arg2+'"/>',
    success: function(msg){
     //alert( "data: " + msg );
   }
   });
  }


</script> 
</head>

<body onload="start()" onunload="stop()">
<div>
 
  
   <div>
     <fieldset style="width: 500">
     <h1 align="center">灯泡控制</h1><br />
    <table border="1" width="500" height="220" >
    <tr>
      <th>名称</th>
      <th>灯泡状态</th>
      <th colspan="2">控制开关</th>
    </tr>
    <tr>
      <td>灯1</td>
      <td><a id='abc001'>-wait-</a></td>
	  <td> <input type="button" value="开灯" onclick='ajaxRequest3("Post","/obix/config/Test/Light1/set/","real",5 )' /></td>
	  <td>  <input type="button" value="关灯" onclick='ajaxRequest3("post","/obix/config/Test/Light1/set/","real",0 )' /></td>
    </tr>
    <tr>
    <td>灯2</td>
      <td><a id='abc002'>-wait-</a></td>
	 <td> <input type="button" value="开灯" onclick='ajaxRequest3("Post","/obix/config/Test/Light2/set/","real",5 )' /></td>
	  <td>  <input type="button" value="关灯" onclick='ajaxRequest3("post","/obix/config/Test/Light2/set/","real",0 )' /></td>
    </tr>
    <tr>
      <td>灯3</td>
      <td><a id='abc003'>-wait-</a></td>
	  <td> <input type="button" value="开灯" onclick='ajaxRequest3("Post","/obix/config/Test/Light3/set/","real",5 )' /></td>
	  <td><input type="button" value="关灯" onclick='ajaxRequest3("post","/obix/config/Test/Light3/set/","real",0 )' /></td>
    </tr>
    </table>
	  </fieldset>
    </div>
	</div>
</br>
<hr/>
<div>
 <div style="float: left">
   <fieldset style="width: 200">
 <h1 align="center">电机机控制</h1><br />
       <a id='abc004'>-wait-</a>
<table width="200">
  <tr>
   <td>
   <input type="button" value="打开电机" onclick='ajaxRequest3("post","/obix/config/Test/Motor/set/","bool","true" )' />
   <input type="button" value="关闭电机" onclick='ajaxRequest3("post","/obix/config/Test/Motor/set/","bool","false" )' />
   <td>
  </tr>
 </table>
	  </fieldset>
    </div>

	  <div style="float: inherit">
    <fieldset style="width: 300;height:105" >
          
			<h1 align="center">红外感应</h1><br />
       <h1  align="center" style="color: red;font-size: 14"> <a id='abc005'>-wait-</a></h1>
	  </fieldset>
    </div>
	 <div style="float: inherit">
  <fieldset style="width: 300;height:105"">
 <h1  align="center">弯曲度感应</h1><br />
     <h1  align="center" style="color: red;">   <a id='abc006'>-wait-</a></h1>
	  </fieldset>
    </div>
	</div>
</body>
</html>

 用页面的话,延迟会有一些,不如那个applet好,但这样我们就可以操作页面显示更好点,如何要查看调用的节点的路径我们就的看http://localhost/obix/

分享到:
评论
1 楼 worrydog 2017-04-24  
问一下,后端obix服务器怎么搭建?

相关推荐

    使用Python通过oBIX协议访问Niagara数据的示例

    oBIX 全称是 Open Building Information Exchange,它是基于 RESTful Web Service 的接口的标准,用于构建控制系统。oBIX是在专为楼宇自动化设计...本文主要介绍使用 Python 通过 oBIX 协议对 Niagara 软件中的点进行读

    obix协议在java中的配置和使用详解

    主要给大家介绍了关于obix协议在java中的配置和使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。

    oBIX的技术规范开发者必读

    OBIX技术规范,开发OBIX必读,最新一代的楼宇自控集成方式。

    oBIX 1.0 详细介绍

    oBIX 1.0 的详细介绍文档,学习 OBIX 必读。

    OBIX模块帮助文档中文

    OBIX模块中文帮助文档,中文帮助手册,内含协议。用于

    Niagara oBIX初学者指南

    这个教程提供给不一定是开发人员的人, 将提供 oBIX 的基本概述。

    Niagara obix简单配置指南.7z

    环境搭建及如何用 obix 在自己开发的界面去调用 Niagara 里的数据点位,

    Niagara obix简单配置指南

    环境搭建及如何用 obix 在自己开发的界面去调用 Niagara 里的数据点位,

    NodeRed_Niagara_Obix_Node

    通过Obix协议将Node-Red链接到Niagara Station。 仅用于基本读取和写入(“输出”和“设置”)以控制“驱动程序”下的点(在“尼亚加拉树”中)。 并可以使用历史记录连接器读取历史记录 Obix-尼亚加拉设置: 要在...

    obix学习文档

    学习obix的好资料,按着上面的介绍基本能实现obix的所有功能。简单易学。

    oBIX server-开源

    开源的oBIX服务器实现提供了一种基础结构,开发人员可以将其用于具有“有意义的系统”(引用oBIX规范)的项目中的设备集成。

    The Obix Framework-开源

    Obix配置框架是基于XML和Java的配置框架,它使开发人员能够轻松快速地开发可配置的软件应用程序。

    Obix Java Toolkit-开源

    oBIX工具包提供了一个Java软件库,用于实现启用了oBIX的应用程序。 该工具包包含用于obj树,XML编码器/解码器,REST会话管理和Swing诊断工具的数据模型。

    oBIX Watch JavaScript Library-开源

    一个用于与oBIX手表进行交互的开源JavaScript库。 这是用于为建筑物管理系统开发“实时” Web 2.0页面的有用工具。

    Java与Http协议的详细介绍

    主要介绍了Java与Http协议的详细介绍的相关资料,这里提供实例来帮助大家学习理解这部分内容,需要的朋友可以参考下

    Niagara 数据采集 平台的配置图解全过程(网络第一文档)

    Niagara 数据采集 平台的配置图解全过程(网络第一文档) Niagara 数据采集 平台的配置图解全过程(网络第一文档) Niagara 数据采集 平台的配置图解全过程(网络第一文档) Niagara 数据采集 平台的配置图解全过程(网络第...

Global site tag (gtag.js) - Google Analytics