因为是个人用途,所以选择的都是最低端的配置,这里介绍一下大致的体验,不是标准测试,仅供参考。
测试环境是Windows 2008 R2+MySQL5.5+IIS+MVC4 (更多…)
因为是个人用途,所以选择的都是最低端的配置,这里介绍一下大致的体验,不是标准测试,仅供参考。
测试环境是Windows 2008 R2+MySQL5.5+IIS+MVC4 (更多…)
public static string Str2Hex(string s)
{
string result = string.Empty;
byte[] arrByte = System.Text.Encoding.GetEncoding(“GB2312”).GetBytes(s);
for (int i = 0; i < arrByte.Length; i++)
{
result += “0x” + System.Convert.ToString(arrByte[i], 16).ToUpper() + “,”; //Convert.ToString(byte, 16)把byte转化成十六进制string
}
return result;
}
在淘宝“高校基地”店买了一个http://item.taobao.com/item.htm?spm=a1z0k.6846101.1130973605.d4915209.SAObbz&id=36884805726,还有一种是PWM输出,这个代码比较多,就是最普遍的发送命令,然后等待信号,再计时,用声速推算距离,但是TX输出把我搞乱了。
终于在http://forum.arduino.cc/index.php?topic=88388.5;wap2找到了答案:
#include <SoftwareSerial.h>
// TX_PIN is not used by the sensor, since that the it only transmits!
#define PING_RX_PIN 6
#define PING_TX_PIN 7SoftwareSerial mySerial(PING_RX_PIN, PING_TX_PIN);
long inches = 0, mili = 0;
byte mybuffer[4] = {0};
byte bitpos = 0;void setup() {
Serial.begin(9600);mySerial.begin(9600);
}void loop() {
bitpos = 0;
while (mySerial.available()) {
// the first byte is ALWAYS 0xFF and I’m not using the checksum (last byte)
// if your print the mySerial.read() data as HEX until it is not available, you will get several measures for the distance (FF-XX-XX-XX-FF-YY-YY-YY-FF-…). I think that is some kind of internal buffer, so I’m only considering the first 4 bytes in the sequence (which I hope that are the most recent! 😀 )
if (bitpos < 4) {
mybuffer[bitpos++] = mySerial.read();
} else break;
}
mySerial.flush(); // discard older values in the next readmili = mybuffer[1]<<8 | mybuffer[2]; // 0x– : 0xb3b2 : 0xb1b0 : 0x–
inches = 0.0393700787 * mili;
Serial.print(“PING: “);
Serial.print(inches);
Serial.print(“in, “);
Serial.print(mili);
Serial.print(“mili”);delay(100);
}
说明:模块每次输出一帧,含4个8位数据,帧格式为:0XFF+H_DATA+L_DATA+SUM
1、0XFF: 为一帧开始数据,用于判断。
2、H_DARA:距离数据的高8位。
3、L_DATA:距离数据的低8位。
4、SUM: 数据和用于交验。其0XFF+H_DATA+L_DATA=SUM(仅低8位)
5、H_DATA与L_DATA合成16位数据,即以毫米为单位的距离值。
注意:模块检测最小距离为30cm,在30cm内有物体,将获得不准确信号。
以上代码中没有做SUM校验
如图,因为Yun的网线口比之前的板子挨着引脚近,所以V7插不上去,研究一番,决定加一层排母,垫高一些再插扩展板。最终选择
1.http://item.taobao.com/item.htm?id=20747855300 1个;
2.http://item.taobao.com/item.htm?id=20747511841 2个;
3.http://item.taobao.com/item.htm?id=20747903210 1个;
4.http://item.taobao.com/item.htm?id=20802935165 1个。
另外还想把这些排母焊到一层板子上,不过单买一个洞洞板运费不划算,回头想好了再说。
网站安装时只需要修改web.config中的数据库连接,其他不变,主要是<authentication mode=”Forms”>保持不变。
1. 用默认的admin账号登录,初始密码是password,界面上有说明,登录后可以在系统设置中修改;
2. 添加一个域帐号作为切换到域帐号登录模式后的管理员账号,新建用户,Admin->User Accounts->Create New User->User Name的格式为domain\username,具体如ccppg\mengfanyong,其他随便填,密码勾选Random Password; (更多…)
目前儿童数字出版的产品使用终端,以PC、平板电脑为主,前者体验最差,平板对于孩子来说,依然是极其缺乏想象力的东西。而有着悠久历史和深度认知的儿童玩具目前还停留在石器时代,未来一定是通过物联网技术,将玩具纳入到智能网络,加上数字出版平台的内容支撑,变成全新的儿童数字出版形态。
先看新闻:
污染十年为何难了? 武强县一化工厂遭村民围堵
图为村民向记者指明厂区围墙的临时排水孔。 中国环境报记者姚伊乐摄
“不要有污染的金钱,只要有尊严地活着。”河北省衡水市武强县、沧州市献县和泊头市11个村的村民将写着这些字样的纸板悬挂在简易凉棚上。 (更多…)
在使用Entity Framework 的Database frist或model first时,怎么在model上添加验证的特性?
因为此时的Model是是VS 工具怎么生成的,直接加attribute到modle类上是太现实也不合理。一个比较合理做法,就是用 buddy class的方式来实现。
比如有一个Model类: Movie。那我们就可以添加一个局部类文件,局部类的内容如下:
using System.ComponentModel.DataAnnotations;
namespace Movies.Models
{
[MetadataType(typeof(MovieMetadata))]
public partial class Movie
{
private class MovieMetadata //这个类名随便起,相当于把这个类里面的东西追加给Movie,这个追加是用[MetadataType]实现的
{
[Required(ErrorMessage="Titles are required")]
public string Title { get; set; }
[Required(ErrorMessage="The Price is required.")]
[Range(5,100,ErrorMessage ="Movies cost between $5 and $100.")]
public decimal Price { get; set; }
}
}
}
通过在这个局部类文件中添加需要的验证属性就可以了。
以上内容来自http://www.cnblogs.com/ITHelper/archive/2013/01/08/2851442.html
另外,对于有文件上传的时候,还可以写一个扩展的model,比如:
public class MovieViewModel
{
[FileExtensions(Extensions = “jpg,gif,png”, ErrorMessage = “jpg,gif,png”)]
public HttpPostedFileBase CoverImageFile { get; set; }
public Movie movie { get; set; }
}
这样,在给control生成强类型view的时候就用MovieViewModel。
经过反复实践,发现MySql Connector.Net 6.6.5可以适配VS2012,其他版本,包括最新的6.7.4版,安装以后在vs2012中找不到mysql provider。
1. 在服务器管理器里安装iis角色;
2. 安装framework4或更新的,dotnetfx45_full_x86_x64;
3. 安装mvc支持,AspNetMVC3ToolsUpdateSetup;
4. 安装mysql connector,mysql-connector-net-6.5.7。