Error: A library uses the same package分析和处理

从提示可以看出,项目中使用的库跟主项目的包名重复,基本上有着几个原因:

  • 一、导入的Module中的build.gradle的defaultConfig的applicationId中与跟主项目中build.gradle的defaultConfig的applicationId相同,有种解决方法为:在主项目的defaultConfig添加enforceUniquePackageName = false
    但其实现在谷歌已经不允许在导入的library中定义applicationId,因此上述情况不因该有存在,基本上考虑第二种情况。

  • 二、导入的第三方的开源项目的library时,根据要求需要设置依赖,但是有人却将依赖设置的位置不对或者重复了,例如将依赖的compile之类的设到了导入的library的build.gradle中,同时在主项目中的build.gradle也设。只要将依赖只添加到后者就好了。

  • 其实主要的原因就是你将导入第三方的库的包名也写在你第三方的库的build.gradle中
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Version 1.7 ----------- - ADD: Delphi/CBuilder 10.2 Tokyo now supported. - ADD: Delphi/CBuilder 10.1 Berlin now supported. - ADD: Delphi/CBuilder 10 Seattle now supported. - ADD: Delphi/CBuilder XE8 now supported. - ADD: Delphi/CBuilder XE7 now supported. - ADD: Delphi/CBuilder XE6 now supported. - ADD: Delphi/CBuilder XE5 now supported. - ADD: Delphi/CBuilder XE4 now supported. - ADD: Delphi/CBuilder XE3 now supported. - ADD: Delphi/CBuilder XE2 now supported. - ADD: Delphi/CBuilder XE now supported. - ADD: Delphi/CBuilder 2010 now supported. - ADD: Delphi/CBuilder 2009 now supported. - ADD: New demo project FlexCADImport. - FIX: The height of the TFlexRegularPolygon object incorrectly changes with its rotation. - FIX: Added division by zero protect in method TFlexControl.MovePathSegment. - FIX: The background beyond docuemnt wasn't filled when TFlexPanel.DocClipping=True. - FIX: In "Windows ClearType" font rendering mode (OS Windows mode) the "garbage" pixels can appear from the right and from the bottom sides of the painted rectangle of the TFlexText object. - FIX: The result rectangle incorrectly calculated in the TFlexText.GetRefreshRect method. - FIX: Added FPaintCache.rcPaint cleanup in the TFlexPanel.WMPaint method. Now it is possible to define is the drawing take place via WMPaint or via the PaintTo direct call (if rcPaint contain non-empty rectangle then WMPaint in progress). - FIX: The TFlexPanel.FPaintCache field moved in the protected class section. Added rcPaint field in FPaintCache that represents drawing rectangle. - ADD: In the text prcise mode (TFlexText.Precise=True) takes into account the rotation angle (TFlexText.Angle). - FIX: Removed FG_NEWTEXTROTATE directive (the TFlexText Precise mode should be used instead). - FIX: The TFlexRegularPolygon object clones incorrectly drawed in case when TFlexRegularPolygon have alternative brush (gradient, texture). - ADD: Add TFlexPanel.InvalidateControl virtual method which calls from TFle
Version V6.48 (2019-07-26) Added flash programming support for AmbiqMicro's AMA2B1KK (Apollo2 Blue; AMA2BEVB). Added flash programming support for AmbiqMicro's AMA2B1KK (Apollo2 Blue; AMA2BEVB). Added unlocking support for Microchip SAML10 series devices. Added unlocking support for Microchip SAML10 series devices. Analog Devices ADUCM355: Reset could not be overwritten using a J-Link script file. Fixed. CCS plugin: Added a new option which allows configuring a J-Link script file (project dependent). Commander: "erase" did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. Commander: "erase" did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. DLL Updater (internal): Added Infineons Micro Inspector. DLL Updater (internal): Added Infineons Micro Inspector. DLL: STM32WB55 added support for Co-Processor Wireless stack upgrade. DLL: Added Flash programming support for CYT2B9 series devices. DLL: Added Flash programming support for CYT2B9 series devices. DLL: Added Flash programming support for Cypress Traveo2 CYT2B and CYT4B series devices. DLL: Added Flash programming support for Cypress Traveo2 CYT2B and CYT4B series devices. DLL: Added OTP flash programming support for TI's RM42L device family. DLL: Added OTP flash programming support for TI's RM44L device family. DLL: Added OTP flash programming support for TI's RM46L device family. DLL: Added OTP flash programming support for TI's RM48L device family. DLL: Added flash programming support for Panasonic MN1M7BFxx and MN1M7AFxx series devices. DLL: Added flash programming support for Panasonic MN1M7BFxx and MN1M7AFxx series devices. DLL: Added flash programming support for ST STM32G47xx series devices. DLL: Added flash programming support for ST STM32G4xx series devices. DLL: Added flash programming support for ST STM32G4xx series devices. DLL: Added flash programming support for STM32H745, STM32H755, STM32H747 and STM32H757 series devices. DLL: Added flash programming support for STM32H745, STM32H755, STM32H747 and STM32H757 series devices. DLL: Added flash programming support for WIZnet W7500 series device. DLL: Added flash programming support for WIZnet W7500 series device. DLL: Added native trace buffer support for Renesas RZ/A2M series. DLL: Added support for Cypress CYT2B series devices Cortex-M4. DLL: Added support for Cypress CYT4B series devices Cortex-M7_0 and Cortex-M7_1. DLL: Added support for Cypress MB9DF / MB9EF series (FCR4) devices. DLL: Added support for RISC-V behind a DAP as setup. DLL: Added support for RISC-V via SWD for RISC-V behind a DAP setups. DLL: Added support for SPI FLash Adesto ATXP128/ATXP128R to SPIFI-Lib for indirect flash programming. DLL: Added support for SPI FLash Adesto ATXP128/ATXP128R to SPIFI-Lib for indirect flash programming. DLL: Added support for command string "CORESIGHT_SetCoreBaseAddr" DLL: Cypress PSoC4 family: Under special circumstances, unlock did not work. Fixed. DLL: Cypress PSoC4 family: Under special circumstances, unlock did not work. Fixed. DLL: Flash programming sector sizes corrected for Traveo2 CYT4B series devices. DLL: Flash programming sector sizes corrected for Traveo2 CYT4B series devices. DLL: For the MPC560xx devices, the ECC SRAM was not initialized after connect. Fixed. DLL: Hilscher NetX90 flash bank size, fixed. DLL: Infineon TLE98xx: Some J-Link LITEs could not connect establish a successful target connection due to missing firmware functionality. Fixed. DLL: JTAG: When only having 1 TAP in the JTAG chain and its matches the one for the configured CPU core but the TAP-ID was unknown, connect did not work. Fixed. DLL: Linux: Delayed / slowed execution of certain API functions when using J-Link via USB (e.g. on Close()). Introduced in V6.46. Fixed. DLL: Linux: When calling a J-Link application via the global symlink (e.g. "JLinkExe" instead of "./JLinkExe"), sometimes the JLinkDevices.xml file was not found. Fixed. DLL: Linux: When calling a J-Link application via the global symlink (e.g. "JLinkExe" instead of "./JLinkExe"), sometimes the libjlink* shared library was not found. Fixed. DLL: Microchip J-32 OEM probes could not support legacy Atmel devices. Fixed. DLL: Minor bug in flash programming algorithm for STM32G0xx series devices, fixed. DLL: NXP KW34: Added flash programming support for the program and data flash area. DLL: NXP KW34: Added flash programming support for the program and data flash area. DLL: NXP KW35 / KW36 / KW38 / KW39: Added flash programming support for the data flash area. DLL: NXP KW35 / KW36 / KW38 / KW39: Added flash programming support for the data flash area. DLL: NXP KW38: Corrected device names showen in the device selection dialog. DLL: NXP KW38: Corrected device names showen in the device selection dialog. DLL: NXP KW3x family: Improved flash programming speed significantly. DLL: NXP KW3x family: Improved flash programming speed significantly. DLL: NXP LPC18xx / LPC43xx: After QSPI flash programming, the QSPI flash memory was no longer memory mapped accessible. Introduced in V6.41. Fixed. DLL: Open flash loaders for RISC-V did not work properly anymore (introduced with V6.46). Fixed. DLL: Programming issue while another application is already running on Hilscher NetX90, fixed. DLL: QSPI flash programming: When the QE bit was set before flash programming, it has been cleared but not restored by the DLL. Introduced in V6.46h. Fixed. DLL: Qorvo GP570 / UE878 / QPG6 family: Flash programming did not work in recent silicon revisions. Fixed. DLL: Qorvo GPxxx: Under special circumstances, flash programming did not work. Fixed. DLL: RAM size of ST STM32F412 series devices, fixed. DLL: RISC-V behind a DAP: Setting system variables , , from J-Link script files did not have any effect for RISC-V behind a DAP. Fixed. DLL: RISC-V behind a DAP: Setting system variables , , from J-Link script files did not have any effect for RISC-V behind a DAP. Fixed. DLL: RISC-V: Added reset type "Reset Pin" to explicitly allow resetting the target via the reset pin, instead of the bit DLL: RISC-V: Changed default reset type from reset pin to to support reset on almost all systems, also ones that do not populate a reset pin DLL: RISC-V: Interrupts were not disabled correctly during flash programming for built-in flash algos (works well for open flash loaders). Fixed. DLL: RISC-V: Reset could fail with "core did not halt after reset" even if the core halted correctly. Fixed. DLL: Re-attaching to existing debug session after connecting and disconnecting once via TELNET (e.g. used by RTTClient and RTTViewer) did not work properly. Fixed. DLL: Renesas R5F51306 (RX130) devices were not detected by the J-Link DLL. Fixed. DLL: Renesas RX231: OFS1 could not be modified. Fixed. DLL: Renesas RX: Added support for RX66N series devices DLL: Renesas RX: Added support for RX72M series devices DLL: Renesas RX: Added support for RX72M series devices DLL: Renesas RX: Added support for RX72N series devices DLL: Renesas RX: Added support for RX72T series devices DLL: Renesas RX: Added support for RX72T series devices DLL: Renesas RX: RX66T: Programming of option-setting memory (OSIS) did not work properly. Fixed. DLL: Renesas RX: When connecting to locked RX devices via JTAG (does not affect FINE!), 16-byte IDCODE (OSIS) could be rejected even though the correct code was given. Fixed. DLL: Renesas S7G2: QSPI flash programming did not work for QSPI flashes >= 16MB. Fixed. DLL: Resets during halt of TI RM57L843ZWT device, due to running watchdog, fixed. Enabled cross trigger interfaces to forward debug acknowledge signal to Watchdog. DLL: SPI-Flash programming for Spansion S25FL256L, fixed. DLL: STM32L031K6 secure chip did not work. Fixed. DLL: STM32WB55 added support for Co-Processor Wireless stack upgrade. DLL: TI RM42L420 added EEPROM support. DLL: TI RM44L520/RM44L920 added flash and EEPROM support DLL: TI RM57L843ZWT added EEPROM support. DLL: TI RM57L843ZWT added EEPROM support. DLL: Under some circumstances Flash Cache was not cleaned after erase operations. DLL: Unsecure read protection for STM32L151xx series devices, fixed. DLL: Unsecure write protection for STM32L151xxx series devices, fixed. DLL: When using J-Trace PRO with IAR EWARM a "failed to allocate x bytes of memory" error could occur. Fixed. DLL: Windows: Renesas RX: When using FINE interface and disabling ongoining debug mode on debug session close, it could happen that a thread was not exited gracefully, causing handle leaks. Fixed. DLL: macOS: When calling a J-Link application via the global symlink (e.g. "JLinkExe" instead of "./JLinkExe"), sometimes the libjlink* shared library was not found. Fixed. Firmware: Flasher ARM / PRO / Portable PLUS: Chip erase could fail in stand-alone mode. Fixed. Firmware: Flasher ARM / PRO / Portable PLUS: Parallel CFI NOR Flash memory programming could fail under special circumstances. Fixed. Firmware: Flasher ARM / PRO / Portable PLUS: Stand-alone mode did not work for some devices from Analog Devices (e.g. ADuCM7023). Fixed. Firmware: Flasher ARM / PRO: FWrite command was unable to receive 512 bytes via UART at once. Fixed. Firmware: Flasher ARM V4: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: Flasher ARM/PPC/RX/PRO: Target power supply monitoring could erroneously detect an over-current. Fixed. Firmware: Flasher PRO: Open flash loaders for RISC-V did not work properly anymore (introduced with V6.46). Fixed. Firmware: Flasher PRO: Universal Flash Loader mode detection in batch mode did not work. Fixed. Firmware: Flasher PRO: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: Flasher Portable PLUS did not show the correct status under special circumstances. Fixed. Firmware: Flasher Portable PLUS did not work in J-Link Mode while showing "OK" message. Fixed. Firmware: Flasher Portable PLUS: Universal Flash Loader mode detection in batch mode did not work. Fixed. Firmware: Flasher Portable PLUS: Number of bytes to program was not calculate correctly, progress bar showed wrong percentage. Fixed. Firmware: Flasher Portable PLUS: Open flash loaders for RISC-V did not work properly anymore (introduced with V6.46). Fixed. Firmware: Flasher Portable PLUS: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link EDU Mini: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link EDU Mini: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link EDU/BASE/PLUS V10: Added support for RISC-V behind a DAP as setup. Firmware: J-Link EDU/BASE/PLUS V10: Increased heap size of firmware (Added support for heap over multiple memory ranges with gaps between them) Firmware: J-Link EDU/BASE/PLUS V10: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link EDU/BASE/PLUS V10: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link EDU/BASE/PLUS V10: SWO: Under very special circumstances it could happen that the 1st byte received on SWO was swallowed. Only happened, if SWO pin was used for something else between SWO_Stop() and SWO_Start(). Fixed. Firmware: J-Link EDU/BASE/PLUS V10: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link OB-K22-SiFive: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link PRO V4: Added support for RISC-V behind a DAP as setup. Firmware: J-Link PRO V4: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link PRO V4: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link PRO V4: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link PRO V4: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Link ULTRA+ V4: Added support for RISC-V behind a DAP as setup. Firmware: J-Link ULTRA+ V4: RISC-V: On implementations that do not populate a "program buffer" CSRs could not be accessed correctly, resulting in non-functional debug sessions. Fixed. Firmware: J-Link ULTRA+ V4: RISC-V: Reset on SiFive FE310 device (mounted on HiFive1 boards) could fail with timeout error. Fixed. Firmware: J-Link ULTRA+ V4: Warning "J-Link low on memory" could occur after using SPI functionality of J-Link. Fixed. Firmware: J-Link ULTRA+ V4: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Link-OB-K22-SiFive: Linux: When using both VCOM ports extensively under special circumstances it could happen that the USB communication locked up. Fixed. Firmware: J-Trace PRO V1 Cortex-M: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Trace PRO V2 Cortex-M: Corrected typo on th webserver trace configuration page. Firmware: J-Trace PRO V2 Cortex-M: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Firmware: J-Trace PRO V2 Cortex: Corrected typo on th webserver trace configuration page. Firmware: J-Trace PRO V2 Cortex: When connecting via IP and using RTT it could happen that J-Link FW crashed and rebooted if the PC did not exit the controlling process in a clean way. Fixed. Flasher ARM / PRO / Portable PLUS: Init/Exit step BNE and BEQ could jump to #step + 1. Fixed. Flasher ARM / PRO / Portable PLUS: Open Flashloader RAMCodes in stand-alone-mode can be >12kB now. Flasher ARM / PRO / Portable PLUS: Stand-alone mode did not work for some ARM devices. Introduced in V6.47b. Fixed. Flasher ARM / PRO: Reading or writing memory in J-Link mode via JTAG caused the firmware to hang and report a USB timeout. Fixed. Flasher: Added stand-alone mode support for Traveo2 CYT2B and CYT4B devices. Flasher: Added stand-alone mode support for Traveo2 CYT2B and CYT4B devices. GDBServer: Under special circumstances, a remote "g" packet error popped up when using the GDBServer with Cortex-AR or MIPS. Fixed. GUI applications (Linux): The directory the application was executed from affected the behavior of the application. Fixed. J-Flash Lite: Updated to select the flash base address of the selected device by default as "Prog. Addr." instead of always 0x00000000. J-Flash Lite: Updated to select the flash base address of the selected device by default as "Prog. Addr." instead of always 0x00000000. J-Flash SPI: Added flash programming support for ISSI IS25LP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25LP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25LP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25LP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP016D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP080D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP128D SPI Flash. J-Flash SPI: Added flash programming support for ISSI IS25WP128D SPI Flash. J-Flash SPI: Licenses that have been burned into J-Link via J-Link Commander "license add" command were not detected properly. Fixed. J-Flash: Generated data files could be unnecessarily big. Fixed. J-Flash: Generated data files could be unnecessarily big. Fixed. J-Flash: Improved error messages during the check, if the data fits into the flash memory. J-Flash: Improved error messages during the check, if the data fits into the flash memory. J-Flash: Licenses that have been burned into J-Link via J-Link Commander "license add" command were not detected properly. Fixed. J-Link BASE/EDU/PLUS: SPI flash programming with J-Flash SPI was very slow. Fixed. J-Link Commander: RISC-V: Added to the list of suggested/available interfaces JFlash: Added command line parameter "?" (Same functionality as "-?"). JFlash: Added command line parameter "?" (Same functionality as "-?"). JFlashSPI: Added SPI flash programming support for ISSI IS25LP016D SPI flash. JFlashSPI: Added SPI flash programming support for ISSI IS25LP016D SPI flash. JFlashSPI_CL: Added command line parameter "?" (Same functionality as "-?"). JFlashSPI_CL: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTClient: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTClient: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTLogger: Added command line parameter "?" (Same functionality as "-?"). JLinkRTTLogger: Added command line parameter "?" (Same functionality as "-?"). JLinkSTR91x: Added command line parameter "?" (Same functionality as "-?") and implemented "help" functionality which returns the available command line parameters. JLinkSTR91x: Added command line parameter "?" (Same functionality as "-?") and implemented "help" functionality which returns the available command line parameters. JTAGLoad: Added command line parameters "?" and "-?" (Same functionality as "/?"). JTAGLoad: Added command line parameters "?" and "-?" (Same functionality as "/?"). PCodes: Changed an ambiguous J-Link report output. PCodes: Resolved an issue where some Cypress PSoC4 devices would not unlock automatically when connecting to them. Fixed. Package: USB driver for VCOM: Under very special circumstances bluescreens could occur when using VCOM. Fixed. (Driver update only applies to Windows Vista and later. Windows XP still uses the old driver as the new one is not compatible to Windows XP anymore) RTTClient: Connecting to existing session did not work correctly on MacOS. Fixed. RTTClient: Linux: Ubuntu: Attaching to existing debug session did not work properly. Fixed. RTTLogger (Linux): Using logrotate lead to null characters being printed before RTT data. Fixed., RTTViewer: Added 'All terminals' message in case of connection loss. RTTViewer: Added information display on how to correctly enter RTT control block search range. RTTViewer: Echo to Terminal 0 / 'All terminals' was not working correctly. Fixed. RTTViewer: Fixed 'Attach to existing session' mode for Windows, MacOS and Linux. RTTViewer: Fixed typo. RTTViewer: Improved J-Link connect/ disconnect sequence. RTTViewer: Improved handling for data logging. RTTViewer: Improved handling for terminal logging. RTTViewer: Improved log messages when connecting to J-Link. RTTViewer: Improved log output. RTTViewer: Improved reconnecting for attach mode. RTTViewer: Improved the handling in case reading of RTT data failed. RTTViewer: In some occasions, the CL option '--autoconnect' did not work. Fixed. RTTViewer: In some rare occasions, clearing a terminal could crash the application. Fixed. RTTViewer: Linux: Ubuntu: Option "Attaching to existing debug session" did not work properly. Fixed. RTTViewer: Some ANSI CSI sequences caused the application to crash. Fixed. RTTViewer: The '--autoconnect' CL option caused the application to crash. Fixed. RemoteServer: Command line options '-select USB=' and '-SelectEmuBySN ' did not work correctly. Fixed. SDK (Windows): Linking against the *.lib files with MinGW did throw errors reg. undefined references to "__security_check_cookie" and "__GSHandlerCheck". Fixed. SDK: JLINKARM_EraseChip() did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. SDK: JLINKARM_EraseChip() did not use the EraseChip command to erase the entire flash but the EraseSector command. Changed. Trace: Under certain circumstances backtrace was not showing for targets with PTM. Fixed. UM08002: Chapter "Python support" added. UM08002: Chapter "Python support" updated. Section "API Functions": Added "FlashDownload" description
Foundations for Analytics with Python by Clinton W. Brownley Copyright © 2016 Clinton Brownley. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. Overview of Chapters Chapter 1, Python Basics We’ll begin by exploring how to create and run a Python script. This chapter focuses on basic Python syntax and the elements of Python that you need to know for later chapters in the book. For example, we’ll discuss basic data types such as numbers and strings and how you can manipulate them. We’ll also cover Preface | xvii the main data containers (i.e., lists, tuples, and dictionaries) and how you use them to store and manipulate your data, as well as how to deal with dates, as dates often appear in business analysis. This chapter also discusses programming concepts such as control flow, functions, and exceptions, as these are important elements for including business logic in your code and gracefully handling errors. Finally, the chapter explains how to get your computer to read a text file, read multiple text files, and write to a CSV-formatted output file. These are important techniques for accessing input data and retaining specific output data that I expand on in later chapters in the book. Chapter 2, Comma-Separated Values (CSV) Files This chapter covers how to read and write CSV files. The chapter starts with an example of parsing a CSV input file “by hand,” without Python’s built-in csv module. It transitions to an illustration of potential problems with this method of parsing and then presents an example of how to avoid these potential problems by parsing a CSV file with Python’s csv module. Next, the chapter discusses how to use three different types of conditional logic to filter for specific rows from the input file and write them to a CSV output file. Then the chapter presents two dif‐ ferent ways to filter for specific columns and write them to the output file. After covering how to read and parse a single CSV input file, we’ll move on to discus‐ sing how to read and process multiple CSV files. The examples in this section include presenting summary information about each of the input files, concate‐ nating data from the input files, and calculating basic statistics for each of the input files. The chapter ends with a couple of examples of less common proce‐ dures, including selecting a set of contiguous rows and adding a header row to the dataset. Chapter 3, Excel Files Next, we’ll cover how to read Excel workbooks with a downloadable, add-in module called xlrd. This chapter starts with an example of introspecting an Excel workbook (i.e., presenting how many worksheets the workbook contains, the names of the worksheets, and the number of rows and columns in each of the worksheets). Because Excel stores dates as numbers, the next section illustrates how to use a set of functions to format dates so they appear as dates instead of as numbers. Next, the chapter discusses how to use three different types of condi‐ tional logic to filter for specific rows from a single worksheet and write them to a CSV output file. Then the chapter presents two different ways to filter for specific columns and write them to the output file. After covering how to read and parse a single worksheet, the chapter moves on to discuss how to read and process all worksheets in a workbook and a subset of worksheets in a workbook. The exam‐ ples in these sections show how to filter for specific rows and columns in the worksheets. After discussing how to read and parse any number of worksheets in a single workbook, the chapter moves on to review how to read and process mul‐tiple workbooks. The examples in this section include presenting summary infor‐ mation about each of the workbooks, concatenating data from the workbooks, and calculating basic statistics for each of the workbooks. The chapter ends with a couple of examples of less common procedures, including selecting a set of contiguous rows and adding a header row to the dataset. Chapter 4, Databases Here, we’ll cover how to carry out basic database operations in Python. The chapter starts with examples that use Python’s built-in sqlite3 module so that you don’t have to install any additional software. The examples illustrate how to carry out some of the most common database operations, including creating a database and table, loading data in a CSV input file into a database table, updat‐ ing records in a table using a CSV input file, and querying a table. When you use the sqlite3 module, the database connection details are slightly different from the ones you would use to connect to other database systems like MySQL, Post‐ greSQL, and Oracle. To show this difference, the second half of the chapter dem‐ onstrates how to interact with a MySQL database system. If you don’t already have MySQL on your computer, the first step is to download and install MySQL. From there, the examples mirror the sqlite3 examples, including creating a database and table, loading data in a CSV input file into a database table, updat‐ ing records in a table using a CSV input file, querying a table, and writing query results to a CSV output file. Together, the examples in the two halves of this chapter provide a solid foundation for carrying out common database operations in Python. Chapter 5, Applications This chapter contains three examples that demonstrate how to combine techni‐ ques presented in earlier chapters to tackle three different problems that are rep‐ resentative of some common data processing and analysis tasks. The first application covers how to find specific records in a large collection of Excel and CSV files. As you can imagine, it’s a lot more efficient and fun to have a computer search for the records you need than it is to search for them yourself. Opening, searching in, and closing dozens of files isn’t fun, and the task becomes more and more challenging as the number of files increases. Because the problem involves searching through CSV and Excel files, this example utilizes a lot of the material covered in Chapters 2 and 3. The second application covers how to group or “bin” data into unique categories and calculate statistics for each of the categories. The specific example is parsing a CSV file of customer service package purchases that shows when customers paid for particular service packages (i.e., Bronze, Silver, or Gold), organizing the data into unique customer names and packages, and adding up the amount of time each customer spent in each package. The example uses two building blocks, creating a function and storing data in a dictionary, which are introduced in Chapter 1 but aren’t used in Chapters 2, 3, and 4. It also introduces another new technique: keeping track of the previous row you processed and the row you’re currently processing, in order to calculate a statistic based on values in the two rows. These two techniques—grouping or binning data with a dictionary and keeping track of the current row and the previous row—are very powerful capabilities that enable you to handle many common analysis tasks that involve events over time. The third application covers how to parse a text file, group or bin data into cate‐ gories, and calculate statistics for the categories. The specific example is parsing a MySQL error log file, organizing the data into unique dates and error messages, and counting the number of times each error message appeared on each date. The example reviews how to parse a text file, a technique that briefly appears in Chapter 1. The example also shows how to store information separately in both a list and a dictionary in order to create the header row and the data rows for the output file. This is a reminder that you can parse text files with basic string oper‐ ations and another good example of how to use a nested dictionary to group or bin data into unique categories. Chapter 6, Figures and Plots In this chapter, you’ll learn how to create common statistical graphs and plots in Python with four plotting libraries: matplotlib, pandas, ggplot, and seaborn. The chapter begins with matplotlib because it’s a long-standing package with lots of documentation (in fact, pandas and seaborn are built on top of matplot lib). The matplotlib section illustrates how to create histograms and bar, line, scatter, and box plots. The pandas section discusses some of the ways pandas simplifies the syntax you need to create these plots and illustrates how to create them with pandas. The ggplot section notes the library’s historical relationship with R and the Grammar of Graphics and illustrates how to use ggplot to build some common statistical plots. Finally, the seaborn section discusses how to cre‐ ate standard statistical plots as well as plots that would be more cumbersome to code in matplotlib. Chapter 7, Descriptive Statistics and Modeling Here, we’ll look at how to produce standard summary statistics and estimate regression and classification models with the pandas and statsmodels packages. pandas has functions for calculating measures of central tendency (e.g., mean, median, and mode), as well as for calculating dispersion (e.g., variance and stan‐ dard deviation). It also has functions for grouping data, which makes it easy to calculate these statistics for different groups of data. The statsmodels package has functions for estimating many types of regression and classification models. The chapter illustrates how to build multivariate linear regression and logistic classification models based on data in pandas DataFrames and then use the mod‐ els to predict output values for new input data. Chapter 8, Scheduling Scripts to Run Automatically This chapter covers how to schedule your scripts to run automatically on a rou‐ tine basis on both Windows and macOS. Until this chapter, we ran the scripts manually on the command line. Running a script manually on the command line is convenient when you’re debugging the script or running it on an ad hoc basis. However, it can be a nuisance if your script needs to run on a routine basis (e.g., daily, weekly, monthly, or quarterly), or if you need to run lots of scripts on a routine basis. On Windows, you create scheduled tasks to run scripts automati‐ cally on a routine basis. On macOS, you create cron jobs, which perform the same actions. This chapter includes several screenshots to show you how to cre‐ ate and run scheduled tasks and cron jobs. By scheduling your scripts to run on a routine basis, you don’t ever forget to run a script and you can scale beyond what’s possible when you’re running scripts manually on the command line. Chapter 9, Where to Go from Here The final chapter covers some additional built-in and add-in Python modules and functions that are important for data processing and analysis tasks, as well as some additional data structures that will enable you to efficiently handle a variety of complex programming problems you may run into as you move beyond the topics covered in this book. Built-ins are bundled into the Python installation, so they are immediately available to you when you install Python. The built-in mod‐ ules discussed in this chapter include collections, random, statistics, iter tools, and operator. The built-in functions include enumerate, filter, reduce, and zip. Add-in modules don’t come with the Python installation, so you have to download and install them separately. The add-in modules discussed in this chapter include NumPy, SciPy, and Scikit-Learn. We also take a look at some additional data structures that can help you store, process, or analyze your data more quickly and efficiently, such as stacks, queues, trees, and graphs.
Release history (reverse chronological order) This release 1.3.7.1 Release date: December 11, 2006 Known bugs: none Fixes/features added from previous release: a) added support for multiple filters per process in VsDrvr.dll b) updated manual Previous release 1.3.5 Release date: October 11th, 2005 Known bugs: none Fixes/features added from previous release a) added VsSetWavelengthStep and VsGetWavelengthStep functions b) added VsSetWavelengthWavesConfirm() function c) fixed error-handling of VsSetWavelength() In earlier revisions, the error status light was cleared after a VsSetWavelength() call failed, so the user did not see the light turn red to alert that an error had occurred. This has been fixed in 1.35 so the error light remains lit, and an error code is returned. d) added range-check to VsDefinePalette() Previous revisions did not range-check the palette index number, and hard crashes could be produced if out-of-range values were supplied to this routine. Previous release 1.33b Release date: February 9, 2005 Known bugs: none Fixes/features changed from previous release: a) Fixed installer: programmers?guide (vsdrvr.pdf) installed when SDK is selected. Previous release 1.33a Release date: January 10th, 2005 Known bugs: i) SDK programmers?guide is not installed even if SDK is selected. Fixes/features added from previous release a) VsDrvr.dll fixed handling of COMx ports that do not support 460kb The autobaud sequence tries a variety of baud rates, some of which are not supported by RS-232 interfaces (but are supported on USB virtual COM ports). This was not handled properly, so if a call was made to VsOpen when no VariSpec was present, but a later call was made when a filter was present, the latter would fail. b) VsGui added check of which COMx ports are present on computer This program now filters its COMx list and only shows ports which actually exist; it used to show COM1 ?COM8 even if not all of these were present. c) VsGui added automatic filter detection on Configure dialog This checks all ports in turn, and reports the first detected filter. The search order is determined by the order in which the computer lists ports in the Registry. d) VsGui changed to recognize filters as present while initializing In prior revisions, VsGui would not report no filter found if a filter was present but still going through its power-up initialization. Now, a message box is posted to indicate that a filter was found, and the program checks whether initialization is complete, at 1 second intervals. When the filter is done initializing, the VsGui controls become active and report the filter information (serial number, wavelength range, etc). e) VsGui added filter status item to Configure dialog Adjacent the COMx combo box, there is now a text field that indicates filter status as 揘ot found? 揑nitializing? or 揜eady? This field is updated whenever the combo box selection is changed. Previous release 1.32 Release date: July 27th, 2004 Known bugs: COMx port described above as 1.33 fix item a) Fixes/features added from previous release a) VsGui added a sweep feature to enable cycling the filter The wavelength start, stop, and step are adjustable. Cycling can be done a fixed number of times or indefinitely. Previous release 1.30 Release date: June 23rd, 2004 Known bugs: none Fixes/features added from previous release a) New commands VsSetWaveplateAndWaves(), VsGetWaveplateAndWaves(), VsGetWaveplateLimits(), and VsGetWaveplateStages() were added for support of variable retarder models. b) New commands VsSetRetries() and VsSetLatencyMs() were added for control of serial port latency and automatic retry in case of error. c) New commands VsSetMode() and VsGetMode() were added for control of the VariSpec filter抯 triggering and sweep modes d) New command VsGetSettleMs() was added to learn optics settling time e) New commands VsIsDiagnostic() and VsIsEngagedInBeam() were added. These are reserved for CRI use and are not supported for use by end users. f) The command syntax and functionality of the VsSendCommand() function was changed - see description of this command for details g) The VsGui program was modified to add sweep function, and the associated files were added to the file manifest. The new functions are assigned higher ordinal numbers than the earlier commands, so the ordinal numbers assigned to routines in the earlier VsDrvr routines are preserved. This means one may use the new VsDrvr.dll file with applications that were developed and linked with the earlier release, without any need to recompile or relink the application. Of course, to use the new functions one must link the application code with the new .lib file containing these functions. Previous release: 1.20 Release date December 3rd, 2003 Known bugs: a) there is a conflict when one uses the implicit palette to set wavelengths, and also defines palette states explicitly using the VsDefinePalette() function. When the explicitly set palette state overwrites a palette state implicitly associated with a certain wavelength, that wavelength will not be accurately set when one issues the VsSetWavelength() command. This is fixed in release 1.30 Fixes/features added from previous release a) fixes bug with implicit palette in September 8 release b) incorporates implicit retry for command send/reply if error in transmission c) recognizes filters with serial numbers > 60000 (normally VariLC numbers) d) supports binary transfer of >127 bytes Previous release 1.11 Release date September 8, 2003 Known bugs a) implicit palette can fail to create palette entry, causing tuning error b) VsSendBinary() fails if 128 chars or more sent (signed char error) Fixes/features added from previous release a) included VsIsPresent() function omitted from function list of 1.10 release Previous release 1.10 Release date: August 28th, 2003 Known bugs: a) VsIsPresent function not included ?generates 搖nresolved external?at link-time Fixes/features added from previous release: b) added command VsEnableImplicitPalette() to code and documentation added command VsConnect() to code and documentation added command VsClose() to code and documentation added local variable to avoid unnecessary querying of diagnostic status documented that command VsConnect() will not be supported in future documented that command VsDisconnect() will not be supported in future documented that command VsIsConnected() will not be supported in future changed to Windows Installer from previous ZIP file added table summary of commands to this manual Previous release 1.00 Release date: November 5th, 2002 Known bugs: a) none Fixes/features added from previous release b) n/a ?initial releaseDescription This package provides a set of functions to control the VariSpec filter, which may be called from C or C++ programs. It incorporates all aspects of the filter communication, including low-level serial routines. With these routines, one can address the filter as a virtual object, with little need for detailed understanding of its behavior. This simplifies the programming task for those who want to integrate the VariSpec into larger software packages. File manifest All files are contained in a single installer file which includes the following: vsdrvr.h declaration file vsdrvr.lib library stub file vsdrvr.dll run-time library vsdrvr_r1p30.pdf (this file) release notes and programmer抯 guide {sample program using VsDrvr package} registryAccess.cpp registryAccess.h resource.h stdafx.h VsConfigDlg.cpp VsConfigfDlg.h VsGui.cpp VsGui.h VsGui.mak VsGui.rc VsGuiDlg.cpp VsGuiDlg.h VsSweep.cpp VsSweep.h Development cycle In order to use the DLL, one should take the following steps: a) Add #include 搗sdrvr.h?statements to all files that access the VariSpec software b) Add vsdrvr.lib to the list of modules searched by the linker c) Place a copy of vsdrvr.dll in either the folder that includes the executable code for the program being developed; or, preferably, in the windows system folder. Failures in step a) will lead to compiler errors; in step b) to linker errors; in step c) to a run-time error message that 揳 required .DLL file, vsdrvr.dll, was not found? VariSpec filter configuration The VariSpec filter communicates via ASCII commands sent over an RS-232 interface or USB. The RS232 can operate at 9600 or 19,200 baud, while the USB appears as a virtual COMx device. While it appears to be present at either 9600 baud or 115.2 kbaud , the actual data transmission occurs at 12 MBaud over the USB. Each command is terminated with an end-of-line terminator which can be either a carriage-return <c/r> or line feed <l/f>. For RS-232 models, the baud rate and terminator character are selected using DIP switches inside the VariSpec electronics module. Default settings are 9600 baud, and the <c/r> character (denoted 慭r?in the C language). For USB devices, the terminator is always <c/r>. For latest information, or to determine how to alter the settings from the factory defaults, consult the VariSpec manual. Timing and latency The VariSpec filter takes a finite time to process commands, which adds an additional delay to that imposed by simple communication delays. In general, the time to process a given command is short except for the following operations: ?filter initialization ?wavelength selection ?palette definition The first of these is quite lengthy (30 seconds or more) because it involves measurements and exercising of the liquid crystal optics. The latter two are much faster but still can take a significant amount of time (up to 300 ms) on the older RS-232 electronics due to the computations involved. On the newer, USB electronics, the latter two functions are completed in less than 5 ms. For this reason, the functions that handle these actions offer the option of waiting until the action is complete before returning (so-called synchronous operation); although they can be called in an asynchronous mode where the function returns as soon as all commands have been sent to the VariSpec, without waiting for them to run to completion. Another option is to use implicit palette tables. If this is enabled, by calling the VsEnableImplicitPalette() function, the driver will define the settings for a given wavelength once, then saves the results within the VariSpec for faster access next time that wavelength is used. Subsequent access times are essentially instantaneous, until either all of the 128 palette states are in use, or the palette is cleared via the VsClearPalette() command. The VsIsReady() function can be used to determine whether a filter is done processing all commands. Ideally, one should check VsIsReady() using a timer or the like to wait efficiently, so that the host PC is free to do other tasks while waiting for the VariSpec. The VariSpec always processes each command to completion before starting on the next command, and it has a 256 byte input buffer, so there is no problem issuing several commands at once; they will all be executed, and in the order given. This also indicates another way to coordinate one抯 program with the VariSpec filter: one can issue any of the VsGetxxx() functions, which query the filter. Since these do not return until the filter has responded, one may be sure that there are no pending commands when the VsGetxxx() function completes. The VsDrvr package provides for automatic re-try of commands up to 3 times, in the event that communications are garbled, and will wait up to 2 seconds for completion of serial commands. The number of retries can be set from 0 to 10, and the latency adjusted, if desired. However, there should be no need to do so. The hardware and software have been tested and observed to execute several million commands without a single communications error, so in practice the need for the retry protocol is very slight. Communication speed is not improved by reducing the latency, since commands proceed when all characters are received, and the latency time to time-out is only relevent when there is a communications lapse ?and as noted, these are very unlikely so the performance burden of retries should not be a practical consideration. Multiple Filters and Multiple Processes These routines only permit one VariSpec per process, and one process per VariSpec. So, these routines cannot control multiple filters at once from a single process; nor can several active processes seek to control the same filter at the same time. The VsDrvr package anticipates a future upgrade to enable control of multiple filters per process, so it makes use of an integer handle to identify which VariSpec is being controlled, even though (for now) only a single filter can be active. This handle is checked, and the correct handle must be used in all calls. Program flow and sequence Typical programs should use the following API calls (all applications, upon initiating link to the filter) ?call VsOpen() to establish communications link (required) ?call VsIsPresent() to confirm a filter is actually present ?call VsIsReady() in case filter is still doing power-up sequence <wait until no longer busy> ?call VsGetFilterIdentity() to learn wavelength limits and serial number if needed (if setting wavelengths via implicit palettes; recommended especially with older filters) ?call VsEnableImplicitPalettes() ? (to set wavelengths, either directly or via implicit palettes) ?call VsSetWavelength() and VsGetWavelength() to select and retrieve tuning (if setting wavelengths by means of palettes, and managing palettes explicity) ?call VsDefinePaletteEntry() and VsClearPalette() to define palette entries ?call VsSetPalette() and VsGetPalette() to select and retrieve palette state (all applications, when done with the filter) ?call VsClose() to release the communications link (required) Sample program Source code for a sample program, VsGui, is provided, which illustrates how to control a VariSpec filter using the VsDrvr package. All filter control code lives in the VsGuiDlg.cpp module, specifically in the Connect(), RequestToSetWavelength(), and VsWriteTimerProc() functions. The latter two use a system timer to decouple the GUI from the actual filter control, for more responsive feedback to the user. Such an approach is unnecessary if palettes are used, which is preferable when one wishes the best real-time performance. See the VariSpec manual for further information. Auxiliary commands Certain commands are normally only used at the factory when filters are being built and configured, or in specialized configurations. These appear after the normal command set in the listing below. Obsolescent commands The VsConnect(), VsIsConnected(), and VsDisconnect() functions are obsolescent. They are supported in this release, but will not necessarily exist in releases after 1.3x. As they are obsolescent, they are not recommended for new code. These function calls are not documented further in this manual.Summary of commands Normal Commands VsClearError(vsHnd) VsClearPalette(vsHnd) VsClearPendingCommands(vsHnd) VsClose(vsHnd) VsDefinePalette(vsHnd, palEntry, wl) VsEnableImplicitPalette(vsHnd, isEnabled) VsGetError(vsHnd, *pErr) VsGetFilterIdentity(vsHnd, *pVer, *pSerno, *pminWl, *pmaxWl) VsGetMode(vsHnd, int *pMode) VsGetPalette(vsHnd, *ppalEntryNo) VsGetSettleMs(vsHnd, *psettleMs) VsGetTemperature(vsHnd, *pTemperature) VsGetWavelength(vsHnd, *pwl) VsGetWavelengthAndWaves(vsHnd, double *pWl, double *pwaves) VsGetWaveplateLimits(vsHnd, double *pminWaves, double *pmaxWaves) VsGetWaveplateStages(vsHnd, int *pnStages) VsIsPresent(vsHnd) VsIsReady(vsHnd) VsOpen(*pvsHnd, portName, *pErrorCode) VsSetLatencyMs(vsHnd, nLatencyMs) VsSetMode(vsHnd, mode) VsSetPalette(vsHnd, palEntry) VsSetRetries(vsHnd, nRetries) VsSetWavelength(vsHnd, wl, confirm) VsSetWavelengthAndWaves(vsHnd, wl, waveplateVector) Auxiliary commands VsGetAllDrive(vsHnd, *pStages, drive[]) VsGetNstages(vsHnd, *pStages) VsGetPendingReply(vsHnd, reply, nChars, *pQuit, firstMs, subsequentMs) VsGetReply(vsHnd, reply, nChars, waitMs) VsIsDiagnostic(vsHnd) VsIsEngagedInBeam(vsHnd) VsSendBinary(vsHnd, bin[], nChars, clearEcho) VsSendCommand(vsHnd, cmd, sendEolChar) VsSetStageDrive(vsHnd, stage, drive) VsThermistorCounts(vsHnd, *pCounts) Alphabetical list of function calls Syntax Throughout this manual, the following conventions are used: VSDRVR_API Int32 VsOpen( VS_HANDLE *vsHnd, LPCSTR port, Int32 *pErrorCode ) Bold text is used for function names Italics indicate variables whose names (or values) are supplied by the user in their code Name-mangling The declaration file vsdrvr.h includes statements that render the API names accurately in a C++ environment, i.e. free of the name-mangling decoration suffix that is normally added by C++ compilers. Thus the functions can be called freely from either C or C++ programs, using the names exactly as shown in this manual or in the VsDrvr.h file. Call and argument declarations The call protocol type, VSDRVR_API, is declared in vsdrvr.h, as are the types Int32 and VS_HANDLE. Errors All functions return an Int32 status value, which is TRUE if the routine completed successfully and FALSE if there was an error. If there is an error in the VsOpen() function, the error is returned in *pErrorCode. If there is an error in communicating with a filter after a successful VsOpen(), one should use the VsGetError() function to obtain the specific error code involved. This function returns VSD_ERR_NOERROR if there is no error pending. Main and auxiliary functions The next section provides a description of the main functions, in alphabetic order; followed by the auxiliary functions, also in alphabetical order. In normal use, one will probably have no need for the auxiliary functions, but this list is provided for completeness. VSDRVR_API Int32 VsClearError( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Purpose: this function clears any pending error on the VariSpec. This resets the error LED on the filter, and sets the pending error to VS_ERR_NOERROR. Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsClearPalette( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Function: clears all elements of the current filter palette and renders the current palette element undefined. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsClearPendingCommands( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Function: clears all pending commands including any presently in-process Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsClose( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen(). May also be NULL, in which case all VariSpec filters are disconnected. Function: Disconnects the filter. Returns: TRUE if successful, FALSE otherwise Notes: No other functions will work until VsOpen() is called to re-establish communications with the filter. VSDRVR_API Int32 VsDefinePalette( VS_HANDLE vsHnd, Int32 palEntry, double wl) Arguments: vsHnd handle value returned by VsOpen() palEntry palette entry to be defined, in the range [0, 127] wl wavelength associated with this palette entry Function: creates a palette entry for the entry and wavelength specified. This palette entry can then be accessed using VsSetPalette() and VsGetPalette() functions. Returns: TRUE if successful, FALSE otherwise Notes: palettes provide a fast way to define filter settings for wavelengths that are to be repeatedly accessed. The calculations are performed once, at the time the palette element is defined, and the results are saved in a palette table to tune to that wavelength without repeating the underlying calculations. And, one may cycle through the palette table, once defined, by means of TTL a trigger signal to the filter electronics. For more information about using palettes, consult the VariSpec user抯 manual. VSDRVR_API Int32 VsEnableImplicitPalette( VS_HANDLE vsHnd, BOOL imlEnabled) Arguments: vsHnd handle value returned by VsOpen() implEnabled selects whether to use implicit palette definition Function: enables or disables implicit palette generation when wavelengths are defined using the VsSetWavelength function. If enabled, a new palette entry is created whenever a new wavelength is accessed, and the VsSetWavelength function will use this palette entry whenever that wavelength is accessed again, until the palette is cleared. The result is improved tuning speed; however, it means that the palette contents are altered dynamically, which can be a problem if one relies upon the palette contents remaining fixed. Clearing the palette with VsClearPalette() will clear all implicit palette entries as well as explicitly defined palette entries. This is useful if one knows that wavelengths used previously will not be used again, or that a new set of wavelengths is about to be defined and one wishes to make sure there is sufficient room in the palette. Returns: TRUE if successful, FALSE otherwise Notes: By default, the implicit palette is enabled for VariSpec filters that have RS-232 interface, and is disabled for newer VariSpec filters that have the USB interface. This is because the newer filters perform the filter tuning calculations fast enough that no performance improvement is obtained by using the implicit palette to set wavelength. For more information about using palettes, consult the VariSpec user抯 manual. VSDRVR_API Int32 VsGetError( VS_HANDLE vsHnd, Int32 *pErr) Arguments: vsHnd handle value returned by VsOpen() pErr pointer to the int that will receive the most recent error code Purpose: this function clears any pending error on the VariSpec. This resets the error LED on the filter, and sets the pending error to VS_ERR_NOERROR. Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsGetFilterIdentity( VS_HANDLE vsHnd, Int32 *pVer, Int32 *pSerno, double *pminWl, double *pmaxWl ) Arguments: vsHnd handle value returned by VsOpen() pVer pointer to variable that receives the filter firmware version pSerno pointer to variable that receives the filter serial number pminWl pointer to variable that receives the filter抯 minimum wavelength pmaxWl pointer to variable that receives the filter抯 maximum wavelength Purpose: this function reads the filter抯 information using the VariSpec 慥?command, and puts it to the call variables. Any one of the pointers may be NULL, in which case that piece of information is not returned. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsGetMode( VS_HANDLE vsHnd, Int32 *pMode ) Arguments: vsHnd handle value returned by VsOpen() pMode pointer to variable that receives the filter mode Purpose: this function enables one to read the filter抯 present mode. The mode describes how the filter responds to hardware triggers, and is described in the filter manual. If the pointer *pMode is NULL, no information is returned. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsGetPalette( VS_HANDLE vsHnd, Int32 *ppalEntry ) Arguments: vsHnd handle value returned by VsOpen() ppalEntry pointer to int that receives the 0-based palette entry number. This pointer may not be NULL. Purpose: this function determines what palette entry is currently active and returns it to *ppalEntry. If the present palette entry is undefined, it sets *ppalEntry to ? and returns a successful status code. Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsGetSettleMs( VS_HANDLE vsHnd, Int32 *pSettleMs ) Arguments: vsHnd handle value returned by VsOpen() pSettleMs pointer to variable that receives the filter settling time Purpose: this function returns the filter抯 settling time, in milliseconds. This is useful for establishing overall system timing. The settling time is defined as beginning at the moment that the electronics have processed the request to change wavelength, as determined by VsIsReady() or equivalent. At that moment, the new set of drive signals are applied to the optics, and the optics will settle in *psettleMs milliseconds. The settling time is defined as a 95% settling time, meaning the filter has settled to 95% of its ultimate transmission value at the new wavelength being tuned to. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsGetTemperature( VS_HANDLE vsHnd, double *pTemperature ) Arguments: vsHnd handle value returned by VsOpen() pTemperature pointer to double that will receive the filter temperature, in C This pointer may not be NULL Purpose: this function determines the filter temperature using the VariSpec 慪?command, and puts the result to *pTemperature. Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsGetWavelength( VS_HANDLE vsHnd, double *pwl ) Arguments: vsHnd handle value returned by VsOpen() pwl pointer to double that will receive the filter wavelength, in nm This pointer may not be NULL Purpose: this function determines the current filter wavelength and returns it to *pwl. If the present wavelength is undefined, it sets *pwl to ? and returns a successful status code. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsGetWavelengthAndWaves( VS_HANDLE vsHnd, double *pwl, double *pwaves ) Arguments: vsHnd handle value returned by VsOpen() pwl pointer to double that will receive the filter wavelength, in nm. This pointer may not be NULL pwaves pointer to double array that will receive one or more waveplate settings. The actual number of settings may be determined by VsGetWaveplateStages(). Purpose: this function determines the current filter wavelength and returns it to *pwl. If the present wavelength is undefined, it sets *pwl to ? and returns a successful status code. If the present wavelength is defined, it also returns the waves of retardance at each of the polarization analysis waveplates in the optics, in the pwaves[] array. Returns: TRUE if successful, FALSE otherwise Notes: See the description of the VsGetWaveplateStages() command for more detail on what stages are considered waveplates. VSDRVR_API Int32 VsGetWaveplateLimits( VS_HANDLE vsHnd, double *pminWaves, double *pmaxWaves ) Arguments: vsHnd handle value returned by VsOpen() pminWaves pointer to double array that will receive the minimum retardances possible at each of the waveplate stages in the filter optics. pmaxWaves pointer to double array that will receive the maximum retardances possible at each of the waveplate stages in the filter optics Purpose: this function determines the range of retardances that are possible at each waveplate stage, in waves, at the present wavelength setting. Note that the retardance range is itself a function of wavelength, so the results will vary as the wavelength is changed. Returns: TRUE if successful, FALSE otherwise Notes: See the description of the VsGetWaveplateStages command for more detail on what stages are considered waveplates. VSDRVR_API Int32 VsGetWaveplateStages( VS_HANDLE vsHnd, Int32 *pnwpStages ) Arguments: vsHnd handle value returned by VsOpen() pnwpStages pointer to Int32 that will receive the number of waveplate stages in the filter optics. This pointer may not be NULL Purpose: this function determines how many polarization analysis stages are present in the optics and returns this number. Note that although all VariSpec filters operate by means of variable retarder element, optical stages that perform wavelength tuning rather than polarization analysis are not treated as waveplate stages. For example, most VariSpec filters do not include any polarization analysis stages and thus report no waveplates. VsGetWaveplateStages will return a value of 2 for conventional PolScope optics. In contrast, VsGetNstages() reports the total number of stages in a filter, including stages that perform polarization analysis and stages that perform wavelength tuning. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsIsPresent( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Function: determines whether a filter is actually present and responding. This is done using the status-check character ??as described in the VariSpec manual. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsIsReady( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Function: determines whether the filter is done processing all commands, and is ready to receive new commands. Returns: TRUE if successful, FALSE otherwise Notes: this is useful when sending commands such as VsSetWavelength(), VsInitialize(), VsExercise(), and VsDefinePaletteEntry() in asynchronous mode. These commands take a prolonged time, and running them synchronously ties up the processor waiting. Alternatively, one can create a loop that uses CreateWaitableTimer(), SetWaitableTimer(), and WaitForSingleObject() to call VsIsReady() at intervals, checking whether the filter is ready. This approach, though more work for the programmer, leaves most of the processor capacity free for other tasks such as GUI update and the like. VSDRVR_API Int32 VsOpen (VS_HANDLE *pvsHnd, LPCSTR port, Int32 *pErrorCode ) Arguments: pvsHnd pointer to handle. This pointer may not be NULL. port port name, such as 揅OM1? pErrorCode pointer to Int32 to receive an error code if VsOpen() fails Purpose: establishes a connection to the VariSpec using the port specified, and automatically determines the baud rate and end-of-line character for subsequent communications. It also retrieves the filter抯 serial number and wavelength range, to confirm that it is a VariSpec and not some other similar device. However, these are retrieved purely as an integrity check, and the values are not returned to the calling application. See VsGetFilterInfo() to access this information. If the device responds as a VariSpec does when it is not ready (i.e. still initializing), VsOpen() fails and returns the error code VSD_ERR_BUSY. However, one may not be sure that the device is a VariSpec until VsOpen() completes successfully The error codes returned by this function are listed in VsDrvr.h. When VsOpen() runs successfully, *pErrorCode is set to VSD_ERR_NOERROR. The handle associated with this filter is set by VsOpen() to a nonzero handle value if successful, or to NULL if no connection is established. The port may refer to COM1 through COM8. Return: TRUE if successful, FALSE otherwise Notes: Until this function is called, none of the other functions will work. VSDRVR_API Int32 VsSetLatency( VS_HANDLE vsHnd, Int32 latencyMs ) Arguments: vsHnd handle value returned by VsOpen() latencyMs the serial port latency, in ms, in the range [1, 5000] Purpose: this function sets the latency time for USB or RS-232 commands to the value given by latencyMs. Commands that do not conclude in this time are considered to have timed-out. Returns: TRUE if successful, FALSE otherwise Notes: increasing the latency time does not increase the time for commands to complete, nor does it insert any delays in normal processing. It merely defines the window for maximum transmission time, beyond which time an error is reported. VSDRVR_API Int32 VsSetPalette( VS_HANDLE vsHnd, Int32 palEntry ) Arguments: vsHnd handle value returned by VsOpen() palEntry the palette entry to be set, in the range [0, 127] Purpose: this function sets the filter to the palette entry specified by palEntry Returns: TRUE if successful, FALSE otherwise Notes: palettes are a good way to control the filter in applications where it will be cycled repeatedly to various, fixed wavelength settings. Palettes calculate the filter settings once, and save the results for rapid access later, rather than calculating them each time, as occurs when one sets the wavelength directly with VsSetWavelength(). See the VariSpec manual for more information on palettes.VSDRVR_API Int32 VsSetRetries( VS_HANDLE vsHnd, Int32 nRetries ) Arguments: vsHnd handle value returned by VsOpen() nRetries the number serial communications retries, in the range [0, 10] Purpose: The VsDrvr software automatically detects errors in communication and re-sends if an error is detected. This function sets the number of times to retry sending any single command, before reporting a communications failure. The default is 3, which should be adequate, and one should rarely need to change this, if ever. The primary purpose of this function is to enable setting the number of retries to zero, to force single-error events to cause detectable errors (as they would normally be fixed automatically via the retry mechanism) Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsSetWavelength( VS_HANDLE vsHnd, double wl, BOOL confirm ) Arguments: vsHnd handle value returned by VsOpen() wl wavelength to tune to, in nm confirm logical flag, indicating whether to confirm actual wavelength value Purpose: this function sets the filter wavelength to the value in wl. If confirm is TRUE, it waits for the filter to complete the command, and then reads back the actual wavelength to confirm it was implemented successfully. Note that the only time there can be a disparity is when the wavelength requested by wl lies outside the legal range for that filter, or if the wavelength is specified to a finer resolution than the filter recognizes (normally, 0.01 nm). Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsGetAllDrive( VS_HANDLE vsHnd, Int32 *pStages, Int32 drive[] ) Arguments: vsHnd handle value returned by VsOpen() pStages pointer to int that will receive the number of stages in the filter drive[] int array to receive the filter drive levels. Purpose: this function reports the number of filter stages in *pStages. If this argument is NULL, it is ignored. The function returns the actual drive level at each stage, in counts, in drive[] , which must not be NULL. Returns: TRUE if successful, FALSE otherwise Notes: The array drive[] must be large enough to receive all the drive levels ?if the exact number of stages is not known, call VsGetNstages() first, or allocate enough array elements (12) to accommodate the largest filter design.VSDRVR_API Int32 VsGetNstages( VS_HANDLE vsHnd, Int32 *pStages ) Arguments: vsHnd handle value returned by VsOpen() pStages pointer to int that will receive the number of stages in the filter Purpose: this function determines the number of optical stages in the filter and returns it in *pStages, which may not be NULL. Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsGetPendingReply( VS_HANDLE vsHnd, LPSTR reply, Int32 nChars, Int32 *pQuit, Int32 firstMs, Int32 subsequentMs ) Arguments: vsHnd handle value returned by VsOpen() reply pointer to buffer that is to receive the reply nChars number of characters to receive pQuit pointer to flag to control this function ?see Notes below firstMs maximum time to wait, in ms, for first character of reply subsequentMs maximum time to wait, in ms, for each subsequent character Purpose: this function is used to exploit some of the less-common aspects of the filter, and it is likely that most programs will require its use. It receives a reply from the filter that may not arrive for a long time. The routine waits up to firstMs for the first character to arrive. Subsequent characters must arrive within subsequentMs of one another. Typically, this routine is called with a high value for firstMs and a lower value for subsequentMs. Returns: TRUE if successful, FALSE otherwise Notes: pQuit can be used to cancel this function while it is waiting for the reply, if that is desired, such as to respond to a user cancellation request. To use this feature, pQuit must be non-NULL and *pQuit must be FALSE at the time VsGetPendingReply() is called. VsGetPendingReply() checks this address periodically, and if it discovers that *pQuit is TRUE, it will cancel and return immediately.VSDRVR_API Int32 VsGetReply( VS_HANDLE vsHnd, LPSTR reply, Int32 nChars, Int32 waitMs ) Arguments: vsHnd handle value returned by VsOpen() reply pointer to buffer that will receive the filter reply nChars the number of characters sought waitMs the maximum time, in ms, to wait for the reply Purpose: this function is used to exploit those filter commands that are not directly provided by other functions, and most programmers will not need to use it. If the reply is not received in the time indicated by waitMs, or if less than nChars are received, the function returns with an unsuccessful status code. Returns: TRUE if successful, FALSE otherwise Notes: noneVSDRVR_API Int32 VsIsDiagnostic( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Function: determines whether the filter is in the diagnostic mode that is used at the factory for setup and calibration. This command is reserved for CRI use only. Returns: TRUE if diagnostic, FALSE otherwise. VSDRVR_API Int32 VsIsEngagedInBeam( VS_HANDLE vsHnd ) Arguments: vsHnd handle value returned by VsOpen() Function: determines whether the filter is engaged in the beam, when configured into certain CRI systems. This function is reserved for CRI use only Returns: TRUE if engaged in the beam, FALSE otherwise VSDRVR_API Int32 VsSendBinary( VS_HANDLE vsHnd, char *bin, Int32 nChars, BOOL clearEcho ) Arguments: vsHnd handle value returned by VsOpen() bin pointer a buffer that contains binary data to be sent to the filter nChars the number of binary characters to be sent clearEcho flag indicating whether to clear echo characters from the queue Purpose: this routine sends binary blocks of data to the filter. This is only necessary when programming calibration data to the filter, and it is not anticipated that this function will be necessary in any normal use. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsSendCommand( VS_HANDLE vsHnd, LPCSTR cmd, BOOL sendEolChar) Arguments: vsHnd handle value returned by VsOpen() cmd pointer to the command to be sent to the filter sendEolChar flag indicating whether to append the end-of-line character or not Purpose: this function sends the command in cmd to the filter, and appends an end-of-line terminator (or not) based on sendEolChar. It automatically retrieves and discards the character echo of this command by the VariSpec. It does not automatically retrieve the reply, if any, from the VariSpec. Returns: TRUE if successful, FALSE otherwise Notes: The parameter sendEolChar should normally be true in all cases, unless one is sending individual character commands such as the ??or 慇?commands described in the VariSpec user抯 manual.VSDRVR_API Int32 VsSetStageDrive( VS_HANDLE vsHnd, Int32 stage, Int32 drive ) Arguments: vsHnd handle value returned by VsOpen() stage stage number whose drive level is to be adjusted drive drive level, in counts, for that stage Purpose: this function provides a way to manually adjust the drive levels at each of the filter抯 optical stages. It is normally used only during manufacture, and is not a function that most software programs will have any reason to use. Returns: TRUE if successful, FALSE otherwise Notes: none VSDRVR_API Int32 VsThermistorCounts( VS_HANDLE vsHnd, Int32 *pCounts ) Arguments: vsHnd handle value returned by VsOpen() pCounts pointer to int that will receive the thermistor signal, in counts Purpose: this function provides a way to determine the signal level, in counts, at the thermistor. It is normally used only during manufacture, and is not a function that most software programs will have any reason to use. Returns: TRUE if successful, FALSE otherwise Notes: none

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值