Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_printer
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
fmp_printer
Commits
7ec97e7d
Commit
7ec97e7d
authored
Jul 28, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
插件更新
parent
5f3adc7d
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
56 deletions
+59
-56
fmp_printer.cpp
+3
-2
fmp_printer.h
+13
-4
fmp_printer_def.h
+1
-0
fmp_printer_i.h
+5
-6
fmp_printer_p.cpp
+28
-34
fmp_printer_p.h
+2
-1
fmp_printer_plugin.cpp
+3
-0
fmp_te_handlers.cpp
+3
-5
fmp_te_handlers.h
+1
-4
No files found.
fmp_printer.cpp
View file @
7ec97e7d
#include "fmp_printer_p.h"
#include "fmp_printer_p.h"
#include "fmp_logger_i.h"
#include "fmp_logger_i.h"
FMPPrinter
::
FMPPrinter
(
ctkPluginContext
*
context
)
FMPPrinter
::
FMPPrinter
(
const
FMPContext
ctx
)
:
FMPPrinterInterface
(
context
),
:
FMPPrinterInterface
(),
context
(
ctx
),
_inited
(
false
),
_inited
(
false
),
d_ptr
(
new
FMPPrinterPrivate
(
this
))
d_ptr
(
new
FMPPrinterPrivate
(
this
))
{
{
...
...
fmp_printer.h
View file @
7ec97e7d
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#define FMPPRINTER_H
#define FMPPRINTER_H
#include <QObject>
#include <QObject>
#include <ctkPluginContext.h>
#include "fmp_printer_i.h"
#include "fmp_printer_i.h"
class
FMPPrinterPrivate
;
class
FMPPrinterPrivate
;
...
@@ -13,16 +14,24 @@ class FMPPrinter : public QObject ,public FMPPrinterInterface
...
@@ -13,16 +14,24 @@ class FMPPrinter : public QObject ,public FMPPrinterInterface
Q_DECLARE_PRIVATE
(
FMPPrinter
)
Q_DECLARE_PRIVATE
(
FMPPrinter
)
public
:
public
:
FMPPrinter
(
ctkPluginContext
*
context
);
explicit
FMPPrinter
(
const
FMPContext
ctx
);
void
InitService
();
//!
void
UninitService
();
bool
DoPrint
(
QString
data
,
QString
strLabel
);
bool
DoPrint
(
QString
data
,
QString
strLabel
);
QString
GetPrintName
();
QString
GetPrintName
();
private
:
virtual
long
GetPluginId
()
const
{
return
GetContext
()
->
getPlugin
()
->
getPluginId
();
}
protected
:
const
FMPContext
GetContext
()
const
{
return
context
;
}
void
InitService
();
void
UninitService
();
private
:
bool
_inited
;
bool
_inited
;
FMPPrinterPrivate
*
d_ptr
;
FMPPrinterPrivate
*
d_ptr
;
const
FMPContext
context
;
signals
:
signals
:
...
...
fmp_printer_def.h
View file @
7ec97e7d
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#define FMP_INIKEY_PRINTERNAME "Printer/Name"
#define FMP_INIKEY_PRINTERNAME "Printer/Name"
#define FMP_INIKEY_PRINTERTYPE "Printer/Mode"
#define FMP_INIKEY_PRINTERTYPE "Printer/Mode"
#define FMP_INIKEY_PRINTERTYPET "Printer/PrintType"
#define FMP_INIKEY_PRINTERSIZE "Printer/PaperWidth"
#define FMP_INIKEY_PRINTERSIZE "Printer/PaperWidth"
#define FMP_INIKEY_PRINTERLEVLEL "Printer/Levlel"
#define FMP_INIKEY_PRINTERLEVLEL "Printer/Levlel"
#define FMP_INIKEY_PRINTERTYPE2 "Printer/Type"
#define FMP_INIKEY_PRINTERTYPE2 "Printer/Type"
...
...
fmp_printer_i.h
View file @
7ec97e7d
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
#include "fmp_printer_def.h"
#include "fmp_printer_def.h"
class
FMPPrinterInterface
;
/**
/**
* 业务插件接口,必须继承自 FMPluginInterface
* 业务插件接口,必须继承自 FMPluginInterface
* @brief The FMPPrinterInterface class
* @brief The FMPPrinterInterface class
...
@@ -12,17 +14,14 @@
...
@@ -12,17 +14,14 @@
class
FMPPrinterInterface
:
public
FMPBaseInterface
class
FMPPrinterInterface
:
public
FMPBaseInterface
{
{
public
:
public
:
explicit
FMPPrinterInterface
(
ctkPluginContext
*
ctx
)
:
FMPBaseInterface
(),
_ctx
(
ctx
)
{}
explicit
FMPPrinterInterface
(
)
:
FMPBaseInterface
(
)
{}
virtual
bool
DoPrint
(
QString
data
,
QString
strLabel
)
=
0
;
virtual
bool
DoPrint
(
QString
data
,
QString
strLabel
)
=
0
;
virtual
QString
GetPrintName
()
=
0
;
virtual
QString
GetPrintName
()
=
0
;
int
PostEvent
(
const
QString
&
topic
,
const
FMPProps
&
pps
)
{
return
FMP_NOIMPL
;
}
int
PostEvent
(
const
QString
&
,
const
FMPProps
&
)
{
return
FMP_NOIMPL
;
}
public
:
ctkPluginContext
*
_ctx
;
};
};
Q_DECLARE_INTERFACE
(
FMPPrinterInterface
,
"
com.
fmp.printer"
)
Q_DECLARE_INTERFACE
(
FMPPrinterInterface
,
"fmp.printer"
)
#endif // FMPPRINTERINTERFACE_H
#endif // FMPPRINTERINTERFACE_H
fmp_printer_p.cpp
View file @
7ec97e7d
#
include
"fmp_printer_p.h"
#
include
"fmp_printer_p.h"
#include <fmp_settings_i.h>
#include <fmp_settings_i.h>
#include <QDateTime>
#include <QDateTime>
#include <ctkPluginContext.h>
#include <ctkServiceReference.h>
#include <ctkServiceReference.h>
#include <QDir>
#include <QDir>
#include "fmp_te_handlers.h"
#include "fmp_te_handlers.h"
...
@@ -9,6 +8,7 @@
...
@@ -9,6 +8,7 @@
#include "fmp_home_i.h"
#include "fmp_home_i.h"
#include "fmp_logger_i.h"
#include "fmp_logger_i.h"
#include "initclass.h"
#include "initclass.h"
#include "QSettings"
#include <windows.h>
#include <windows.h>
#include <winspool.h>
#include <winspool.h>
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
FMPPrinterPrivate
::
FMPPrinterPrivate
(
FMPPrinter
*
q
)
FMPPrinterPrivate
::
FMPPrinterPrivate
(
FMPPrinter
*
q
)
:
q_ptr
(
q
)
:
q_ptr
(
q
)
{
{
FMPLoggerInterface
::
InitContext
(
q
->
_ctx
);
}
}
int
FMPPrinterPrivate
::
Init
()
int
FMPPrinterPrivate
::
Init
()
...
@@ -45,9 +44,6 @@ FMPPrinterPrivate::~FMPPrinterPrivate()
...
@@ -45,9 +44,6 @@ FMPPrinterPrivate::~FMPPrinterPrivate()
int
FMPPrinterPrivate
::
Uninit
()
int
FMPPrinterPrivate
::
Uninit
()
{
{
Q_Q
(
FMPPrinter
);
Q_Q
(
FMPPrinter
);
if
(
_settings
!=
nullptr
)
delete
_settings
;
_settings
=
0
;
q
->
_inited
=
false
;
q
->
_inited
=
false
;
return
FMP_SUCCESS
;
return
FMP_SUCCESS
;
...
@@ -76,11 +72,6 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
...
@@ -76,11 +72,6 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
}
}
QLOG_INFO
()
<<
"receive data is"
<<
data
;
QLOG_INFO
()
<<
"receive data is"
<<
data
;
char
m_data
[
2048
]
=
{
0
};
char
m_label
[
1024
]
=
{
0
};
char
m_data
[
2048
]
=
{
0
};
char
m_label
[
1024
]
=
{
0
};
switch
(
m_print
.
m_PrintType
)
{
case
0
:
case
1
:
if
(
m_print
.
m_PrintSize
==
58
)
if
(
m_print
.
m_PrintSize
==
58
)
{
{
if
(
!
strLabel
.
compare
(
"balance"
))
if
(
!
strLabel
.
compare
(
"balance"
))
...
@@ -92,13 +83,11 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
...
@@ -92,13 +83,11 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
FM_unloaddll
();
FM_unloaddll
();
return
1
;
return
1
;
}
}
if
(
data
.
isEmpty
())
if
(
data
.
isEmpty
())
{
{
QLOG_INFO
()
<<
"ready e data isEmpty "
;
QLOG_INFO
()
<<
"ready e data isEmpty "
;
return
0
;
return
0
;
}
}
QByteArray
tmpData
=
data
.
toLocal8Bit
();
QByteArray
tmpData
=
data
.
toLocal8Bit
();
strcpy
(
m_data
,
tmpData
.
data
());
strcpy
(
m_data
,
tmpData
.
data
());
QLOG_INFO
()
<<
"ready print data is"
<<
m_data
;
QLOG_INFO
()
<<
"ready print data is"
<<
m_data
;
...
@@ -112,8 +101,6 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
...
@@ -112,8 +101,6 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
FM_unloaddll
();
FM_unloaddll
();
return
1
;
return
1
;
}
}
case
2
:
if
(
m_print
.
m_PrintSize
==
80
)
if
(
m_print
.
m_PrintSize
==
80
)
{
{
if
(
!
strLabel
.
compare
(
"balance"
))
if
(
!
strLabel
.
compare
(
"balance"
))
...
@@ -144,12 +131,7 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
...
@@ -144,12 +131,7 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
FM_unloaddll
();
FM_unloaddll
();
return
1
;
return
1
;
}
}
else
if
(
m_print
.
m_PrintSize
==
56
)
{
;
}
break
;
default
:
#if 0
#if 0
if(GetInfo(m_print.printname,data))
if(GetInfo(m_print.printname,data))
{
{
...
@@ -162,26 +144,37 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
...
@@ -162,26 +144,37 @@ bool FMPPrinterPrivate::_DoPrint(QString data,QString strLabel="")
return 0;
return 0;
}
}
#endif
#endif
break
;
}
return
0
;
return
0
;
}
}
QString
FMPPrinterPrivate
::
_GetPrintName
()
QString
FMPPrinterPrivate
::
_GetPrintName
()
{
{
Q_Q
(
FMPPrinter
);
// settings = FMP::GetService<FMPSettingsInterface>();
_settings
=
q
->
GetService
<
FMPSettingsInterface
>
(
q
->
_ctx
);
// m_print.printname = settings->GetString(FMP_INIKEY_PRINTERNAME);
m_print
.
printname
=
_settings
->
GetString
(
FMP_INIKEY_PRINTERNAME
);
// m_print.m_PrintType = settings->GetInt(FMP_INIKEY_PRINTERTYPE);
m_print
.
m_PrintType
=
_settings
->
GetInt
(
FMP_INIKEY_PRINTERTYPE
);
// m_print.m_PrintSize = settings->GetInt(FMP_INIKEY_PRINTERSIZE);
m_print
.
m_PrintSize
=
_settings
->
GetInt
(
FMP_INIKEY_PRINTERSIZE
);
// m_print.m_level = settings->GetString(FMP_INIKEY_PRINTERLEVLEL);
m_print
.
m_level
=
_settings
->
GetString
(
FMP_INIKEY_PRINTERLEVLEL
);
// m_print.m_parall = settings->GetString(FMP_INIKEY_PRINTERPARALL);
m_print
.
m_parall
=
_settings
->
GetString
(
FMP_INIKEY_PRINTERPARALL
);
// m_print.type = settings->GetInt(FMP_INIKEY_PRINTERTYPE2);
m_print
.
type
=
_settings
->
GetInt
(
FMP_INIKEY_PRINTERTYPE2
);
// m_print.m_Usb = settings->GetString(FMP_INIKEY_PRINTERUSB);
m_print
.
m_Usb
=
_settings
->
GetString
(
FMP_INIKEY_PRINTERUSB
);
// m_print.m_Ip = settings->GetString(FMP_INIKEY_PRINTERNET);
m_print
.
m_Ip
=
_settings
->
GetString
(
FMP_INIKEY_PRINTERNET
);
// m_print.m_printerLabel = settings->GetString(FMP_INIKEY_PRINTERLABEL);
m_print
.
m_printerLabel
=
_settings
->
GetString
(
FMP_INIKEY_PRINTERLABEL
);
// m_print.m_nDays = settings->GetInt(FMP_INIKEY_LOGDAYS);
m_print
.
m_nDays
=
_settings
->
GetInt
(
FMP_INIKEY_LOGDAYS
);
QString
apppath
=
QCoreApplication
::
applicationDirPath
();
QSettings
*
settings
=
new
QSettings
(
QString
(
"%1/FreemudPOS.ini"
).
arg
(
apppath
),
QSettings
::
IniFormat
);
m_print
.
printname
=
settings
->
value
(
FMP_INIKEY_PRINTERNAME
).
toString
();
m_print
.
m_PrintType
=
settings
->
value
(
FMP_INIKEY_PRINTERTYPET
).
toInt
();
m_print
.
m_PrintSize
=
settings
->
value
(
FMP_INIKEY_PRINTERSIZE
).
toInt
();
m_print
.
m_level
=
settings
->
value
(
FMP_INIKEY_PRINTERLEVLEL
).
toString
();
m_print
.
m_parall
=
settings
->
value
(
FMP_INIKEY_PRINTERPARALL
).
toString
();
m_print
.
type
=
settings
->
value
(
FMP_INIKEY_PRINTERTYPE2
).
toInt
();
m_print
.
m_Usb
=
settings
->
value
(
FMP_INIKEY_PRINTERUSB
).
toString
();
m_print
.
m_Ip
=
settings
->
value
(
FMP_INIKEY_PRINTERNET
).
toString
();
m_print
.
m_printerLabel
=
settings
->
value
(
FMP_INIKEY_PRINTERLABEL
).
toString
();
m_print
.
m_nDays
=
settings
->
value
(
FMP_INIKEY_LOGDAYS
).
toInt
();
delete
settings
;
return
m_print
.
printname
;
return
m_print
.
printname
;
}
}
...
@@ -198,6 +191,7 @@ QString FMPPrinterPrivate::SendIniData()
...
@@ -198,6 +191,7 @@ QString FMPPrinterPrivate::SendIniData()
.
append
(
m_print
.
m_Ip
==
""
?
"127.0.0.1"
:
m_print
.
m_Ip
).
append
(
"|"
)
.
append
(
m_print
.
m_Ip
==
""
?
"127.0.0.1"
:
m_print
.
m_Ip
).
append
(
"|"
)
.
append
(
m_print
.
m_printerLabel
==
""
?
"Gprinter 2120TF"
:
m_print
.
m_printerLabel
).
append
(
"|"
)
.
append
(
m_print
.
m_printerLabel
==
""
?
"Gprinter 2120TF"
:
m_print
.
m_printerLabel
).
append
(
"|"
)
.
append
((
QString
::
number
(
m_print
.
m_nDays
,
10
)
==
""
)
?
(
"10"
)
:
QString
::
number
(
m_print
.
m_nDays
,
10
)).
append
(
"|"
);
.
append
((
QString
::
number
(
m_print
.
m_nDays
,
10
)
==
""
)
?
(
"10"
)
:
QString
::
number
(
m_print
.
m_nDays
,
10
)).
append
(
"|"
);
FMP_INFO
()
<<
"m_print_ini is ok"
<<
m_print_ini
;
return
m_print_ini
;
return
m_print_ini
;
}
}
...
...
fmp_printer_p.h
View file @
7ec97e7d
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
class
FMPSettingsInterface
;
class
FMPSettingsInterface
;
class
FMPHomeInterface
;
class
FMPHomeInterface
;
typedef
struct
typedef
struct
{
{
QString
printname
;
//打印机的名字
QString
printname
;
//打印机的名字
...
@@ -38,7 +39,7 @@ public:
...
@@ -38,7 +39,7 @@ public:
PrintClass
m_print
;
PrintClass
m_print
;
private
:
private
:
FMPSettingsInterface
*
_
settings
;
FMPSettingsInterface
*
settings
;
};
};
#endif // FMP_PRINTER_P_H
#endif // FMP_PRINTER_P_H
fmp_printer_plugin.cpp
View file @
7ec97e7d
...
@@ -41,12 +41,15 @@ void FMPPrinterPlugin::start(ctkPluginContext* context)
...
@@ -41,12 +41,15 @@ void FMPPrinterPlugin::start(ctkPluginContext* context)
void
FMPPrinterPlugin
::
stop
(
ctkPluginContext
*
context
)
void
FMPPrinterPlugin
::
stop
(
ctkPluginContext
*
context
)
{
{
qDebug
()
<<
__FUNCTION__
<<
"in"
;
Q_UNUSED
(
context
)
Q_UNUSED
(
context
)
if
(
_printer_service
)
if
(
_printer_service
)
{
{
delete
_printer_service
;
delete
_printer_service
;
_printer_service
=
0
;
_printer_service
=
0
;
}
}
qDebug
()
<<
__FUNCTION__
;
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
...
...
fmp_te_handlers.cpp
View file @
7ec97e7d
#include "fmp_te_handlers.h"
#include "fmp_te_handlers.h"
#include "fmp_printer.h"
#include "fmp_printer.h"
FMPStartEventHandler
::
FMPStartEventHandler
(
ctkPluginContext
*
ctx
,
FMPPrinter
*
_printer
)
FMPStartEventHandler
::
FMPStartEventHandler
(
FMPPrinter
*
_printer
)
:
FMPPrinterEventHandler
(
FMP_TOPICS_SERVICES
FMPE_SERVICE_REQ_START
"/"
+
QString
::
number
(
ctx
->
getPlugin
()
->
getPluginId
()),
:
FMPPrinterEventHandler
(
FMP_TOPICS_SERVICES
FMPE_SERVICE_REQ_START
"/"
+
QString
::
number
(
_printer
->
GetPluginId
()),
_printer
)
_printer
),
_ctx
(
ctx
)
{
{
FMPProps
props
;
FMPProps
props
;
props
[
ctkEventConstants
::
EVENT_TOPIC
]
=
_topic
;
props
[
ctkEventConstants
::
EVENT_TOPIC
]
=
_topic
;
_ctx
->
r
egisterService
<
ctkEventHandler
>
(
this
,
props
);
FMP
::
R
egisterService
<
ctkEventHandler
>
(
this
,
props
);
}
}
void
FMPStartEventHandler
::
handleEvent
(
const
ctkEvent
&
event
)
void
FMPStartEventHandler
::
handleEvent
(
const
ctkEvent
&
event
)
...
...
fmp_te_handlers.h
View file @
7ec97e7d
...
@@ -23,11 +23,8 @@ class FMPStartEventHandler : public QObject, public FMPPrinterEventHandler
...
@@ -23,11 +23,8 @@ class FMPStartEventHandler : public QObject, public FMPPrinterEventHandler
Q_OBJECT
Q_OBJECT
Q_INTERFACES
(
ctkEventHandler
)
Q_INTERFACES
(
ctkEventHandler
)
public
:
public
:
explicit
FMPStartEventHandler
(
ctkPluginContext
*
ctx
,
FMPPrinter
*
Takeout
);
explicit
FMPStartEventHandler
(
FMPPrinter
*
Takeout
);
void
handleEvent
(
const
ctkEvent
&
event
);
void
handleEvent
(
const
ctkEvent
&
event
);
private
:
ctkPluginContext
*
_ctx
;
};
};
...
...
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