tailieunhanh - The Automated Factory Scenario
Các Kịch bản tự động Nhà máy Giả sử bạn đang viết các hệ thống điều khiển cho một nhà máy tự động. Nhà máy có chứa một số lượng lớn các máy khác nhau, mỗi nhiệm vụ thực hiện khác biệt trong sản xuất của các bài viết được sản xuất bởi các-nhà máy tạo hình và tấm kim loại folding | The Automated Factory Scenario Suppose you are writing the control systems for an automated factory. The factory contains a large number of different machines each performing distinct tasks in the production of the articles manufactured by the factory shaping and folding metal sheets welding sheets together painting sheets and so on. Each machine was built and installed by a specialist vendor. The machines are all computer-controlled and each vendor has provided a set of APIs that you can use to control their machine. Your task is to integrate the different systems used by the machines into a single control program. One aspect that you have decided to concentrate on is to provide a means of shutting all the machines down quickly if needed NOTE The term API means Application Programming Interface. It is a method or set of methods exposed by a piece of software allowing you to control that software. You can think of the .NET Framework as a set of APIs as it provides methods allowing you to control the .NET common language runtime and the Microsoft Windows operating system. Each machine has its own unique computer-controlled process and API for shutting down safely. These are summarized below StopFolding Folding and shaping machine FinishWelding Welding machine PaintOff Painting machine Implementing the Factory Without Using Delegates A simple approach to implementing the shutdown functionality in the control program is shown below class Controller . public void ShutDown . Fields representing the different machines private FoldingMachine folder private WeldingMachine welder private PaintingMachine painter Although this approach works it is not very extensible or flexible. If the factory buys a new machine you must modify this code the Controller class and the machines are tightly coupled. Implementing the Factory by Using a Delegate However although the names of each method are different they all have the same .
đang nạp các trang xem trước