Friday, August 29, 2008

Apple iPhone 3G - GPS



The Apple iPhone 3G's GPS uses Infineon PMB 2525 Hammerhead II chip. The chip integrates a A-GPS baseband processor and a low-noise GPS RF front end. It is accurate in 2m at steady state and the Time-to-First Fix (mobile based) is 1 second@5m. High sensitivity, -160dBm for indoor and deep urban operation (cold start, -130 dBm).

Hammerhead II uses serial communication interfaces (UART, SPI, I2C) with speed as low as 38,400 bps. Both A-GPS control software and LBS (Location based services) application executed on host CPU. No additional TCXO required, uses host 32 kHz standby clock & reference clock (10 to 40 MHz)



Thursday, August 21, 2008

溝通

《中國人的溝通藝術 》一 陳耀南
知己知彼
合情合理
有質有文
不亢不卑

知彼之非,知己之是
動之以情,說之以理
以古喻今,引人入勝
强者不驕,弱者不扁


Monday, July 28, 2008

Enterprise JavaBean

JavaBeans are simple classes that follow a particular coding style (setter and getter methods). Enterprise JavaBeans (EJBs), must operate within the context of a container, are server-side components built to deal with the complexities of distribution. The EJB framework (container and server) allows user to focus on writing business logic code within the EJBs. The EJB server holds containers and provides generic EJB server services required by all containers, including transaction monitoring services, generic security services and administration service. Although the precise demarcation of responsibilities between the server and its containers is not defined by the EJB specification, the container to EJB interface is part of the specification. There are four basic elements that make up an EJB component:
  1. Business logic interface (also known as the object interface)
  2. Life cycle interface (also known as the home interface)
  3. EJB component class
  4. XML deployment descriptor
(since EJB 2.0, local life cycle interface and local business logic interface were introduced).

For every EJB component you must implement certain methods. These are called callback or life cycle methods. For example, a method is called just after a component instance is created, or just before it is destroyed, or just prior to its passivation (a form of serialization) or reactivation.

Although users are responsible for writing the life cycle and business logic, their implementation classes are generated automatically prior to deployment by container tools. XML files are written to describe the required distribution properties for EJBs. With an appropriate XML deployment descriptor editor, we are able to display and alter the deployment properties. Container tools read these XML deployment descriptor files and generate distribution code. Among the various properties there are some worth to mention:
Security - logical security role names are used. Allows user to say who is allowed to invoke which methods.

Transaction scope, persistence requirements, composition, and the type of EJB - e.g. indicate to the container the kind of EJB you have developed and chain of methods used in a transaction. If a persistent EJB, the parts of the EJB that should be synchronized with a table in an underlying RDBMS.

There are three kinds of EJBs:
Session EJBs - used to encapsulate business logic. Stateful session and stateless session EJBs are two variants of session beans. Their data is not synchronized automatically with an underlying persistent store by the container.

Entity EJBs - used to encapsulate business logic. Unlike the session EJBs, their data is synchronized. This synchronization can either be at the control of the container entirely (container-managed persistence), or can be partially the responsibility of the EJB code (bean-managed persistence).

Message driven EJBs - this is new to EJB 2.0. While session and entity EJBs support synchronous communication, message driven EJBs support asynchronous communication. It read message objects off an associated destination (a queue or topic).

Wednesday, July 23, 2008

Spring

The front-ends built using WebWork or Struts (Struts2) can be integrated with a Spring-based middle-tier. By using Spring's declarative transaction management features the web application is fully transactional, just as it would be when using container managed transactions as provided by Enterprise JavaBeans. The only thing you need to do is wire up your business logic using an ApplicationContext and integrate your web layer using a WebApplicationContext.

Model-View-Controller

The Struts framework was created by Craig R. McClanahan and donated to Apache Software Foundation (ASF) in 2000. A framework provides generic, cooperative components that your application extends to deliver a particular set of functions. So it is also referred as an "upside-down" library. The Struts framework provides three key components for the implementation of the MVC structure.
  • A "request" handler provided by the application developer that is mapped to a standard URI.
  • A "response" handler that transfers control to another resource which completes the response.
  • A tag library that helps developers create interactive form-based applications with server pages.
Others
Cocoon project founded by Stefano Mazzocchi in January 1999 is an open source project the ASF. Cocoon leverages XML, XSLT, and Simple API for XML (SAX) to help create, deploy, and maintain XML server applications.

Velocity is a Jakarta project like Struts. It is a Java-based template engine that can generate SQL, PostScript, and XML form templates.

JavaServer Faces (JSF) project is to provide a standard set of JSP Tags and classes to aid in the management of complicated HTML forms, event handling, and presentation state.

Jakarta Turbine is a servlet-based framework. A large set of components is included with the framework, including those for using relational databases, security, and scheduling, etc.

WebWork is a web application framework that uses the Pull Hierarchical Model View Controller (HMVC) design. With a standard MVC design, changes made to the model are pushed to the view. In the case of WebWork, the views pull the data when they need it.

Spring is a J2EE application framework developed by Rod Johnson. Spring is not just a web framework. It can integrated with other disparate components.

Apache Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts2.

Controller - MVC
The controller portion of the web tier MVC design generally is a Java Servlet. The Front Controller pattern, which is part of the J2EE Design Patterns, describes how a web tier controller should be implemented. Code that would normally need to put in every JSP page can be put in the controller servlet, which processes all the request.

In the Struts framework, the controller responsibilities are implemented by several different components, one of which is an instance of the org.apache.struts.action.ActionServlet class. The ActionServlet extends the javax.servlet.http.HttpServlet class and its responsible for packaging and routing HTTP traffic to the appropriate handler in the framework.

An org.apache.struts.action.Action class in the Struts framework is an extension of the controller component. It decouples the client request from the business model. This allows for more than a one-to-one mapping between the user request and an Action. The Action class can perform other functions, such as authorization, logging, and session validation, before invoking the business operation.
Note: In Struts 2, POJO Actions - use any class as an Action class - even the interface is optional. We can inject dependencies into Actions using Spring without glue code or red tap.

Model - MVC
In an enterprise application, the model portion of MVC pattern will be Enterprise JavaBeans. The Struts framework does not have a great deal of support in the way of model components. This is better left for EJB, CORBA, or some other type of component framework.

The EJB 2.0 made performance improvements through the use of local interfaces. However, due to the overhead of making remote calls, there still can be a significant performance impact if the web tier attempt to use entity beans directly as the model portion of the application. Therefore, JavaBeans are returned from session beans and used within the web tier. These JavaBeans are referred to as data transfer object (DTO) and are used within the views to build the dynamic contents. In a distributed application, usage of DTOs reduces the network bandwidth and improve response.

In Struts, application data is encapsulated in Java objects. User input is used to populate an action form upon form submission, business methods accept transfer objects as arguments, and custom tags are designed to manipulate JavaBeans. You can keep business logic out of the Action classes to protect against change. The Action is free to put the object in the request or session and then forward it to a JSP, where the data can be extracted and presented to the user.

View - MVC
The views within the web tier MVC pattern typically consist of HTML and JSP pages. The view components employed in a Struts application are:
  • HTML
  • DTO
  • Struts ActionForms
  • JSP
  • Custom tags
  • Java resource bundles
The Struts framework (ActionForm objects) automatically collects the input from the request and passes the data to an Action using a form bean. To keep the presentation layer decoupled from the business layer, DTO was created by using the data from the ActionForm.
Note: In Struts 2, no more ActionForms. POJO forms - use any JavaBean to capture form input or put properties directly on an Action class. Use both binary and String properties!

JSP pages make up the majority of what has to be built for the Struts view components. Combined with custom tag libraries and HTML, JSP makes it easy to provide a set of views for an application.

The Struts framework provides six core tag libraries. We may extend the Struts tags or create our own custom tags. The custom tag libraries that are included with the framework are: HTML, Bean, Logic, Template, Nested, and Tiles tag libraries.

Note: The Struts 2 adds interactivity and flexibility with AJAX tags that look and feel just like standard Struts tags.

Monday, July 21, 2008

Strike Pegger

There is a Wall Street axiom that says "90% of all the options that are bought and held to expiration will expire worthless". The Strike Pegger computes the stock price where the sum of the amount to be paid by all call and put writers is the smallest. This computed price changes as the ratio of open interest for calls and puts changes.

The Max Pain effect is the tendency for a stock’s price to gravitate towards this number as we approach the expiration date. Options officially expire the day after the third Friday of the month. Apple (AAPL) July 2008 options expired on July 18 after the closing bell. The calculated Max Pain value for AAPL is 160.



Update: AAPL closed at 165.15 on July 18.

Note: The strike pegger is more accurate for most major indexes and stocks which have large option volume, relatively low float, and have not experienced a significant and abrupt price move. The Volatility Skew, the Put/Call Ratio, and the Strike Peg should all be evaluated. Correct interpretation of the Volatility Skew is most valuable, since it effects the accuracy of the Put/Call Ratio and the Strike Peg.

Ref: http://www.optionistics.com/i/strike_pegger

Tuesday, June 3, 2008

Plasma Effects on Polymers

The interactions between polymers and plasmas and UV radiation taking places in both vacuum coating processes and hardening of sol-gels (wet-chemical coating). Reactions on polymer surfaces can be caused by high-energy electrons, ions, and neutrals, as well as by electromagnetic radiation in the deep ultra-violet (VUV, wavelength < 180 nm). The treatments cause chain scission, ablation, cross-linking, and oxidation to a depth of 5-50 nm. Important plasma parameters for a treatment are the plasma excitation frequency, the gas pressure and composition, and the treatment time.

Plasma treatments are able to introduce polar oxygen groups even if carried out in inert gases. The polymer radicals formed during the treatments are long-lived and typically react with water or oxygen from the gas background. An adhesion improvement by plasma treatments has been attributed variously to improved wettability, to surface cross-linking, or to interfacial diffusion.

The degradation of polymers caused by environmental UV radiation is the cause of yellowing of many polymer materials. In particular, polycarbonates are prone to yellowing, whereas polyacrylates are more stable to environmental radiation. The discoloration is due to photo-oxidation reactions.
Polycarbonate


Electromagnetic radiation at wavelength below 200 nm has enough energy to break polymer bond, and the photon energy of wavelength below 120 nm is sufficient to ionize most organic materials. Important for coating processes is VUV radiation at wavelength below 180 nm. Argon in a plasma shows primarily VUV emissions below 160 nm due to energy transfer from excited-state argon metastables to hydrogen from water and organic materials. Studies show that cross-linking reactions during low-pressure plasma treatments are mainly initiated by VUV radiation. Cross-linking reactions dominate on polymers containing at least one hydrogen atom bonded to adjoining carbon atoms. This is find in the thermoplastics like polyethylene, polypropylene, polystyrene, and polyamide. For PMMA and other acrylics, scission of bonds and the formation of weakly bonded layers is found after different plasma treatments.
Acrylate polymer - PMMA


Antireflective (AR) coating design for plastics
Special requirements have to be taken into account in the design of AR coatings for plastics:
  • The layer materials have to be selected in order to achieve radiation protection of interfaces or of the bulk polymer dependent on the polymer substrate type.
  • The layer materials and thicknesses have to be adjusted considering the mechanical and thermal film stresses and the total heat development during the deposition process.
  • Designs should be suitable for integrating additional functions like improved scratch resistance, barrier function, antistatic function, or hydrophobic properties.
  • Sometimes changed optical properties of interfacial zones due to plasma treatments have to be taken into account for design calculations.

Plastic eyeglasses have to be pass rigorous environmental and abrasion tests. AR layers which is preferred in quarter-half-quarter design, and hydrophobic top coatings are arranged on top of hard coatings several micrometers thick. Usually, the hard coatings are lacquers based on silanols, or organic-modified silica layers applied by vacuum deposition processes. These hard coated surfaces act as the substrate so that the vacuum deposition of the AR coating does not have to be done on the more sensitive polymer itself. AR coatings produced using wet-chemical processes comprise mainly single-layer and two-layer systems.