Upgrade to Pro — share decks privately, control downloads, hide ads and more …

3 VIPLE as a Workflow Language

3 VIPLE as a Workflow Language

2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班

shadowkael

July 19, 2016
Tweet

More Decks by shadowkael

Other Decks in Education

Transcript

  1. 1 物联网和机器人导论 VIPLE工作流编程 Introduction to IoT and Robotics, based on

    Visual Programming Experiments Yinong Chen Arizona State University, U.S.A. 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Lectures of the Course 2 http://neptune.fulton.ad.asu.edu/VIPLE/ Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 3 Lecture Outline Service-Oriented Programming 3 Parallel Programming 4 General-Purpose Programming 2 Introduction to VIPLE 1 Event-Driven Programming 5 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Workflow and Visual Programming  Workflow defines a system through  Architecture: Service oriented using orchestration or chorography style  Interface: Partners and roles between the components  Behaviors: Activities and execution orders of activities  Workflow is not necessarily visual  BPEL is a workflow language, and it is text-based (XML)  Workflow can be easily visualized and is often defined visually  Oracle SOA Suite and JDeveloper visualize BPEL 4 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Application of Visual Programming Languages  Most workflow languages today are visualized;  Simplified workflow languages are used in education: 5  MIT: Scratch - Visual Game Programming  University of Virginia and Carnegie Mellon: Alice Visual Game Programming  MIT App Inventor: Phone App Visual Programming  Lego NXT & EV3 – Visual Robotics Application Development  Microsoft Robotics Developer Studio Visual Programming Language (MRDS VPL)  ASU VIPLE: Visual IoT/Robotics Programming Language Environment Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 VIPLE Programming Paradigms VIPLE Features  General-purpose control flow programming  Service-oriented computing, supporting RESTful and WSDL  Parallel / multithreading programming, with underlying threads safety  Event-driven programming, with built-in and custom events  Workflow and visual programming  IoT and Robotics programming 6
  2. 2 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Basic Activities of

    VIPLE  Variable: supports basic types (Int32, Double, String, Boolean, etc.).  Calculate: Calculate the value of any C# expression.  Data: Introducing the constant values in regular programming language There are dozen of basic activities, and many composite services in VIPLE Repository 7 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Basic Activities (cont.)  Join: proceeds when all threads arrive; It can be used for waiting parallel data or threads.  Merge: proceeds when one of the data or threads arrives. It can be used for waiting alternative data, e.g., creating the returning point of a loop;  If: same as regular programming language construct; It allows multiple conditions.  Switch: same as regular programming language construct;  While: start a loop;  Break exits a loop, and  End While returns to While 8 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Basic Activities (cont.) Basic Activity Activity Activity Service  Construct a composite activity (block or module) Application  Basic Activity and Activity are building blocks of a diagram or flowchart.  Activity can be wrapped into a service  Data transfer between  activities are through global variables and parameter passing  services don’t support global 9 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 VIPLE Services 10 General-purpose and event services Generic robotic services Vendor-specific robotic services Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 VIPLE Programming: Output 11 General-purpose and event services Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 VIPLE Programming: Input 12
  3. 3 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 VIPLE Programming: Variable

    and Loop 13 Use state. to access variable Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Activity and Parameter Passing 14 Add a parameter for the activity Use instance. to access parameter Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Case Study: Simulating an ALU 15 a b c a b c a b c a c 0 1 b0 b1 e0 e0 result 0 b0 1 b1 result 00 01 10 11 b0 b1 b2 b3 e1e0 e1 e0 result 0 0 b0 0 1 b1 1 0 b2 1 1 b3 result 4-to-1 multiplexer 2-to-1 multiplexer carryOut sum One-bit adder a b carryIn Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 One-Bit ALU 16 operation 0 1 0 1 2 3 + CarryIn a b r carryOut 1-bit ALU a b r operation CarryIn carryOut 1-bit adder 4-to-1 multiplexer 2-to-1 multiplexer Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Simulating AND Gate in VIPLE 17 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Case Study: Building the One-Bit Adder 18 carryOut sum a b carryIn
  4. 4 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Testing the One-Bit

    Adder 19 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Creating 2-1 Multiplexor 20 00 01 10 11 first second third fourth e1e0 result Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Creating One-Bit ALU 21 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Testing One-Bit ALU 22 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Automated Test Case Generation  Manual testing is time consuming and tedious  Analyze the test case generation for 1-bit adder 23 CountTo7 a b carryIn 0 0 0 0 1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0 5 1 0 1 6 1 1 0 7 1 1 1 if CountTo7 = 0, 1, 2, 3, then a = 0, else a = 1; if CountTo7 = 0, 1, 4, 5, then b = 0, else b = 1; if CountTo7 = 0, 2, 4, 6, then carryIn = 0, else carryIn = 1; Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Counter that Generate Test Cases as Events 24
  5. 5 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Automated Testing of

    One-Bit Adder 25 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 ASU VIPLE is Service Oriented 26 .Net Framework Workflow Foundation Web services and applications ASP .Net Robotic services and Applications ASU Service and Application Repository Service Broker Service Provider Robotic Applications in VIPLE Service Client MRDS VPL ASU VIPLE Other Framew orks Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Converting an Activity into a Service  An activity is a part of an application  It cannot be reused in another application  To convert an activity into a service: Right click: 27 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 After a Custom Service is Created  When you “Export as a Service”, you can save the service anywhere you want.  By default, it will be saved into the “CustomServices” folder in your VIPLE program folder.  When VIPLE is started, all services will be imported into the VIPLE service list, where you find the other services like Print Line and Text to Speech.  To delete (remove) a custom service, open the folder CustomServices and delete the file of the service. After you restart the service, the custom service will disappear from the service list.  To share a service in another application, copy the service file into the CustomServices folder of another application. 28 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Calling RESTful Services 29 http://venus.eas.asu.edu/WSRepository/Ser vices/EncryptionRest/Service.svc/Decrypt?t ext=AdAqmhVEN2A= http://venus.eas.asu.edu/WSRepository /Services/EncryptionRest/Service.svc/E ncrypt?text=Hello Service address, with parameter value =Hello, to be called Service address, with parameter value = AdAqmhVEN2A=, to be called Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Calling a WSDL Service 30 http://venus.eas.asu.edu/WSRepository/Ser vices/RandomStringSVC/Service.svc     Service address to be called   
  6. 6 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Code Activity: Wrap

    any C# Class into an Activity 31     Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Sequential vs. Parallel Computing 32  Sequential version of adding many numbers sum = =0 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Parallel / Distributed Computing  Parallel version of adding many numbers 33 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Events and Event Handling  A common technique in distributed computing  XML validation and handling  Exceptions and handling  Mouse click and code processing the click  Sensory input arrived (touch sensor) and the action  A timer elapsed and the action  Event-driven computing assumes there are multiple processors to handle events in parallel  Event handling process  Class A publishes event delegates (signatures) for subscription;  Class B implements an event handler and subscribes to an event delegate by adding the handler name into the delegate;  When an event occurs in class A, class A will callback the handler in class B, which handles the event. 34 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Events and Event Handling (Contd.) 35 Events taking Delegates (Signatures) Class A (event service) Event subscribing Event handling Class B (event client) Callbacks Event subscribing Event handling Class C (event client) Events Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Concurrency and Events in Robotics Programming 36 Bumper sensor Sonar sensor Timer Orchestration Motor 1 Motor 2 Servo Event notification Message Box Event output Data output Data and event outputs
  7. 7 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Concurrency and Events

    in Robotics Programming  Handling sensory inputs and controlling actuators must be dealt with concurrently, as otherwise sensor inputs can easily be ignored and actuators can get starved.  Orchestration and composition should not be in control flow model. Event-driven model is a better way to handle such applications.  Event notification can be sensible alone, or in combination with the return data 37 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Event-Driven Notification 38 Activity / Service User Activity Activity / Service User Activity Event signals Event signals, e.g., timer, or completion Regular return value Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Event-Driven Programming VIPLE supports two types of events  Custom events: Allow programmers to define an event as an activity’s output  Built-in events: Predefined services in the VIPLE service list that generate events 39 General-purpose and event services Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Event-Driven Programming: Custom Event 40  Implementing the CountToN activity with event output Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Event-Driven Programming: Custom Event 41  Accessing the custom event Custom events and built-in events Counter generates different data in each iteration, it works without using events If an activity can generate the same data, we need to use event output Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 General-purpose and event services Event-Driven Programming: Key Press Event 42 Printed 5 second later
  8. 8 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 Parity Bit Generation

    Using Key Press Event  An ASCII code consists of 7 bits of 0s or 1s.  The 8th bit is often generated for parity checking:  If the first 7 bits has odd number of 1s, the 8th bit is 0, otherwise, it is 1, to keep the total number of 1s is an odd number.  Write a VIPLE application to generate the odd-parity bit of an ASCII code. Example: 43 Y. Chen 2016 Google 师资培育与课程建设第二期 “嵌入式与系统软件开发”研讨班 44 Next Lecture …  Finite State Machine (FSM)  Maze navigation  Robotics Programming in Simulation