CN103631641B - A kind of simulator and its implementation of simulated battery charged state - Google Patents

A kind of simulator and its implementation of simulated battery charged state Download PDF

Info

Publication number
CN103631641B
CN103631641B CN201310668562.9A CN201310668562A CN103631641B CN 103631641 B CN103631641 B CN 103631641B CN 201310668562 A CN201310668562 A CN 201310668562A CN 103631641 B CN103631641 B CN 103631641B
Authority
CN
China
Prior art keywords
battery
simulation
interface
analog
driven
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201310668562.9A
Other languages
Chinese (zh)
Other versions
CN103631641A (en
Inventor
吴奇峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Weihai Shenzhou Information Technology Research Institute Co ltd
Original Assignee
TCL Communication Ningbo Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by TCL Communication Ningbo Ltd filed Critical TCL Communication Ningbo Ltd
Priority to CN201310668562.9A priority Critical patent/CN103631641B/en
Publication of CN103631641A publication Critical patent/CN103631641A/en
Application granted granted Critical
Publication of CN103631641B publication Critical patent/CN103631641B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention discloses a kind of simulator and its implementation of simulated battery charged state, wherein, set one to include analog-driven and simulate the simulator of UI modules, the analog-driven is supplied to application program first interface and is supplied to simulation UI module second interfaces;After the simulation UI modules receive simulated action instruction, write by second interface to analog-driven;The application program reads simulated action instruction by the first interface from the analog-driven, and is acted accordingly according to simulated action instruction, realizes the simulation to battery charging state.The invention enables the developer of application program to carry out software development independently of the battery apparatus of reality, operate very convenient, and it is true to nature to simulate effect, only need to ensure that first interface is consistent with the software function of the first interface in real hardware, you can ensure that application program can also be realized in real battery apparatus.

Description

A kind of simulator and its implementation of simulated battery charged state
Technical field
The present invention relates to software field, more particularly to a kind of simulator and its implementation of simulated battery charged state.
Background technology
Mobile terminal development process mainly includes two parts of software development and hardware development, and per a mobile terminal Initial development phase, because hardware is not fully prepared also, related software just can not be developed and debugged, such as in electricity In the case that pond and charger are not fully prepared also, the related software of its charged state can not just be developed, so prior art In mobile terminal development efficiency substantially reduce.
Therefore, prior art has yet to be improved and developed.
The content of the invention
In view of above-mentioned the deficiencies in the prior art, it is an object of the invention to provide a kind of simulation of simulated battery charged state Device and its implementation, it is intended to which solving battery is related to charger in existing mobile terminal development process software development can not Operated in software program, development efficiency be low the problem of.
Technical scheme is as follows:
A kind of simulator implementation method of simulated battery charged state, wherein, including:
Set one to include analog-driven and simulate the simulator of UI modules, the analog-driven is supplied to application program first Interface and be supplied to simulation UI module second interfaces;
After the simulation UI modules receive simulated action instruction, write by second interface to analog-driven;
The application program reads simulated action instruction by the first interface from the analog-driven, and according to institute State simulated action instruction to be acted accordingly, realize the simulation to battery charging state.
The simulator implementation method of described simulated battery charged state, wherein, in addition to:
It is used for the data structure for representing battery charging state defined in analog-driven in advance.
The simulator implementation method of described simulated battery charged state, wherein, the simulation UI modules include following choosing :AC external power supply sockets, USB external power supply sockets, external power supply state, battery electric quantity and power supply status display field, it is each The corresponding member value that option corresponds in data structure.
It is a kind of to use the simulator that method simulated battery charged state is implemented as described above, wherein, the simulator includes simulation Driving and simulation UI modules;
The analog-driven, for being supplied to application program first interface and being supplied to simulation UI module second interfaces;
The simulation UI modules, write for the simulated action received to be instructed by second interface to analog-driven, The application program reads simulated action instruction by the first interface from the analog-driven, and dynamic according to the simulation Make instruction to be acted accordingly, realize the simulation to battery charging state.
The simulator of the simulated battery charged state, wherein, the first interface includes being used to obtain battery charging shape The interface of state, battery charging state therein include:Whether powered, whether powered by USB by AC, battery electric quantity height, have it is outer Connect the state and battery capacity under power supply.
The simulator of the simulated battery charged state, wherein, the simulation UI modules realize that module includes:
Object Creation module, show for creating the object of a battery, and for handling when battery charging state changes Show in simulation UI modules.
The simulator of the simulated battery charged state, wherein, the simulation UI modules realize that module also includes:
Battery status memory module, for storing present battery charged state.
The simulator of the simulated battery charged state, wherein, the simulation UI modules realize that module also includes:
Simulated action instructs writing module, and simulated action instruction is written into mould for the first interface by analog-driven In the data structure for intending driving.
Beneficial effect:The present invention is supplied to using journey by setting analog-driven and simulation UI modules by the analog-driven Sequence first interface and simulation UI module second interfaces are supplied to, application program reads simulated action from the analog-driven and refer to Order, and acted accordingly according to simulated action instruction, realize the simulation to battery status.Pass through the present invention, application The developer of program can carry out software development independently of the battery apparatus of reality, operate very convenient, and mould It is true to nature to intend effect, it is only necessary to ensure that first interface is consistent with the software function of the first interface in real hardware, you can ensureing should Can also be realized in real battery apparatus with program, even if so the present invention simulator replaced by real hardware, the simulation The difference of device and real hardware also can be neglected so that the application program after exploitation need not modify in the later stage, so as to improve The development efficiency of application program.
Brief description of the drawings
Fig. 1 is the flow chart of the simulator implementation method preferred embodiment of simulated battery charged state of the present invention.
Fig. 2 is the structured flowchart of the simulator preferred embodiment of simulated battery charged state of the present invention.
Fig. 3 is the interfacial structure figure that UI modules are simulated in simulator of the present invention.
Embodiment
The present invention provides a kind of simulator and its implementation of simulated battery charged state, for make the purpose of the present invention, Technical scheme and effect are clearer, clear and definite, and the present invention is described in more detail below.It is it should be appreciated that described herein Specific embodiment only to explain the present invention, is not intended to limit the present invention.
A kind of simulator implementation method of simulated battery charged state of the present invention, as shown in figure 1, including step:
S101, set one to include analog-driven and simulate the simulator of UI modules, the analog-driven is supplied to using journey Sequence first interface and be supplied to simulation UI module second interfaces;
After S102, the simulation UI modules receive simulated action instruction, write by second interface to analog-driven;
S103, the application program read simulated action instruction by the first interface from the analog-driven, and Acted accordingly according to simulated action instruction, realize the simulation to battery charging state.
The simulator implementation method of the present invention is to realize that the related application program of battery apparatus can be simulated in software Debugged and developed on device, so as to improve development efficiency.
With reference to the simulator, the present invention will be described in detail.
Referring to Fig. 2, Fig. 2 is a kind of structured flowchart of the simulator of simulated battery charged state of the present invention, as illustrated, The simulator 100 includes:
Analog-driven 120 and simulation UI modules 110, the analog-driven 120 are used to be supplied to application program 130 first to connect Mouthful and be supplied to the second interface of simulation UI modules 110, the simulation UI modules 110, which instruct the simulated action received, to be passed through Second interface is write to analog-driven 120, and the application program 130 is by the first interface from the analog-driven 120 Simulated action instruction is read, and is acted accordingly according to simulated action instruction, realizes the mould to battery charging state Intend.
The software function of interface on the first interface and actual hardware of the present invention is consistent, and the first interface is root Formulated according to the software of actual development, as long as first interface keeps consistent with the interface of actual hardware, then if using journey Sequence can be operated on simulator, and same application program can be also operated on actual hardware, so as to realize simulation actual hardware Function.Simulated battery charged state driving as electronic equipment input equipment one kind, on the whole for be supplied to application The character device interface of program standard, only it need to provide basic operation(Mainly manage the information of battery charging state)With Just charged state can be fed back to application program in time.
And the second interface in the present invention can then be modified as needed, originally driving and the connection of hardware with And the connection and communication become for analog-driven and simulation UI modules is linked up, so analog-driven needs to provide extra interface Simulation UI modules are given, simulation UI modules is simulated the effect similar to actual hardware.
In the present embodiment, it is used for defined in analog-driven the data structure for representing battery charging state in advance, uses Situation is possible to represent battery charging state, the data structure is as follows:
struct PowerStatus {
unsigned int ACPluged:1;// whether by AC power supplies 1:It is;0:It is no
unsigned int USBPluged:1;// whether by USB chargings 1:It is;0:It is no
unsigned int LowBAT:1;// battery electric quantity mark 1:low(It is low);0:high(It is high)
unsigned int BatteryChargeStatus:3;// there is state 1 under external power supply:full charge(It is fully charged) 2:normal charge(Charge normal) 3:not charge(It is uncharged)
unsigned int PowerMV:16;// battery capacity(mAh)
};
struct PowerStatus CurrentPowerStatus = { 0, 0, 0, 3, 2000 };// silent Recognize power supply status, that is, represent the power supply status of acquiescence.
So above-mentioned data structure has represented the index of battery charging state:Whether powered, whether powered by USB by AC, Battery electric quantity height, there are state and battery capacity under external power supply.
The interface of the data structure is controlled by ioctl (), ioctl orders:
SET_POWERSTATUS (It is worth for 0):Battery charging state is set, and ioctl the 3rd parameter type is representative electricity (the struct PowerStatus*) of pond charged state, this interface use only for simulation UI modules, actual to drive and do not need.
GET_POWERSTATUS (It is worth for 1):Battery charging state is obtained, ioctl the 3rd parameter type is representative electricity (the struct PowerStatus*) of pond charged state, this interface is first interface, there is provided is used to application program.
Simulation UI modules in the present invention, its interface can as shown in figure 3,
AC external power supply sockets therein, corresponding to the member value in data structure:unsigned int ACPluged;
USB external power supply sockets therein, corresponding to the member value in data structure:unsigned int USBPluged;
External power supply state options therein, corresponding to the member value in data structure:unsigned int BatteryChargeStatus;
Battery capacity option therein, corresponding to the member value in data structure:unsigned int PowerMV;
Power supply status display field therein, it is to determine to show according to above-mentioned member value and unsigned int LowBAT Show content.
Each option in simulation UI modules is briefly described below.
AC external power supply sockets:If hook is stamped thereon, then it represents that now there is external AC to charge battery;
USB external power supply sockets:If hook is stamped thereon, then it represents that now there is circumscribed USB line to charge battery
External power supply state options:If both the above option does not all select, this is invalid, otherwise has 2 kinds of options to be available for selecting Select:full charge;nomal charge;
Battery capacity option:Scope 0 ~ 2000, here 2000 be battery capacity, can be set according to actual conditions Put;
Power supply status display field:When there is any one external power supply socket to be chosen, charged is shown!, otherwise show not charged。
Simulation UI modules realize that module includes:Power.h, power.cpp, simphone.h, simphone.cpp, its In, cpp and h are the types of program file, and the realization of function is all placed in cpp files, and h files are " header file ", function Definition etc. is all placed in h files.
Simphone.h is used for the object for creating a battery, i.e. Object Creation module, works as battery charging shape for handling State is shown in when changing in simulation UI modules;Power.h, for storing present battery charged state, i.e. battery status storage mould Block;Simphone.cpp is used for the data knot that simulated action instruction is written to analog-driven by the first interface of analog-driven In structure, i.e., simulated action instructs writing module.
Simphone calls the system that needs to use in analog-driven and has been encapsulated into inside a class, with convenient use, This is by power.h and power.cpp realizations.The following member function for needing to use defined in power.h and Filec descriptor fd:
class TPower
{
public:
static int openPower();
static void closePower();
static int readPower();
static int writePower(const struct PowerStatus);// will utilize Ioctl systems, which are called, writes battery status in buffering area buffer
static int getFD();The filec descriptor fd for the device file that // acquisition is opened
private:
static int m_fd;
};
The various signals that simphonebase.cpp files change the battery status simulated in all simulation UI modules pass Defeated to arrive corresponding treatment trough powerStatusChanged (), this treatment trough is Virtual Function, simphone.cpp (Main classes in simphone.cpp inherits the main classes in simphonebase.cpp)In also define corresponding treatment trough, it is real The treatment trough defined in simphone.cpp can be performed in the operation of border, these treatment troughs are responsible for present battery charged state to write Into the respective data structures of analog-driven.
In treatment trough powerStatusChanged (), the data set in simulation UI modules are read first, are then beaten Open power device files:
TPower::openPower();
Then present battery charged state is written in analog-driven:
TPower::writePower(currentPowerStatus);The charged state of // battery is all stored in data In structure currentPowerStatus
It is then switched off this device file:
TPower::closePower();
Finally the charged state of battery is reacted on the interface in module UI modules.
Illustrate how to determine each member in data structure PowerStatus according to the option in simulation UI module interfaces below Value:
unsigned int ACPluged :It is otherwise 0 for 1 if stamping hook before AC In external power supply sockets;
unsigned int USBPluged :It is otherwise 0 for 1 if stamping hook before USB external power supply sockets;
unsigned int BatteryChargeStatus:If above-mentioned two option does not all select, for 3, otherwise when outer It is 1 when meeting power supply status option selection full charge, for 2 during selection nomal charge;
unsigned int PowerMV:Value set by storage battery capacity option;
In summary, the present invention is supplied to using journey by setting analog-driven and simulation UI modules by the analog-driven Sequence first interface and simulation UI module second interfaces are supplied to, application program reads simulated action from the analog-driven and refer to Order, and acted accordingly according to simulated action instruction, realize the simulation to battery status.Pass through the present invention, application The developer of program can carry out software development independently of the battery apparatus of reality, operate very convenient, and mould It is true to nature to intend effect, it is only necessary to ensure that first interface is consistent with the software function of the first interface in real hardware, you can ensureing should Can also be realized in real battery apparatus with program, even if so the present invention simulator replaced by real hardware, the simulation The difference of device and real hardware also can be neglected so that the application program after exploitation need not modify in the later stage, so as to improve The development efficiency of application program.
It should be appreciated that the application of the present invention is not limited to above-mentioned citing, for those of ordinary skills, can To be improved or converted according to the above description, all these modifications and variations should all belong to the guarantor of appended claims of the present invention Protect scope.

Claims (8)

  1. A kind of 1. simulator implementation method of simulated battery charged state, it is characterised in that including:
    Set one to include analog-driven and simulate the simulator of UI modules, the analog-driven is supplied to application program first interface And it is supplied to simulation UI module second interfaces;
    After the simulation UI modules receive simulated action instruction, write by second interface to analog-driven;
    The application program reads simulated action instruction by the first interface from the analog-driven, and according to the mould Intend action command to be acted accordingly, realize the simulation to battery charging state;On the first interface and actual hardware The software function of interface is consistent;
    Simulation UI modules realize that module includes:Power.h, power.cpp, simphone.h, simphone.cpp, wherein, Cpp and h is the type of program file, and the realization of function is all placed on cpp files, and h files are header file, and the definition of function is all put In h files;
    Simphone.h is used for the object for creating a battery, i.e. Object Creation module, for handling when battery charging state changes It is shown in during change in simulation UI modules;Power.h, for storing present battery charged state, i.e. battery status memory module; Simphone.cpp is used for the data structure that simulated action instruction is written to analog-driven by the second interface of analog-driven In, i.e., simulated action instructs writing module;
    The power.cpp is used to perform the current charging instruction of battery, i.e. battery charging execution module.
  2. 2. the simulator implementation method of simulated battery charged state according to claim 1, it is characterised in that also include:
    It is used for the data structure for representing battery charging state defined in analog-driven in advance.
  3. 3. the simulator implementation method of simulated battery charged state according to claim 2, it is characterised in that the simulation UI modules include following option:AC external power supply sockets, USB external power supply sockets, external power supply state, battery electric quantity and power supply Status display column, the corresponding member value that each option corresponds in data structure.
  4. A kind of 4. simulator using implementation method simulated battery charged state as claimed in claim 1, it is characterised in that institute Stating simulator includes analog-driven and simulation UI modules;
    The analog-driven, for being supplied to application program first interface and being supplied to simulation UI module second interfaces;
    The simulation UI modules, write for the simulated action received to be instructed by second interface to analog-driven, it is described Application program reads simulated action instruction by the first interface from the analog-driven, and is referred to according to the simulated action Order is acted accordingly, realizes the simulation to battery charging state;The first interface is soft with the interface on actual hardware Part function is consistent;
    Simulation UI modules realize that module includes:Power.h, power.cpp, simphone.h, simphone.cpp, wherein, Cpp and h is the type of program file, and the realization of function is all placed on cpp files, and h files are header file, and the definition of function is all put In h files;
    Simphone.h is used for the object for creating a battery, i.e. Object Creation module, for handling when battery charging state changes It is shown in during change in simulation UI modules;Power.h, for storing present battery charged state, i.e. battery status memory module; Simphone.cpp is used for the data structure that simulated action instruction is written to analog-driven by the second interface of analog-driven In, i.e., simulated action instructs writing module;
    The power.cpp is used to perform the current charging instruction of battery, i.e. battery charging execution module.
  5. 5. the simulator of simulated battery charged state according to claim 4, it is characterised in that the first interface includes using In the interface for obtaining battery charging state, battery charging state therein includes:Whether powered, whether powered by USB by AC, electricity Pond electricity height, there are state and battery capacity under external power supply.
  6. 6. the simulator of simulated battery charged state according to claim 4, it is characterised in that the reality of the simulation UI modules Existing module includes:
    Object Creation module, it is shown in for creating the object of a battery, and for handling when battery charging state changes Simulate in UI modules.
  7. 7. the simulator of simulated battery charged state according to claim 4, it is characterised in that the reality of the simulation UI modules Existing module also includes:
    Battery status memory module, for storing present battery charged state.
  8. 8. the simulator of simulated battery charged state according to claim 4, it is characterised in that the reality of the simulation UI modules Existing module also includes:
    Simulated action instructs writing module, and simulated action instruction is written into simulation for the first interface by analog-driven drives In dynamic data structure.
CN201310668562.9A 2013-12-11 2013-12-11 A kind of simulator and its implementation of simulated battery charged state Active CN103631641B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310668562.9A CN103631641B (en) 2013-12-11 2013-12-11 A kind of simulator and its implementation of simulated battery charged state

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310668562.9A CN103631641B (en) 2013-12-11 2013-12-11 A kind of simulator and its implementation of simulated battery charged state

Publications (2)

Publication Number Publication Date
CN103631641A CN103631641A (en) 2014-03-12
CN103631641B true CN103631641B (en) 2018-04-06

Family

ID=50212734

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310668562.9A Active CN103631641B (en) 2013-12-11 2013-12-11 A kind of simulator and its implementation of simulated battery charged state

Country Status (1)

Country Link
CN (1) CN103631641B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2015176340A (en) * 2014-03-14 2015-10-05 オムロン株式会社 Programmable controller and device control method by programmable controller

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593989A (en) * 2008-12-31 2009-12-02 中南林业科技大学 A kind of intelligent type accumulator testing charger and control method thereof
KR20100131088A (en) * 2009-06-05 2010-12-15 한국항공우주연구원 Satellite battery simulator
CN102288847A (en) * 2011-06-16 2011-12-21 深圳市科陆电子科技股份有限公司 Device and method for simulating working characteristic of charging post
CN102841317A (en) * 2011-06-23 2012-12-26 康舒科技股份有限公司 battery simulator
CN103389432A (en) * 2013-08-06 2013-11-13 国网电力科学研究院 Test device for charging control process of DC (direct current) battery charger of electric automobile and implementation method of device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101593989A (en) * 2008-12-31 2009-12-02 中南林业科技大学 A kind of intelligent type accumulator testing charger and control method thereof
KR20100131088A (en) * 2009-06-05 2010-12-15 한국항공우주연구원 Satellite battery simulator
CN102288847A (en) * 2011-06-16 2011-12-21 深圳市科陆电子科技股份有限公司 Device and method for simulating working characteristic of charging post
CN102841317A (en) * 2011-06-23 2012-12-26 康舒科技股份有限公司 battery simulator
CN103389432A (en) * 2013-08-06 2013-11-13 国网电力科学研究院 Test device for charging control process of DC (direct current) battery charger of electric automobile and implementation method of device

Also Published As

Publication number Publication date
CN103631641A (en) 2014-03-12

Similar Documents

Publication Publication Date Title
CN103080868B (en) Charging port
CN204243832U (en) A kind of charging and output compatible multiplex roles charging circuit
CN101938164B (en) Power equipment control method, device and related system thereof
CN103248763B (en) A kind of means of communication and mobile terminal
CN109802457A (en) A kind of electronic equipment and its charging method
CN107678753A (en) A kind of program burn writing method, apparatus and electronic equipment
CN103019702B (en) A kind of visualization of 3 d display and control editing system and method
CN103516557A (en) Method and system for testing
CN101505339B (en) Implementation method for directly deploying mobile phone application program from computer onto mobile phone
CN105182791A (en) RTDS-based photovoltaic power generation system digital and physical hybrid simulation system
CN105576753A (en) Information processing method and electronic equipment
CN102411310A (en) Simulation method of automobile power cell and apparatus thereof
CN103631641B (en) A kind of simulator and its implementation of simulated battery charged state
CN107526614A (en) FPGA development boards and its communication means
CN204117134U (en) A kind of electric-controlled plate wireless transmission programmer
CN113094256B (en) BMS software testing method and electronic equipment
CN104657293A (en) Method and device for man-machine interaction of ME (Mobile Equipment)
CN107861775A (en) A kind of SSD starts control device and method
CN209928235U (en) External equipment and system for refrigerator
CN101566853A (en) Vehicle driving data recording method and device
CN205003656U (en) Operating system of transparent programming of restructural hardware
CN103150952A (en) Reconfigurable electronic design automation (EDA) experimental platform
CN106355118A (en) IC card reader
CN113315195A (en) Charging control method, charging pile, mobile device and readable storage medium
CN106055062A (en) Charging management method of USB interface, and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20211201

Address after: 264200 19th floor, block a, innovation and entrepreneurship base, No. 213, Torch Road, torch high tech Industrial Development Zone, Weihai City, Shandong Province

Patentee after: WEIHAI ELECTRONIC INFORMATION TECHNOLOGY COMPREHENSIVE RESEARCH CENTER, MINISTRY OF INDUSTRY AND INFORMATION TECHNOLOGY

Address before: 6 / F, No.5, Lane 999, Yangfan Road, high tech Zone, Ningbo, Zhejiang 315100

Patentee before: TCL COMMUNICATION (NINGBO) Co.,Ltd.

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20221122

Address after: 264200 18th Floor, Building A, Innovation and Entrepreneurship Base, No. 213, Torch Road, Torch Hi tech Industrial Development Zone, Weihai, Shandong

Patentee after: Weihai Shenzhou Information Technology Research Institute Co.,Ltd.

Address before: 264200 19th floor, block a, innovation and entrepreneurship base, No. 213, Torch Road, torch high tech Industrial Development Zone, Weihai City, Shandong Province

Patentee before: WEIHAI ELECTRONIC INFORMATION TECHNOLOGY COMPREHENSIVE RESEARCH CENTER, MINISTRY OF INDUSTRY AND INFORMATION TECHNOLOGY