Exemplo n.º 1
0
//直接进纸n/120英寸。1B-25-35-n(01 =< n <= FF)
func (jst *OkiPrinter) SeekColPos(pos float32, currpos float32) error {
	if pos == 0 {
		utils.Trace("pos is zero ,skip")
		return nil
	}

	inch := int(utils.ConvertFrommmToInch(pos) * float32(120))
	remain := inch
	for {
		//oki的最大位移为255/120 inch
		if remain > 255 {
			s, _ := hex.DecodeString("1b2535ff")
			utils.Trace("OkiPrinter send AdvanceLine pi %x", s)
			if jst.checkJobInPrint() {
				driverlayer.WriteData(jst.w, s)
			} else {
				return PR2NOTINJOB
			}
			remain -= 255
		} else {
			var d uint8 = uint8(remain) & 0xff
			s, _ := hex.DecodeString("1b2535" + utils.FormatInt(int(d), 2, "0", 16) + "20")
			utils.Trace("OkiPrinter send AdvanceLine pi %x", s)
			if jst.checkJobInPrint() {
				return driverlayer.WriteData(jst.w, s)
			} else {
				return PR2NOTINJOB
			}
			break
		}
	}
	return nil
}
Exemplo n.º 2
0
//设置字符间距
//单位mm
func (jst *OlevittePrinter) SetColInterval(w float32) error {
	utils.Trace("OlevittePrinter received SetColInterval request")
	var line int
	line = int(utils.ConvertFrommmToInch(w) * float32(jst.dotinstace))
	utils.Trace("SetColInterval:col interval is %d/240 inch", line)
	a := strconv.Itoa(line / 10)
	b := strconv.Itoa(line % 10)
	s, _ := hex.DecodeString("1c533" + a + "3" + b)
	utils.Trace("OlevittePrinter send SetColInterval pi %x", s)
	if jst.checkJobInPrint() {
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}
}
Exemplo n.º 3
0
//设置有边界    单位:毫米
func (jst *OkiPrinter) SetRightMargin(pos float32) error {
	utils.Trace("OkiPrinter received SetRightMargin request")
	var l int = int(utils.ConvertFrommmToInch(pos) * float32(180))
	if l > 1690 {
		utils.Error("OkiPrinter ;s right margin is not allowed to exceed than 228.6mm !!")
		return PR2RIGHTTOOLARGE
	}
	utils.Trace("SetRightMargin:real right margin is %d/180 inch", l)
	b := "1b29" + utils.FormatInt(l, 4, "0", 16)
	s, _ := hex.DecodeString(b)
	utils.Trace("OkiPrinter send SetRightMargin pi %x", s)
	if jst.checkJobInPrint() {
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}
}
Exemplo n.º 4
0
//pr2在放入纸或存折之前可以使用的指令
//参数单位:mm
//命令参数:1/240inch
//命令参数不小于70,且不小于设备配置
func (jst *OlevittePrinter) SetTop(pos float32) error {
	utils.Trace("OlevittePrinter received SetTop request")
	line := int(utils.ConvertFrommmToInch(pos) * float32(240))
	utils.Trace("SetTop:top is %d mm", line)
	if line < 70 {
		return nil
	}
	a := strconv.Itoa(line / 100)
	b := strconv.Itoa(line / 10 % 10)
	c := strconv.Itoa(line % 10)
	s, _ := hex.DecodeString("1b543" + a + "3" + b + "3" + c)
	utils.Trace("OlevittePrinter send SetTop pi %x", s)
	if jst.checkJobInPrint() {
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}
}
Exemplo n.º 5
0
//设置n/120英寸行据。1B-25-39-n1-n2(n1为00,n2表示:00-FF/120)
func (jst *OkiPrinter) SetLineInterval(lineinterval float32) error {
	utils.Trace("OkiPrinter received SetLineInterval request")

	var line int
	line = int(utils.ConvertFrommmToInch(lineinterval) * float32(120))
	if line > 255 {
		return LINEINTERVALTOOLARGE
	}
	utils.Trace("SetLineInterval:line interval is %d/120 inch", line)
	s, _ := hex.DecodeString("1b2539" + utils.FormatInt(line, 4, "0", 16))
	utils.Trace("OkiPrinter send SetLineInterval pi %x", s)
	if jst.checkJobInPrint() {
		jst.lineinterval = lineinterval
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}

}
Exemplo n.º 6
0
//设置列距.是以列距为计算方式的(即字符间距)
//一般都是1/180
func (jst *OkiPrinter) SetColInterval(w float32) error {
	utils.Trace("OkiPrinter received SetColInterval request")

	var line int
	line = int(utils.ConvertFrommmToInch(w) * float32(jst.dotinstace)) //1/180
	if line > 255 {
		return LINEINTERVALTOOLARGE
	}
	utils.Trace("SetColInterval:col interval is %d/120 inch", line)

	realinterval := utils.FormatInt(line, 2, "0", 16)
	s, _ := hex.DecodeString("1c24" + realinterval)
	utils.Trace("OkiPrinter send SetColInterval pi %x", s)
	if jst.checkJobInPrint() {
		jst.colinterval = w
		return driverlayer.WriteData(jst.w, s)
	} else {
		return PR2NOTINJOB
	}

}
Exemplo n.º 7
0
//单位长度不一致,这个是以点距为单位的
//即:多少个字符
func (jst *OkiPrinter) SeekLinePos(pos float32, currpos float32) error {
	utils.Trace("OkiPrinter received SeekLinePos request")
	line := utils.ConvertFrommmToInch(pos) * float32(jst.dotinstace)
	return jst.SeekRealLinePos(line)
}