Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
miya-hardware
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
miya-hardware
Commits
641ec581
Commit
641ec581
authored
Jan 22, 2019
by
pengguangpu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
英泰打印驱动尘埃落定
parent
ed9f6ba9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
369 additions
and
25 deletions
+369
-25
PrintActivity.java
app/src/main/java/com/miya/hardware/PrintActivity.java
+1
-1
BasePrinter.java
print/src/main/java/com/miya/print/BasePrinter.java
+5
-0
ChuangjiePrinter.java
print/src/main/java/com/miya/print/ChuangjiePrinter.java
+9
-14
PrinterManager.java
print/src/main/java/com/miya/print/PrinterManager.java
+22
-4
SangdaPrinter.java
print/src/main/java/com/miya/print/SangdaPrinter.java
+2
-6
YingtaiPrinter.java
print/src/main/java/com/miya/print/YingtaiPrinter.java
+325
-0
ChuangjieWeighing.java
...ng/src/main/java/com/miya/weighing/ChuangjieWeighing.java
+5
-0
No files found.
app/src/main/java/com/miya/hardware/PrintActivity.java
View file @
641ec581
...
@@ -137,7 +137,7 @@ public class PrintActivity extends Activity implements View.OnClickListener {
...
@@ -137,7 +137,7 @@ public class PrintActivity extends Activity implements View.OnClickListener {
break
;
break
;
case
R
.
id
.
btnRelease
:
case
R
.
id
.
btnRelease
:
if
(
PrinterManager
.
getInstance
().
isConnected
())
{
if
(
PrinterManager
.
getInstance
().
isConnected
())
{
if
(
PrinterManager
.
getInstance
().
getPrinter
().
release
()
==
true
)
{
if
(
PrinterManager
.
getInstance
().
release
()
==
true
)
{
tvResult
.
setText
(
"销毁成功"
);
tvResult
.
setText
(
"销毁成功"
);
}
else
{
}
else
{
tvResult
.
setText
(
"没初始化过"
);
tvResult
.
setText
(
"没初始化过"
);
...
...
print/src/main/java/com/miya/print/BasePrinter.java
View file @
641ec581
...
@@ -8,6 +8,11 @@ import android.graphics.Bitmap;
...
@@ -8,6 +8,11 @@ import android.graphics.Bitmap;
*/
*/
public
class
BasePrinter
implements
IPrinter
{
public
class
BasePrinter
implements
IPrinter
{
/**
* 80mm打印纸允许打印的最大图片的宽度,此为经验值
*/
final
static
int
MAX_IMG_WIDTH_80MM
=
570
;
/**
/**
* 初始化调用者的引用
* 初始化调用者的引用
*/
*/
...
...
print/src/main/java/com/miya/print/ChuangjiePrinter.java
View file @
641ec581
...
@@ -41,11 +41,6 @@ public class ChuangjiePrinter extends BasePrinter {
...
@@ -41,11 +41,6 @@ public class ChuangjiePrinter extends BasePrinter {
*/
*/
int
textSize
=
-
1
;
int
textSize
=
-
1
;
/**
* 80mm打印纸允许打印的最大图片的宽度,此为经验值
*/
final
static
int
MAX_IMG_WIDTH_80MM
=
570
;
@Override
@Override
public
boolean
init
(
Context
context
)
{
public
boolean
init
(
Context
context
)
{
this
.
context
=
context
;
this
.
context
=
context
;
...
@@ -71,9 +66,7 @@ public class ChuangjiePrinter extends BasePrinter {
...
@@ -71,9 +66,7 @@ public class ChuangjiePrinter extends BasePrinter {
}
}
ret
=
setAlign
(
align
);
ret
=
setAlign
(
align
);
ret
=
printString
(
content
);
ret
=
printString
(
content
);
if
(
isFeed
)
{
//创捷机器打印完后会强制走纸一行,这里不再判断是否走纸标志
ret
=
LF
();
}
return
ret
;
return
ret
;
}
}
...
@@ -89,12 +82,17 @@ public class ChuangjiePrinter extends BasePrinter {
...
@@ -89,12 +82,17 @@ public class ChuangjiePrinter extends BasePrinter {
@Override
@Override
public
boolean
release
()
{
public
boolean
release
()
{
super
.
release
();
if
(
mUsbDriver
!=
null
&&
mUsbDev
!=
null
)
{
if
(
null
==
mUsbDev
)
{
if
(
mUsbDriver
.
isConnected
())
{
if
(
mUsbDriver
.
isConnected
())
{
mUsbDriver
.
disconnet
();
if
(
null
!=
mUsbDev
)
{
mUsbDriver
.
disconnet
(
mUsbDev
);
}
}
}
mUsbDev
=
null
;
mUsbDriver
=
null
;
context
=
null
;
}
}
D
.
i
(
TAG
,
"创捷打印资源已关闭"
);
return
true
;
return
true
;
}
}
...
@@ -319,9 +317,6 @@ public class ChuangjiePrinter extends BasePrinter {
...
@@ -319,9 +317,6 @@ public class ChuangjiePrinter extends BasePrinter {
int
ret
=
setAlign
(
align
);
int
ret
=
setAlign
(
align
);
//创捷机器打印条码只能居左、居中打印,并且内部会强制走纸
//创捷机器打印条码只能居左、居中打印,并且内部会强制走纸
ret
=
printBarCode
(
content
);
ret
=
printBarCode
(
content
);
if
(
isFeed
)
{
ret
=
feedPaper
();
}
return
ret
;
return
ret
;
}
}
...
...
print/src/main/java/com/miya/print/PrinterManager.java
View file @
641ec581
...
@@ -17,10 +17,11 @@ public class PrinterManager {
...
@@ -17,10 +17,11 @@ public class PrinterManager {
enum
Type
{
enum
Type
{
//这里添加扩展的驱动
//这里添加扩展的驱动
// TYPE_HISENSE("hisense", ChuangjiePrinter.class.getName()),
// TYPE_HISENSE("hisense", ChuangjiePrinter.class.getName()),
// TYPE_YINGTAI("yingtai", ChuangjiePrinter.class.getName()),
// TYPE_SUNMI("shangmi", ChuangjiePrinter.class.getName()),
// TYPE_SUNMI("shangmi", ChuangjiePrinter.class.getName()),
TYPE_YINGTAI
(
"yingtai"
,
YingtaiPrinter
.
class
.
getName
()),
TYPE_SANGDA
(
"sangda"
,
SangdaPrinter
.
class
.
getName
()),
TYPE_CHUANGJIE
(
"chuangjie"
,
ChuangjiePrinter
.
class
.
getName
()),
TYPE_CHUANGJIE
(
"chuangjie"
,
ChuangjiePrinter
.
class
.
getName
());
TYPE_SANGDA
(
"sangda"
,
SangdaPrinter
.
class
.
getName
());
/**
/**
* 设备类型名称
* 设备类型名称
...
@@ -96,6 +97,23 @@ public class PrinterManager {
...
@@ -96,6 +97,23 @@ public class PrinterManager {
return
false
;
return
false
;
}
}
/**
* 销毁相关资源
*
* @return
*/
public
boolean
release
()
{
if
(
isConnected
())
{
boolean
result
=
printer
.
release
();
if
(
result
==
false
)
{
return
false
;
}
printer
=
null
;
return
true
;
}
return
true
;
}
/**
/**
* 获取当前打印接口
* 获取当前打印接口
*
*
...
...
print/src/main/java/com/miya/print/SangdaPrinter.java
View file @
641ec581
...
@@ -25,17 +25,13 @@ public class SangdaPrinter extends BasePrinter {
...
@@ -25,17 +25,13 @@ public class SangdaPrinter extends BasePrinter {
final
static
String
TAG
=
SangdaPrinter
.
class
.
getSimpleName
();
final
static
String
TAG
=
SangdaPrinter
.
class
.
getSimpleName
();
public
PrinterAPI
mPrinter
=
PrinterAPI
.
getInstance
()
;
public
PrinterAPI
mPrinter
;
InterfaceAPI
io
=
null
;
InterfaceAPI
io
=
null
;
/**
* 80mm打印纸允许打印的最大图片的宽度,此为经验值
*/
final
static
int
MAX_IMG_WIDTH_80MM
=
570
;
@Override
@Override
public
boolean
init
(
Context
context
)
{
public
boolean
init
(
Context
context
)
{
super
.
init
(
context
);
super
.
init
(
context
);
mPrinter
=
PrinterAPI
.
getInstance
();
if
(
isConnect
())
{
if
(
isConnect
())
{
mPrinter
.
disconnect
();
mPrinter
.
disconnect
();
}
}
...
...
print/src/main/java/com/miya/print/YingtaiPrinter.java
0 → 100644
View file @
641ec581
This diff is collapsed.
Click to expand it.
weighing/src/main/java/com/miya/weighing/ChuangjieWeighing.java
View file @
641ec581
package
com
.
miya
.
weighing
;
package
com
.
miya
.
weighing
;
import
android.content.Context
;
import
android.content.Context
;
import
android.os.Build
;
import
android.os.CountDownTimer
;
import
android.os.CountDownTimer
;
import
android.util.Log
;
import
android.util.Log
;
...
@@ -30,6 +31,10 @@ public class ChuangjieWeighing extends BaseWeighing {
...
@@ -30,6 +31,10 @@ public class ChuangjieWeighing extends BaseWeighing {
@Override
@Override
public
boolean
init
(
Context
context
)
{
public
boolean
init
(
Context
context
)
{
//根据序列号判断是否是创捷机器
if
(!
Build
.
SERIAL
.
startsWith
(
"CCL"
))
{
return
false
;
}
serialPortFunction
=
SerialPortFunction
.
getInstance
();
serialPortFunction
=
SerialPortFunction
.
getInstance
();
serialPortFunction
.
setContext
(
context
);
serialPortFunction
.
setContext
(
context
);
try
{
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment