FlexSim Supplemental Training: Session 4

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Formulas, Ranges, and Functions. Formulas n Formulas perform operations such as addition, multiplication, and comparison on worksheet values. n Formulas.
Lecture 2 Introduction to C Programming
Introduction to C Programming
JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
Introduction to C Programming
CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
14/11/11.  These words have special meanings in themselves  These should NOT be used as Identifiers.  For example:  Break, do, function, case, else,
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 5, 2005.
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
Chapter 5: Loops and Files.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
COMP 14 Introduction to Programming Miguel A. Otaduy May 20, 2004.
Introduction to C Programming
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
Textbook: Applied Simulation, modeling and Analysis using FlexSim
FlexSim Supplemental Training: Session
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
Fundamentals of Python: From First Programs Through Data Structures
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
2440: 211 Interactive Web Programming Expressions & Operators.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Input, Output, and Processing
CPS120: Introduction to Computer Science
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Linux+ Guide to Linux Certification, Third Edition
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Class 2Intro to Databases Goals of this class Include & Require in PHP Generating Random Numbers in PHP Arrays – Numerically Indexed and Associative Program.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Applications Development
JavaScript, Fourth Edition
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 10 - JavaScript/JScript: Control Structures II Outline 10.1Introduction 10.2Essentials of.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
Loops and Files. 5.1 The Increment and Decrement Operators.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Microsoft Visual Basic 2012 CHAPTER FIVE Decision Structures.
Chapter 6: Looping. Objectives Learn about the loop structure Create while loops Use shortcut arithmetic operators Create for loops Create do…while loops.
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
Second Model: “Model2”. What You Will Learn  How to build a simple layout  How to connect ports for routing flowitems  How to detail and enter data.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Linux Administration Working with the BASH Shell.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
BASIC ELEMENTS OF A COMPUTER PROGRAM
The Selection Structure
Functions CIS 40 – Introduction to Programming in Python
JavaScript: Functions.
Lecture 07 More Repetition Richard Gesick.
MATLAB: Structures and File I/O
Lecture 4B More Repetition Richard Gesick
Chapter 5 - Functions Outline 5.1 Introduction
Introduction to C++ Programming
T. Jumana Abu Shmais – AOU - Riyadh
Chapter 3 – Introduction to C# Programming
2.6 The if/else Selection Structure
Objectives You should be able to describe: The while Statement
CSC215 Lecture Control Flow.
Introduction to C Programming
Web Programming and Design
Presentation transcript:

FlexSim Supplemental Training: Session 4 20121029

Session Philosophy Increase your modelling power through: Knowing where and how model data is stored/accessed Reusability Abstraction Be able to ask yourself: What Event and what Object will allow me to accomplish what I want? 2 2

The Flexsim Tree and Flexscript Trees and Nodes Functions Understanding Modeling events The Modelling Language – Flexscript Model building 3 3

What is a Node? Basic data structure of Flexsim is a hierarchal tree main tree (model and project related objects and data) view tree (GUI related objects and picklists) model tree (model related objects and data) The node is the basic building block of a tree Nodes hold all the information behind the scenes for objects, GUIs and data. 4 4

Node Structure Nodes have a name Nodes can have a data item number string object If nodes have object data, use > to view a separate node list containing the object info (data members and member functions) If nodes contain sub nodes, use + to expand and view the child nodes 5 5

Node Symbols Standard Folder Object Object data Function (C++) Function (FlexScript) 6 6

Sample Model Tree 7 7

functionname(argument1, argument2, etc) What is a function? functionname(argument1, argument2, etc) An argument can be: Numerical value String (“text“) Reference to an object or node Function example: colorrandom(item) (see OnExit trigger of a Source object) Many of Flexsim’s functions are used to read data from the tree and save data to the tree. 8 8

Functions and the ‘return’ statement Function ‘calls’ are like asking a question Input is required of the user and an answer is given as a ‘return’ value Picklist properties on Objects are functions The return values will mean different things for each object function, it answers the question asked by the function

Object Properties Understanding the edit fields of an object will help you understand Flexsim. You should be able to answer the following four questions about each edit field: what is its purpose? when is it evaluated? what are its access variables? what does it return? 10 10

Order of Execution (pushed flowitem) flowitem enters OnEntry Setup Time Pick Operator Pick Operator Process Time OnSetupFinish delay delay OnProcessFinish Send To Port possible delay OnExit delay Request Transport From 11 11

Access Variables & Returns Edit Field Access Variables Returns Setup Time current, item, port delay time Process Time current, item Send To Port port number Pull From Port current Pull Requirement true/false (1/0) Request Transport From numeric pointer Pick Operator OnReset N/A OnMessage current, msgsendingobject, msgparam1, msgparam2, msgparam3 OnEntry OnExit OnSetupFinish OnProcessFinish 12 12

General Rules language is case sensitive (A does not equal a) no specific format is required (free use of spaces, tabs and line returns are encouraged for readable code) text strings are entered between quotes. “mytext” parenthesis follow a function call and commas separate the arguments of the function. moveobject(object1, object2); a function or command will always end with a SEMI-COLON (;) parenthesis can also be used freely to make associations in your math and logic statements. Ex: ((x+3)*2) curly braces { } are used to define a block of statements. to comment the rest of a line use // and type note here multi-line comments start with /* and end with */. don’t use spaces or special characters in name definitions ( _ is ok). names may include numbers, but may not begin with a number (machine_9 is acceptable, 9machine is not). 13 13

Variable Types int double string treenode integer (1, 2, 3, 14324) double precision (2.5, 3.14159) text string (“Anthony was here.”) reference to a node in the tree 14 14

Declaring and Setting Variables int index = 1; double weight = 175.8; string category = “groceries”; treenode forklift = centerobject(current,1); 15 15

Math Operators x + y x plus y x - y x minus y x * y x times y x / y sqrt(x) pow(x,y) round(x) frac(x) fmod(x,y) min(x,y) max(x,y) x plus y x minus y x times y x divided by y square root of x x to the power of y (xy) x rounded to the nearest integer returns the decimal portion of x returns the remainder of x/y returns minimum of x and y returns maximum of x and y 16 16

Comparing x > y x < y x >= y x <= y x == y x != y comparetext(string1,string2) x greater than y x less than y x greater than or equal to y x less than or equal to y x equal to y x not equal to y string1 matches string2 These values return TRUE or FALSE. 17 17

Updating x = y x += y x -= y x *= y x /= y x ++ x -- set x to y set x to x plus y set x to x minus y set x to x times y set x to x divided by y add 1 to x subtract 1 from x Remember: ‘=‘ is not the same as ‘==‘ = is used to set a value == is a comparison operator 18 18

Relating && || ! logical AND logical OR logical NOT 19 19

Logical ‘if’ Statement if (test expression) { code block } else if (content(item) == 2) { colorred(item); } else colorblack(item); 20 20

Logical ‘switch’ Statement int type = getitemtype(item); switch (type) { case 1: coloryellow(item); break; } case 5: colorred(item); default: colorgreen(item); switch ( switchvariable ) { case casenum: code block break; } case casenum2: default: 21 21

Basic Object Referencing current - the current object, the owner of the code item - the involved flowitem that triggered the event model - references the model tree rank(node, ranknum) rank(current,3) first(object) first(current) last(object) last(current) inobject(object, portnum) inobject(current,1) outobject(object, portnum) outobject(current,1) centerobject(object, portnum) centerobject(current,1) node(“relativepath”, object) node(“/Operator1”,model()) 22 22

Basic Object Statistics content( object ) getinput( object ) getoutput( object ) getstatenum( object ), setstatenum( object, value ) int inventory = content(current); int produced = getoutput(current); 23 23

Accessing Data in the Tree getvarnum(object, “varname”), setvarnum(object, “varname”, value) getvarstr(object, “varname”), setvarstr(object, “varname”, string) getvarnode(object, “varname”) getnodenum(node), setnodenum(node, value) getnodestr(node), setnodestr (node, string) labels(object) itemtype(object) Many nodes are arranged as tables within objects and can also be accessed with the table commands gettablenum(ReferenceToTable, row, col), settablenum() etc.

Logical ‘while’ Statement while (test expression) { code block } while (content(current) > 0) { destroyobject(last(current)); } In programming, a while loop is a control structure that allows a code block to be repeated as long as a test expression is true. May also use the break or return statement to force loop execution to halt. Avoid infinite loops by ensuring that the test expression will eventually fail. 25 25

Logical ‘for’ Statement for (start expression; test expression; count expression) { //code block } for (int index=1; index<=content(current); index++) { colorblue(rank(current,index)); } A for loop allows you to repeat a block of code a set number of times. The head of the for loop defines the repeat conditions: 1. specify a changing variable & give it an initial value 2. set a condition to exit the loop 3. how to treat your variable at the end of each iteration Avoid infinite loops by ensuring that the test expression will eventually fail. 26 26

Model Key Concepts Logic Control via Loops and Conditional statements Locating, and manipulating data from the Tree, ex. how does the Combiner know how many flowitems to pack? Combiner component list table shows target quantities from each input port Additional node in its tree called targetcomponentsum which is the sum of all target quantities from all input ports. The cumulative number of flowitems to pack across all ports. If you need to alter the combiner’s component list dynamically, you need to adjust both values; the value from each port, and the sum of all ports

Model Description Purpose Description Practice using FlexScript to accomplish various modeling needs, such as routing, decision making and object manipulation. Description 4 item types, distributed according to the duniform distribution, enter a conveyor, and are routed to 1 of 2 object groups consisting of a queue, pallet source and a combiner. Write a Send to Port rule that will send 70% of the flowitems to the queue on port 1, and the rest to port 2. Combiners will read a Label value off of pallets and pack that many flowitems into the pallet. The label value will vary according to duniform(3, 12). Assume an infinite supply of pallets from the pallet source. Loaded pallets are sent to a processor where they will process for a length of time equal to the lognormal2(15, 3.1, 0.5) times the number of flowitems on the pallet. Change the color of the boxes inside the pallet according to their itemtype, as they leave the processor. Arrange the colors such that itemtype 1 = green, 2 = red, 3 = orange, and 4 = blue. Send pallets to the appropriate sink such that if they have less than or equal to 6 items they go to sink 1 the rest to sink 2. 28 28

Model Layout 29 29