tlink平台数据转发 c# 控制台程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Timers;
using System.Data;
using Newtonsoft; namespace Tlink_Send
{
class Program
{
public static string HttpPost(string Url, string postDataStr)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
Stream myRequestStream = request.GetRequestStream();
StreamWriter myStreamWriter = new StreamWriter(myRequestStream, Encoding.GetEncoding("gb2312"));
myStreamWriter.Write(postDataStr);
myStreamWriter.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close(); return retString;
} static void Main(string[] args)
{
Console.WriteLine("江苏xx电气公司OPC-Tlink转发工具");
//Console.ReadKey();
System.Timers.Timer maxTimer = new System.Timers.Timer();
maxTimer.Elapsed += new ElapsedEventHandler(Tmr_Elapsed);
// 设置引发时间的时间间隔 此处设置为1秒(1000毫秒)
maxTimer.Interval = ;
maxTimer.Enabled = true; //Console.WriteLine(album.ToString());
System.Threading.Thread.Sleep();
Console.ReadKey(); } static void Tmr_Elapsed(object sender, ElapsedEventArgs e)
{
Newtonsoft.Json.Linq.JObject jsonObject = new Newtonsoft.Json.Linq.JObject(); jsonObject.Add("deviceNo", "这里替换成你自己的设备编号"); dynamic album = jsonObject; album.sensorDatas = new Newtonsoft.Json.Linq.JArray() as dynamic; dynamic song = new Newtonsoft.Json.Linq.JObject();
song.sensorsId = ;
song.value = (System.DateTime.Now.Millisecond-).ToString();
Console.WriteLine("江苏xx电气公司OPC-Tlink转发工具");
Console.WriteLine("传感器1的采集值为"+ song.value);
album.sensorDatas.Add(song); song = new Newtonsoft.Json.Linq.JObject();
song.sensorsId = ;
song.value = (System.DateTime.Now.Millisecond+).ToString();
Console.WriteLine("江苏xx电气公司OPC-Tlink转发工具");
Console.WriteLine("传感器2的采集值为" + song.value);
album.sensorDatas.Add(song); song = new Newtonsoft.Json.Linq.JObject();
song.sensorsId = ;
song.value = (System.DateTime.Now.Millisecond-).ToString();
Console.WriteLine("江苏xx电气公司OPC-Tlink转发工具");
Console.WriteLine("传感器3的采集值为" + song.value);
album.sensorDatas.Add(song); //Console.WriteLine(album.ToString());
HttpPost("http://api.tlink.io/tlink_interface/api/device/createDataPonit.htm", album.ToString());
Console.ReadKey();
}
}
}
tlink平台数据转发 c# 控制台程序的更多相关文章
- 万物云平台数据转发 c# 控制台程序
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- 中国移动物联网平台数据转发 c# 控制台程序
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- 利用irc服务器做物联网数据转发 c# winform程序
利用irc协议的优点: 免费,不用购买服务器就可以实现稳定公网转发数据 开源,irc的客户端和开源库众多,省去了自己造轮子的时间 历史悠久,互联网诞生伊始就有irc 缺点:安全性比较差 简单协议接收可 ...
- 《图解HTTP》读书笔记(七:通信数据转发程序-代理/网关/隧道)
HTTP通信时,除客户端和服务器以外,还有一些用于通信数据转发的应用程序,例如代理.网关和隧道,它们可以配合服务器工作.这些服务器和应用程序可以将请求转发给通信线路上的下一站服务器,并且能接收从那台服 ...
- HTTP_5_通信数据转发程序:代理、网关、隧道
HTTP通信时,除客户端和服务器之外,还有一些用于通信数据转发的应用程序,例如代理,网关,隧道.配合服务器工作. 代理 转发功能,客户端与服务器之间可有多个代理, 缓存代理:减少服务器压力,透明代理: ...
- 控制台程序实现利用CRM组织服务和SqlConnection对数据库中数据的增删改查操作
一.首先新建一个控制台程序.命名为TestCol. 二.打开App.config在里面加入,数据库和CRM连接字符串 <connectionStrings> <add name=&q ...
- iNeuOS工业互联平台,实现动态图元、计算平台、远程控制、数据转发等,和大厂相比如何
目 录 1. 概述... 2 2. 平台演示... 2 3. 增加按钮组态元件... 2 4. 组态图元旋转及动画... 3 5. 后台容 ...
- C运行时库(C Run-time Library)详解(提供的另一个最重要的功能是为应用程序添加启动函数。Visual C++对控制台程序默认使用单线程的静态链接库,而MFC中的CFile类已暗藏了多线程)
一.什么是C运行时库 1)C运行时库就是 C run-time library,是 C 而非 C++ 语言世界的概念:取这个名字就是因为你的 C 程序运行时需要这些库中的函数. 2)C 语言是所谓的“ ...
- linux下服务端实现公网数据转发
之前在腾讯上使用了一个免费的公网服务器,只有7天,linux系统. 其实有这样的想法,是因为有个研二的师弟问我怎么样才能让连个局域网的电脑通信. 我跟他说了两种方法,一种是找个公网服务器来转发数据,另 ...
随机推荐
- windows2003服务器,时间每隔1小时自动同步一次
有台服务器的时间总是不对,可能是电池快没电了吧,于是想让它时间保持更新状态,但又不想用第三方软件,在百度上查了一下,还真有方法 HKEY_LOCAL_MACHINE->SYSTEM->Cu ...
- iOS.C
iOS开发中C语言的应用: 1. NS_ENUM & NS_OPTIONS http://nshipster.com/ns_enum-ns_options/
- Java Http协议处理类
public class HttpRequest { public static String doGet(String url,String params) throws Exception{ re ...
- 域名ping不通,ip地址ping得通
原因:dns服务器过期,需要更换dns服务器地址
- Spring ApplicationContext(二)环境准备
Spring ApplicationContext(二)环境准备 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) 本节介绍 ...
- easyui 获取特定页签tab
var findTab=$('#mytabs').tabs('getTab','财务信息').panel('options').tab; var findTabIndex = $('#tab').ta ...
- android 使用UDP发送数据 DatagramSocket 创建对象为null
DatagramSocket socket=null; try { socket = new DatagramSocket(); //这里创建对象为空 } catch (SocketExceptio ...
- ros主从关系
主机: 在~/.bashrc里面输入 export ROS_MASTER_URI=http://localhost:11311export ROS_HOSTNAME=192.168.4.1 其ip地址 ...
- java的nio例子
package main; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.Inet ...
- Hibernate学习笔记:基础模型类
根据业务建模型时,有一些字段基本每个表都是需要的,如下表: package com.company.jelly.model; import javax.persistence.EntityListen ...