§ 6.1 Pipes of pipelines are mainly used in the Palmos platform to synchronize with desktop computers. When a thermal synchronization is performed, the Hot Sync Manager will call the pipe, keep the desktop computer to synchronize the information of the handheld device, back up the manner of the handheld device to the desktop computer, or download the information from the desktop computer to the handheld device. Understand the pipe: a standard Windows pipeline is a dynamic link library that provides a call entry function for the hot synchronization manager. In a given hot synchronization operation, it may be related to the following or all components: HotSync Manager: This program controls the entire hot synchronization process. The hot synchronization manager runs on the background of the desktop, monitors a specific communication port to respond to requests from the Palmos handheld device. Hot Synchronization Manager handles basic communication of desktop computers and handheld devices, controls multiple users of a desktop computer, install new applications and databases to handheld, because cold boots or other reasons lead to catastrophic data loss later Data on the handheld device: Conduit: Pipe is a plug-in module that handles data exchange between applications on the handheld device and desktop computer data source. During a thermal synchronization operation, the Hot Sync Manager calls each registered pipe to complete the corresponding data synchronization process. A pipe does not need to interact with the user to complete the data to modify the desktop, the handheld or both. When you design a pipeline, it is important to do any interaction with the user. When a user performs remote synchronization, he has no way to deal with any prompts obtained from the pipeline; the notification DLLS (Notifier DLLS): If a pipe and desktop application modify a data, then the desktop application must be notified during the synchronization process. Do not operate the data, this can prevent data from being destroyed or generated a recording copy. Before the Temperature Sync Manager calls the pipe to perform data transmission, the manager will call the Notification DLL for some special pipelines. The Notification DLL sequentially passes the information to the appropriate desktop program in the format that the desktop application can understand. The best example of this processing is "Palm Desktop", which does not allow users to modify any data during synchronization. The reason why "Palm Desktop" knows is in the synchronization process because there is its own advertisement DLL-PDN20.dll to inform it; PALM-side application: General Palm-side application is a fast data acquisition tool for desktop applications Provide some useful data. It can also be used as a lightweight reader, at any time view data sheet downloaded from the desktop. To allow it to support hot synchronization, you don't need to add any code to it; desktop applications: In fact, any desktop application can share data with Palmos handheld devices in place in pipe design. Desktop app can create data and send it to the handheld, processing data obtained from the handheld, or sharing data on the handheld device. Synchronous Manager API: This set of APIs offers the function of desktop computers and handheld devices using pipeline communication. Whether it is a desktop computer connection, this set of APIs can directly read and write data on the device; the step of hot synchronization: When the user starts a synchronous operation, whether it is a hot synchronization button that presses the base, or click The hot synchronization button in the hot synchronization program in the handheld device, the synchronization manager starts working. The following steps generally describe the entire thermal synchronization process: 1. User confirmation and positioning: Each Palmos handheld has a unique User ID associated with the manager. If the handheld device is used for the first time, the Hot Synchronization Manager will prompt you to select a user, so that the data can be maintained when a desktop computer and multiple handheld devices are operated synchronously.
At the beginning of the synchronous process, the manager ensures that the userid is legal and then positioned to the path of the user at the desktop. For example, my own user path is C: / Palm / Miken. Many pipes save their information in this subdirectory; 2, decide the synchronization type: A pipe will perform some of two synchronous operations: Slow synchronization and quick synchronization. In slow synchronization, the pipelines compares each record of the handheld device database and the PC's data source, and in the quick synchronization, the pipeline only compares the record of the modified flag; if the last synchronization of the handheld device is the same PC, hot synchronization manager will notify the pipe to perform fast synchronization, otherwise slow synchronization will not be executed, because the pipeline cannot rely on each record of the modification mark; 3. Notification of desktop applications: Hot Synchronization Manager call the corresponding advertisement DLL In order to let the desktop application know if the hot synchronization manager is modifying the data shared by PC and PALM; 4, the pipeline installation: The Sync Manager will return the Creator ID of each application of the handheld if the notice does not have problems. If a pipe is installed for a particular Creatorid, the synchronization manager will load this pipe to a list of modules that will run. Synchronous Manager also browsing those databases that are not "data" on the handheld computer. If the database sets a backup bit, the synchronization manager adds these databases to a list, and built-in backup pipes in the synchronization process will process this list; 5, install: Now Sync Manager can use its built-in pipeline to install Any database in the desktop computer queue. Generally, these databases are placed in queues by Palm's installation tool (Instapp.exe). In Windows, Palm Installation Tool copies these databases to the install subdirectory that changes the user directory. For example, the database waiting for installation in my computer is in the C: / Palm / Miken / Install directory; 6, the pipe execution: Synchronous manager loop processing in the fourth step, the list of pipelines already prepared, call each pipeline To synchronize your handheld equipment and desktop data; 7, secondary installation: In synchronization manager 3.0.1 or later, it will call the installation pipe again, this will make a chance to operate, so that it can get any pipeline Any database in the installation queue. This step allows a pipe to produce a database and "push" it "push" to the handheld device, the information returned from the web or other network source is very useful for pipelines. For example, Avantgo uses this feature to install the latest downloaded web page to the handheld device; 8, Database Backup: Synchronous Manager calls the backup pipe, store the data in the fourth step in the backup queue to the corresponding user's Backup Under contents. For example, my backup directory is a c: / palm / miken / backup directory; 9, synchronous information update: Sync Manager has completed most of the task, it will update synchronization time, PC ID and user ID, if necessary Also update the synchronization application of the handheld device. The synchronization manager will also send a streamlined synchronization log file to the handheld device, and the user can know the errors and warnings generated in the synchronization operation. 10. Second desktop application notification: Synchronization Manager Secondly calls the advertisement DLL to check if the synchronous operation is complete, the desktop application can be safely modified to share the shared data source; 11, the handheld application notice: Palmos give those new The installed and data modified in the synchronization process issues an advertisement, which is usually sent to the SysapplaunchCmdsyncNotify message to them.
Some applications need to perform some operations, such as rebooting warnings, registering BEAM data; 6.2 Piping Program Development This section we will focus on how to use Microsoft Visual C 6.0 and CDK4.01 to develop Windows pipelines on Windows. We assume that you are familiar with object-oriented programming ideas, you can use Visual C to develop, have experience in developing dynamic link libraries. Pipe Development Kit (CDK) can be downloaded from Palm's official website, which contains all templates, object classes, and some required documents, which you can easily create a Mac OS and Windows platform. If you develop the pipe of the Mac OS platform, you need to install MetrowerKs CodeWarrior 3.0 or higher. To develop Windows platform, you have two options: 1. Use Microsoft Visual C 6.0 and Windows version of CDK 2, Symantec Visual Cafe Pro for Java and The CDK Java Edition. The CDK Java version has been tested in Microsoft Visual J 1.1, but Visual Cafe Pro is supported by Palm's development platform. The disc that comes with the book includes the CDK4.0 version of the Mas OS platform, the CDK and Java version of the Windows platform. What we need to do: a full-functional pipeline DLL, you need to provide specific implementation of the following interface functions to the synchronization manager:
ExportFunc long OpenConduit (PROGRESSFN pFn, CSyncProperties & rProps); ExportFunc long GetConduitName (char * pszName, WORD nLen); ExportFunc DWORD GetConduitVersion (); ExportFunc long ConfigureConduit (CSyncPreference & pref); ExportFunc long GetConduitInfo (ConduitInfoEnum infoType, void * pInArgs, void * Pout, DWORD * pdwoutsize; ExportFunc Long cfgconduit (Conduitcfgenum CFGTYPE, VOID * PARGS, DWORD * PDWARGSSIZE); I will tell the role of these functions: OpenConduit: Operation after opening the pipe, is the truly synchronization of the pipe Some, you need to determine the direction of the synchronization according to rprops.m_synctype, and then add data to the code that implements synchronization in the implementation of the function. During your development process, you only need this function to implement, and other code that can be generated using the wizard. Of course, if necessary, you can also modify the implementation code of other interface functions; getConduitName: Returns the pipe name to the manager. If you use the pipeline configuration tool to get your name for your pipe, the synchronization manager will no longer call this function. You have added the processing of infotype as eConduitName in GetConduitInfo, which will not be called; getConduitversion: Remove the version number of your pipe; configureconduit and cfgconduit: are called when you change the configuration information of the pipe. When you select the "Custom" item of the Sync Manager menu, the user-defined dialog box will appear. You choose your pipe, press the "Change" button, and this function will be called. I usually only achieve cfgconduit, and the program is running very stable; getConduitInfo: You can get the default synchronization type, user name, user ID, pipe CreatorID, etc. When you use the wizard to create a new pipeline project, you will find that these interface functions have been ready for you, you just have to add some code according to your needs. Use the Pipe Wizard: Open Visualc 6.0, select the New item of the File menu, create a new project, as shown in Figure 6-1 Figure 6-1 Using the Conduit Wizard New Project We will create a pipeline project called Firstconduit.
Press the OK button to display the interface of the wizard first step, as shown in Figure 6-2, Figure 6-2 Conduit Wizard First Step Generic Type will provide Palm address, schedule, notepad, task (these four The procedures are Palmos attached to the five options, which provide you with a general pipeline basic class interface; the MFC type is similar, just it allows you to use Palm's MFC inner library in the program; third type Provide you with a basic framework for establishing a pipe DLL, including the DLL entry point position you need, you can more flexibly develop by calling the app function, and the construction of the project is also relatively simple, so we will introduce in this chapter. Using this type of development method, select "Conduit Entry Points Only", press the "Next" button to enter the second step. In this step you need to choose the characteristics of your pipeline. "Archiving" item allows you to read and write a file separate from the desktop data source, "Sync Action Configuration Dialog" joins the dialog box selected by the pipeline synchronization direction, selects the third item, enter the third step . Press the Finish button directly, our project is created. Figure 6-3 Conduit Wizard Second Step Figure 6-4 Conduit Wizard Step 3 Pipe Coding: In this example I just let you know that the pipeline has already run, so it is only available in the log. Synchronous information. You just need to do the following two steps: 1. Add #include
ExportFunc long OpenConduit (PROGRESSFN pFn, CSyncProperties & rProps) {long retval = -1; if (pFn) {// TODO - create your own custom sync class, and run it} LogAddEntry ( "My First Conduit", slSyncFinished, FALSE); Return (0);} Engineering Environment Settings: Select the setting item of the Project menu, enter the project settings dialog, as shown in Figure 6-5, Figure 6-5 Project Environment Variable Setting 1 Specify the path and file name of the synchronization manager so that we can You can directly execute the manager and debug our pipe DLL. In this dialog, there is a "Program Arguments", you can join the "-IC" switch so that the CDK comes with the pipe tracker. I used my own tracker during the development process, so I closed this feature. I can get it in the disc. At the same time, you also need to change the output path of the DLL, as shown in Figure 6-6. Of course, if your CDK installation directory is different from me, you need to make a corresponding modification. Handmade installation of the pipe: We are unlikely to make the user in the distribution of the pipeline, we need to write a procedure for automatically install the pipe. Here we are just to facilitate our development, use manual installation methods. At the directory Figure 6-6 Project Environment Variable Setting 2 / CDK401/common/bin/c4.01, we can get the tool "CONDCFG.EXE" of the pipeline configuration, execute it, and the appearance of Figure 6-7 Figure 6-7 Pipeline configuration The interface of the tool, press the "Add" button to add our new pipeline into it. The specific configuration is shown in Figure 6-8. It is necessary to mention that "Creator ID" is matched to the Creator ID of the handheld device application .prc. To the current location, the PC end has been completed (of course it does not transfer our data during synchronization, we need to write code completion), now we also need to write a corresponding Palm application. PALM-side application: Create a new project using CodeWarrior, modify the Creator ID as shown in Figure 6-9. Compiled into .prc. Figure 6-8 Configuration of New Pipes Figure 6-9 Changes .PRC Creator ID Test Pipe: Plus .prc first sync to Palm, select the VC integrated development environment Build menu, the execution, the execution load us The pipe manager, press the synchronization button, the interface as shown in Figures 6-10, indicating that synchronization is in progress during the synchronization processing. This interface will automatically disappear after the synchronization is complete. After the synchronization is complete, right click on the icon of the synchronization manager in the tray. In the menu that appears, select "View Log ..." item, you will see "Ok My First Conduit" in the log file, this shows that our pipeline is operating correctly. . If you have already made this step, congratulations, you have learned the basic steps of pipe development! Section IV will explain a specific example in detail a pipeline for data synchronization. If you understand the fourth quarter, you have fully capable of developing a complete pipeline business program. § 6.3 Pipeline development process of debugging techniques: I am going to talk about the skills of procedure before conducting specific pipeline development, because I know as a programmer, good debugging method will undoubtedly make his development work Half of skill, and knowing that debugging is also a must-have quality. I will tell you two very useful techniques in this section: the simulator directly debugs the tracking of the pipe and pipeline.
Simulator Direct Debuting Channel: You need to do the following settings in the simulator: 1. Open the menu of the simulator synchronization program, as shown in Figure 6-11; Figure 6-11 Menu 2 of the Synchronization program, select the Modem Synchronization Settings item, Set, determine, determine; Figure 6-12 Modify the modem parameter 3, select the "LAN Synchronization Settings" item of the menu, set, determined, determined in Figure 6-13; Figure 6-13 LAN synchronization parameter 4, select menu The "Host Settings" item, as shown in Figure 6-14, determined; Figure 6-14 Host Setting 5, select the "Enter Phone" button under the Simulator Synchronization Program "MODEM Hot Synchronization", "Phone Settings" What does not fill in the dialog, directly press the "OK" button, appear as shown in Figure 6-15; Figure 6-15 Sets the Modem Hot Synchronization 6, select "Settings" in the emulator's right-click menu Item, in accordance with Figure 6-16; Figure 6-16 Attribute setting 7, click the icon in the tray, select "Network" from the menu. Now you can press the "Modem Hot Synchron" icon directly as shown in Figure 6-17, Figure 6-17 Synchronizing the simulator using the simulator. This way if you don't have a machine, you can also learn pipe technology, and have more convenient communies with machines. Tracking of the pipe: Because the pipe is actually a DLL, it has brought certain troubles to our debugging, of course, single step tracking is also effective. A good debugging method will undoubtedly improve our development efficiency, so you must master a good debugging method. If you are a Visualc master, you must have better ways than me, you can jump directly to the next section. The method I introduced is more suitable for Visualc beginners. In the CD, I have a debugger I wrote myself, I will make you simply teach you to use it. 1. Turn the header file Miken.h to your project directory, select the "Add to Project" item of the Project menu, join this file to your project; 2, add the reference to it at the beginning of the fistconduitgencond.cpp file: #include "Miken.h; 3, select" settings "item" Project ", select the" C / C "tab in the dialog box, add" _Mikendebug "macro definition in the edit box under" PreProcessor Definitions " This is a switch. If there is no such macro, there will be no debugging information. So you can add this macro when debugging, and the pipeline debugging is successful, then remove this macro, recompile your project, will not There is no debugging information. 4, I will provide you with four macro interfaces, m_debug0, m_debug1, m_debug2, m_debug3, if you need to expand in the header file. If you need to view the run results of the program, you can Join: m_debug0 ("Haha, my pipe is coming", 0); m_debug1 ("Now you are in the synchronous database", M_Recordno, 1); m_debug2 ("field% s, value:% D ", m_fieldname, m_fieldvalue, 2); m_debug3 ("% D record, field% S, value% D ", M_ Recordno, M_FieldName, M_FieldValue, 3);
The last parameter of the macro interface is to indicate what color display string information is: 0: RGB (0,0,255) 1: RGB (27, 47, 247) 2: RGB (0,94,0) 3: RGB (255 0, 0) Other numbers: RGB (0,255,0) This time when the debug information is too much, you can distinguish them in color. If you use 3 to indicate an error message, you see that the red character information in the debugger indicates that there is an error. §6.4 Realization of a complex pipeline: Below I will take you a detailed step of doing a pipe with a patrol system in the hospital hospitalization system. In order to make the program simple, let the readers are easy to understand, I only select two tables, and each table takes only three fields, and I will give a comment if necessary. In the example, I only write code from the PALM end read the database, and the database of the PC side, you can use ADO, ODBC, and DAO, etc., specific encoding you can refer to the relevant books. PALM End App: The full application can get on the CD, here I only list the table structure: typef strunt // patient medical record table {int potientsex; // Gender, 0: Male 1: female int pattern; // age char HistoryNo [7]; // Inpatient number, primary keyword} casehistory, * pcasehistory; typef struct // long-term doctor meter
{Char HistoryNo [7]; // Hospital No. Char PatientName [9]; // Name CHAR Section [5]; // Academic
LONGADVICE, * PLONGADVICE;
Realization of pipes: 1. Refer to 6.2 Section 6. Adjustment into a new project, named Hospital; 2, refer to "Tracking" section in Section 6.3, add "Miken.h" to your project, in HospitAlgencond. The start of CPP is referenced, and the macro definition is added _Mikendebug; 3, the table structure definition, CaseTemp and AdviceTem are two temporary structures: typedef struct // patient medical record table
{Long Patientsex; // Gender, 0: Male 1: Female
Long Patientage;
// Age Char * HistoryNO; // Inpatient number, main keyword
} CaseHistory, * PCaseHistory; TypeDef struct // long-term doctor meter
{char * historyno; // 住 住 CHAR * PATIENTNAME; / / Name Char * Section; // Academic
} LongAdvice, * plongadvice; typef struct {char point [1];} CaseTemp; typef struct {long sex; long agent; char point [1];} adviceTemp; 4, modify the OpenConduit section:
ExportFunc Long OpenConduit (Progressfn Pfn, CsyncProperties & rProps) {long return = -1; switch (rprops.m_syncType) // Get the currently set synchronization direction
{CASE EPCTOHH: / / PC to Palm
M_debug ("Your current operation is PC -> Palm", 0); retval = copypctopalm (rprops); Break; Case EHHTOPC: // Palm to PC
M_debug ("Your current operation is Palm -> PC", 0); RetVal = CopyPalmtopc (rprops); Break; Case Eslow: // Slow Synchronization and Fast Synchronization Break; Case Efast: Break;} Return (RetVal); } 5, custom functions CopyPctopalm and CopyPalmTopc implement code, see CD project. Author webmaster http://www.msale.net/index.php?page=4&mode=Article&k=9