|
|
|
ผมทำโปรแกรมควบคุม หลอด LED ผ่าน Usb pararelprot คัยพอมีความรู้ทางนี้แนะนำหน่อยคับ |
|
|
|
|
|
|
|
คัยพอมีคำแนะนำหัยกับโปรแกรมหน่อยคับ
ช่วยทีคับตอนนี้กำลังหาทางทำอยู่คับแต่ไม่ได้
C# คับ
|
|
|
|
|
Date :
2011-03-29 21:20:25 |
By :
kit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มีคัยพอมีความรู้เขียนโปรแกรมทางแนะนำหน่อยคับ
ขอบคุณสำหรับคำตอบนะคับ
|
|
|
|
|
Date :
2011-03-30 01:00:41 |
By :
kit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สาธุมีคนหัยคำแนะนำหน่อย
ขอบคุณล้วงหน้านะคับ สาธุ
|
|
|
|
|
Date :
2011-03-30 14:52:58 |
By :
kit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค้ด C# หรือป่าวค่ะ
สนใจเรื่องการควบคุมอุปกรณ์เหมือนกัน
ถ้าคัยมีความรู้ด้านนี้ก็ตอบให้หน่อนนะค่ะ
|
|
|
|
|
Date :
2011-03-30 16:50:01 |
By :
aofaff |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Search คำว่า C# Serial Port เยอะแยะ
|
|
|
|
|
Date :
2011-03-30 17:03:32 |
By :
อิอิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ของทำใส่ parelprot คับต้องทำยังไงหรอคับ
ขอบคุณสำหรับคำตอบนะคับคุณ Guest
|
|
|
|
|
Date :
2011-03-30 19:52:35 |
By :
kit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยดูโค้ดหน่อยคับไม่จะติดต่อกับ pararelprot ยังไงคับ
Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace Application2
{
public partial class Form1 : Form
{
private StreamWriter swSender;
private StreamReader srReceiver;
private TcpClient tcpServer;
private delegate void UpdateLogCallback(string strMessage);
private delegate void CloseConnectionCallback(string strReason);
private Thread thrMessaging;
private IPAddress ipAddr;
private bool Connected;
int stand = 888;
Boolean swith = false;
int lastValue;
public class PortAccess
{
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
}
private void setLED(int iValue, Label lable)
{
if (lastValue != iValue) { swith = false; }
reset();
if(swith ==false){
lable.BackColor = Color.RoyalBlue;
SendMessage(iValue);
swith = true;
}else{
lable.BackColor = Color.White ;
SendMessage(0);
swith = false;
}
lastValue = iValue;
}
private void reset()
{
label1.BackColor = Color.White;
label2.BackColor = Color.White;
label3.BackColor = Color.White;
label4.BackColor = Color.White;
label5.BackColor = Color.White;
label6.BackColor = Color.White;
label7.BackColor = Color.White;
label8.BackColor = Color.White;
}
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{
PortAccess.Output(stand, 0);
reset();
Environment.Exit(0);
}
private void InitializeConnection()
{
ipAddr = IPAddress.Parse("192.168.1.11");
tcpServer = new TcpClient();
tcpServer.Connect(ipAddr, 1986);
Connected = true;
swSender = new StreamWriter(tcpServer.GetStream());
swSender.WriteLine("Start");
swSender.Flush();
thrMessaging = new Thread(new ThreadStart(ReceiveMessages));
thrMessaging.Start();
}
private void ReceiveMessages()
{
srReceiver = new StreamReader(tcpServer.GetStream());
string ConResponse = srReceiver.ReadLine();
if (ConResponse[0] == '1')
{
//this.Invoke(new UpdateLogCallback(this.UpdateLog), new object[] { "Connected Successfully!" });
}
else
{
string Reason = "Not Connected: ";
Reason += ConResponse.Substring(2, ConResponse.Length - 2);
this.Invoke(new CloseConnectionCallback(this.CloseConnection), new object[] { Reason });
return;
}
while (Connected)
{
//this.Invoke(new UpdateLogCallback(this.UpdateLog), new object[] { srReceiver.ReadLine() });
}
}
private void CloseConnection(string Reason)
{
Connected = false;
swSender.Close();
srReceiver.Close();
tcpServer.Close();
}
private void SendMessage(int msg)
{
swSender.WriteLine(msg);
swSender.Flush();
}
public void OnApplicationExit(object sender, EventArgs e)
{
reset();
if (Connected == true)
{
Connected = false;
swSender.Close();
srReceiver.Close();
tcpServer.Close();
}
}
private void Form1_Load(object sender, EventArgs e)
{
InitializeConnection();
}
private void Form1_Closed(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void button9_Click(object sender, EventArgs e)
{
SendMessage(0);
reset();
}
private void button1_Click(object sender, EventArgs e)
{
setLED(1, label1);
}
|
|
|
|
|
Date :
2011-03-31 00:17:19 |
By :
kit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะแปลงโค้ดควบคุม หลอด led ให้เป็นการควบคุมผ่าน pararelprot
มันต้องเพิ่มส่วนไหนบ้างค่ะ
|
|
|
|
|
Date :
2011-04-01 13:23:11 |
By :
aofaff |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|