board.py ( File view )

  • By kissjava 2013-10-02
  • View(s):20
  • Download(s):1
  • Point(s): 1
			#coding:utf-8

'''生产管理电子看板'''

from ctypes import *
import time

dll = WinDLL('BX_IV.board.dll')

def send_init(ip='192.168.0.21',screenNo=1):
	iControlType = 852 #BX-5E3:852
	iSendMode = 2     #0:串口通讯模式;2:网口固定IP通讯模式

	iScreenNo = screenNo
	iWidth = 448
	iHeight = 256
	iScreenType = 2   #显示屏类型;1:单基色;2:双基色;3:双基色;注意:BX-4MC只支持三基色;其余类型控制卡都不支持三基色;
	iPixelMode = 1    #点阵类型;1:R+G;2:G+R;该参数只对双基色屏有效 ;默认为2;
	iDataDA = 0       #数据极性;,0x00:数据低有效,0x01:数据高有效;默认为0;
	iDataOE = 0       #OE极性; 0x00:OE 低有效;0x01:OE 高有效;默认为0;
	iRowOrder = 0     #行序模式;0:正常;1:加1行;2:减1行;默认为0;
	iFreqPar = 6      #扫描点频;0~6;默认为0;
	pCom = "COM1"     #串口名称;串口通讯模式时有效;例:COM1
	iBaud = 57600     #串口波特率:目前支持9600、57600;默认为57600;注意:BX-3T控制卡只支持9600波特率;其它控制卡支持9600、57600
	iSocketPort = 5005
	sSocketIP = ip
	iWiFiPort = 5005
	sWiFiIP = "192.168.100.1"
	sCom = "COM1"
	m_bSendBusy = False

	# #清除节目
	# dll.DeleteScreenProgram(iScreenNo, 0)

	# # AddScreen
	# dll.AddScreen(iControlType, iScreenNo, iWidth, iHeight, iScreenType, iPixelMode, iDataDA, iDataOE,
	# 	iRowOrder, iFreqPar, sCom, iBaud, sSocketIP, iSocketPort, sWiFiIP, iWiFiPort, "ScreenStatus.ini")

	# # AddScreenProgram
	# dll.AddScreenProgram(iScreenNo, 0, 0, 65535, 11, 26, 2011, 11, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 59)


	# # 时钟
	# dll.AddScreenProgramClockArea(iScreenNo, 0, 5, 5, 80, 80)

	# title = u'巨林'.encode('gbk')
	# dll.AddScreenProgramClockAreaFile(iScreenNo, 0, 0,
	# 	1, 1, 1, # 固定文字,使用年月日时间,使用星期
	# 	6, 0, # 年月日格式,星期格式
	# 	12, 65535, 1, 0, 0, #固定文字大小,颜色,粗,斜,下划
	# 	22, 10, #固定文字坐标
	# 	9, 255, 0, 0, 0, #年月日文字大小,颜色,粗,斜,下划
	# 	15, 45, #年月日文字坐标
	# 	9, 255, 0, 0, 0, #星期文字大小,颜色,粗,斜,下划
	# 	25, 55, #星期文字坐标
	# 	9, 65535, 0, 0, 0, #表盘文字大小,颜色,粗,斜,下划
	# 	1,255, 1, 1, 65535, #表盘中心大小,颜色,369时点类型,尺寸,颜色
	# 	1,1,255,#369外时点类型,尺寸,颜色
	# 	1,1,65280,#分钟点类型,尺寸,颜色
	# 	2,65535,#时针尺寸,颜色
	# 	1,65280,#分针
	# 	1,255,#秒针
	# 	1,#自适应位置
	# 	title,
	# 	u'宋体',
	# 	u'宋体',
	# 	u'宋体',
	# 	u'宋体')

	# dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 90, 0, 348, 75)
	# filename = r'b\title.gif'
	# dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 1, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	# dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 0, 93, 448, 21)
	# filename = r'b\field1.gif'
	# dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 2, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	# dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 0, 150, 448, 22)
	# filename = r'b\field2.gif'
	# dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 3, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	# dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 0, 172, 70, 77)
	# filename = r'b\field3.gif'
	# dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 4, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	# SendScreenInfo 加载屏参数
	if (m_bSendBusy == False):
		m_bSendBusy = True
		dll.SendScreenInfo(iScreenNo, iSendMode, 41471, 0)
		m_bSendBusy = False
	else:
		raise IOError,'设备忙碌,请稍后再试'

	# if (m_bSendBusy == False):
	# 	m_bSendBusy = True
	# 	dll.SendScreenInfo(iScreenNo, iSendMode, 41456, 0)
	# 	m_bSendBusy = False
	# else:
	# 	raise IOError,'设备忙碌,请稍后再试'

def send_data(ip='192.168.0.21',light=16,screenNo=1):
	iControlType = 852 #BX-5E3:852
	iSendMode = 2     #0:串口通讯模式;2:网口固定IP通讯模式

	iScreenNo = screenNo
	iWidth = 448
	iHeight = 256
	iScreenType = 2   #显示屏类型;1:单基色;2:双基色;3:双基色;注意:BX-4MC只支持三基色;其余类型控制卡都不支持三基色;
	iPixelMode = 1    #点阵类型;1:R+G;2:G+R;该参数只对双基色屏有效 ;默认为2;
	iDataDA = 0       #数据极性;,0x00:数据低有效,0x01:数据高有效;默认为0;
	iDataOE = 0       #OE极性; 0x00:OE 低有效;0x01:OE 高有效;默认为0;
	iRowOrder = 0     #行序模式;0:正常;1:加1行;2:减1行;默认为0;
	iFreqPar = 6      #扫描点频;0~6;默认为0;
	pCom = "COM1"     #串口名称;串口通讯模式时有效;例:COM1
	iBaud = 57600     #串口波特率:目前支持9600、57600;默认为57600;注意:BX-3T控制卡只支持9600波特率;其它控制卡支持9600、57600
	iSocketPort = 5005
	sSocketIP = ip
	iWiFiPort = 5005
	sWiFiIP = "192.168.100.1"
	sCom = "COM1"
	m_bSendBusy = False

	# for x in range(31,4,-1):
	# 	dll.DeleteScreenProgramArea(iScreenNo,0,x)

	#清除节目
	dll.DeleteScreenProgram(iScreenNo, 0)

	# AddScreen
	dll.AddScreen(iControlType, iScreenNo, iWidth, iHeight, iScreenType, iPixelMode, iDataDA, iDataOE,
		iRowOrder, iFreqPar, sCom, iBaud, sSocketIP, iSocketPort, sWiFiIP, iWiFiPort, "ScreenStatus.ini")

	# AddScreenProgram
	dll.AddScreenProgram(iScreenNo, 0, 0, 65535, 11, 26, 2011, 11, 26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, 59)


	# 时钟
	dll.AddScreenProgramClockArea(iScreenNo, 0, 5, 5, 80, 80)

	title = u'巨林'.encode('gbk')
	dll.AddScreenProgramClockAreaFile(iScreenNo, 0, 0,
		1, 1, 1, # 固定文字,使用年月日时间,使用星期
		6, 0, # 年月日格式,星期格式
		12, 65535, 1, 0, 0, #固定文字大小,颜色,粗,斜,下划
		22, 10, #固定文字坐标
		9, 255, 0, 0, 0, #年月日文字大小,颜色,粗,斜,下划
		15, 45, #年月日文字坐标
		9, 255, 0, 0, 0, #星期文字大小,颜色,粗,斜,下划
		25, 55, #星期文字坐标
		9, 65535, 0, 0, 0, #表盘文字大小,颜色,粗,斜,下划
		1,255, 1, 1, 65535, #表盘中心大小,颜色,369时点类型,尺寸,颜色
		1,1,255,#369外时点类型,尺寸,颜色
		1,1,65280,#分钟点类型,尺寸,颜色
		2,65535,#时针尺寸,颜色
		1,65280,#分针
		1,255,#秒针
		1,#自适应位置
		title,
		u'宋体',
		u'宋体',
		u'宋体',
		u'宋体')

	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 90, 0, 348, 75)
	filename = r'b\title.gif'
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 1, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 0, 93, 448, 21)
	filename = r'b\field1.gif'
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 2, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 0, 150, 448, 22)
	filename = r'b\field2.gif'
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 3, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 0, 172, 70, 77)
	filename = r'b\field3.gif'
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 4, filename, 0, "Consolas", 11, 0, 255, 1, 0, 0)

	# rw1
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 8, 121, 100, 12)
	filename = r'b\row1rwd.txt'#任务单
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 5, filename, 1, "Consolas", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 115, 121, 110, 12)
	filename = r'b\row1stockid.txt'#物料i
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 6, filename, 1, "Consolas", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 235, 121, 40, 12)
	filename = r'b\row1plan.txt'#计划
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 7, filename, 1, u"新宋体", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 282, 121, 40, 12)
	filename = r'b\row1had.txt'#完工
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 8, filename, 1, u"新宋体", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 325, 121, 40, 12)
	filename = r'b\row1rate.txt'#达成
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 9, filename, 1, u"新宋体", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 370, 121, 20, 12)
	filename = r'b\row1bad.txt'#不
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 10, filename, 1, u"新宋体", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 400, 121, 34, 12)
	filename = r'b\row1state.txt'#状
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 11, filename, 1, u"新宋体", 9, 0, 65280, 1, 0, 0)

	# 生产状
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 105, 175, 50, 12)
	filename = r'b\pro_1.txt'#装配站
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 12, filename, 1, u"新宋体", 9, 0, 65535, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 170, 175, 50, 12)
	filename = r'b\pro_2.txt'#监测站
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 13, filename, 1, u"新宋体", 9, 0, 65535, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 235, 175, 50, 12)
	filename = r'b\pro_3.txt'#雕铣机
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 14, filename, 1, u"新宋体", 9, 0, 65535, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 300, 175, 50, 12)
	filename = r'b\pro_4.txt'#加工中心
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 15, filename, 1, u"新宋体", 9, 0, 65535, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 380, 175, 50, 12)
	filename = r'b\pro_5.txt'#车床
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 16, filename, 1, u"新宋体", 9, 0, 65535, 1, 0, 0)

	# 品质状况
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 105, 195, 50, 12)
	filename = r'b\pinzhi_1.txt'#装配站
	dll.AddScreenProgramAreaBmpTextFile(iScreenNo, 0, 17, filename, 1, u"新宋体", 9, 0, 65280, 1, 0, 0)
	dll.AddScreenProgramBmpTextArea(iScreenNo, 0, 170, 195, 50, 12)
	filename = r'b\pinzhi_2.txt'#检测站
	dll.AddScreen
...
...
(Not finished, please download and read the complete file)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
board.py26.39 kB30-09-13 16:33
...
Sponsored links

board.py (2.64 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D