| 1 | model PickPlace
|
|---|
| 2 | inner Real y(start=10.0);
|
|---|
| 3 | inner Real yd(start=0.0);
|
|---|
| 4 | inner Real x(start=10.0);
|
|---|
| 5 | inner Real xd(start=0.0);
|
|---|
| 6 | inner Boolean inn(start=false);
|
|---|
| 7 | inner Boolean down(start=true);
|
|---|
| 8 | inner Boolean up(start=false);
|
|---|
| 9 | inner Boolean out(start=false);
|
|---|
| 10 | inner Boolean pick(start=false);
|
|---|
| 11 | inner Boolean drop(start=false);
|
|---|
| 12 | inner Boolean ON(start=false);
|
|---|
| 13 | inner Boolean OFF(start=false);
|
|---|
| 14 | inner Integer count(start=1);
|
|---|
| 15 | inner Real ymax(start=10.0);
|
|---|
| 16 | inner Real ymin(start=0.0);
|
|---|
| 17 | inner Real xmax(start=10.0);
|
|---|
| 18 | inner Real xmin(start=0.0);
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | block StandingStill
|
|---|
| 22 | outer output Real y;
|
|---|
| 23 | outer output Real yd;
|
|---|
| 24 | equation
|
|---|
| 25 | yd=0;
|
|---|
| 26 | y=previous(y)+yd*0.002;
|
|---|
| 27 | end StandingStill;
|
|---|
| 28 | StandingStill standingstill;
|
|---|
| 29 | block MovingDown
|
|---|
| 30 | outer output Real y;
|
|---|
| 31 | outer output Real yd;
|
|---|
| 32 | outer output Integer count;
|
|---|
| 33 | equation
|
|---|
| 34 | yd=-5;
|
|---|
| 35 | y=previous(y)+yd*0.002;
|
|---|
| 36 | count=count+1;
|
|---|
| 37 | end MovingDown;
|
|---|
| 38 | MovingDown movingdown;
|
|---|
| 39 | block MovingUp
|
|---|
| 40 | outer output Real y;
|
|---|
| 41 | outer output Real yd;
|
|---|
| 42 | equation
|
|---|
| 43 | yd=+5;
|
|---|
| 44 | y=previous(y)+yd*0.002;
|
|---|
| 45 | end MovingUp;
|
|---|
| 46 | MovingUp movingup;
|
|---|
| 47 | equation
|
|---|
| 48 | initialState(standingstill);
|
|---|
| 49 | transition(standingstill,movingdown,down,immediate=true,priority=1);
|
|---|
| 50 | transition(standingstill,movingup,up,immediate=true,priority=2);
|
|---|
| 51 | transition(movingdown,standingstill,not down,immediate=true);
|
|---|
| 52 | transition(movingup,standingstill,not up,immediate=true);
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | public
|
|---|
| 57 | block StandingStilll
|
|---|
| 58 | outer output Real x;
|
|---|
| 59 | outer output Real xd;
|
|---|
| 60 | equation
|
|---|
| 61 | xd=0;
|
|---|
| 62 | x=previous(x)+xd*0.002;
|
|---|
| 63 | end StandingStilll;
|
|---|
| 64 | StandingStilll standingstilll;
|
|---|
| 65 | block MovingOut
|
|---|
| 66 | outer output Real x;
|
|---|
| 67 | outer output Real xd;
|
|---|
| 68 | equation
|
|---|
| 69 | xd=5;
|
|---|
| 70 | x=previous(x)+xd*0.002;
|
|---|
| 71 | end MovingOut;
|
|---|
| 72 | MovingOut movingout;
|
|---|
| 73 | block MovingIn
|
|---|
| 74 | outer output Real x;
|
|---|
| 75 | outer output Real xd;
|
|---|
| 76 | equation
|
|---|
| 77 | xd=-5;
|
|---|
| 78 | x=previous(x)+xd*0.002;
|
|---|
| 79 | end MovingIn;
|
|---|
| 80 | MovingIn movingin;
|
|---|
| 81 | equation
|
|---|
| 82 | initialState(standingstilll);
|
|---|
| 83 | transition(standingstilll,movingout,out,immediate=true,priority=1);
|
|---|
| 84 | transition(standingstilll,movingin,inn,immediate=true,priority=2);
|
|---|
| 85 | transition(movingout,standingstilll,not out,immediate=true);
|
|---|
| 86 | transition(movingin,standingstilll,not inn,immediate=true);
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | public
|
|---|
| 91 | block On1
|
|---|
| 92 | Integer res;
|
|---|
| 93 | outer input Integer count;
|
|---|
| 94 | outer output Boolean out;
|
|---|
| 95 | outer output Boolean inn;
|
|---|
| 96 | outer output Boolean up;
|
|---|
| 97 | equation
|
|---|
| 98 | res=rem(count,2);
|
|---|
| 99 | out=res>0;
|
|---|
| 100 | inn=res<1;
|
|---|
| 101 | up=false;
|
|---|
| 102 | end On1;
|
|---|
| 103 | On1 on1;
|
|---|
| 104 | block Off1
|
|---|
| 105 | end Off1;
|
|---|
| 106 | Off1 off1;
|
|---|
| 107 | equation
|
|---|
| 108 | initialState(on1);
|
|---|
| 109 | transition(on1,off1,y<ymax,immediate=true);
|
|---|
| 110 | transition(off1,on1,y>=ymax,immediate=true);
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | public
|
|---|
| 114 | block On2
|
|---|
| 115 | Integer res;
|
|---|
| 116 | outer output Boolean down;
|
|---|
| 117 | outer output Boolean drop;
|
|---|
| 118 | outer output Boolean pick;
|
|---|
| 119 | outer input Real count;
|
|---|
| 120 | equation
|
|---|
| 121 | res=rem(count,2);
|
|---|
| 122 | pick=res>0;
|
|---|
| 123 | drop=res<1;
|
|---|
| 124 | down=false;
|
|---|
| 125 | end On2;
|
|---|
| 126 | On2 on2;
|
|---|
| 127 | block Off2
|
|---|
| 128 | end Off2;
|
|---|
| 129 | Off2 off2;
|
|---|
| 130 | equation
|
|---|
| 131 | initialState(off2);
|
|---|
| 132 | transition(off2,on2,y<=ymin,immediate=true);
|
|---|
| 133 | transition(on2,off2,y>ymin,immediate=true);
|
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 | public
|
|---|
| 137 | block On3
|
|---|
| 138 | outer output Boolean down;
|
|---|
| 139 | outer output Boolean out;
|
|---|
| 140 | equation
|
|---|
| 141 | out=false;
|
|---|
| 142 | down=true;
|
|---|
| 143 | end On3;
|
|---|
| 144 | On3 on3;
|
|---|
| 145 | block Off3
|
|---|
| 146 | end Off3;
|
|---|
| 147 | Off3 off3;
|
|---|
| 148 | equation
|
|---|
| 149 | initialState(off3);
|
|---|
| 150 | transition(off3,on3,x>=xmax,immediate=true);
|
|---|
| 151 | transition(on3,off3,x<xmax,immediate=true);
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | public
|
|---|
| 155 | block On4
|
|---|
| 156 | outer output Boolean inn;
|
|---|
| 157 | outer output Boolean down;
|
|---|
| 158 | equation
|
|---|
| 159 | inn=false;
|
|---|
| 160 | down=true;
|
|---|
| 161 | end On4;
|
|---|
| 162 | On4 on4;
|
|---|
| 163 | block Off4
|
|---|
| 164 | end Off4;
|
|---|
| 165 | Off4 off4;
|
|---|
| 166 | equation
|
|---|
| 167 | initialState(on4);
|
|---|
| 168 | transition(on4,off4,x>xmin,immediate=true);
|
|---|
| 169 | transition(off4,on4,x<=xmin,immediate=true);
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 | public
|
|---|
| 173 | block Open
|
|---|
| 174 | outer output Boolean OFF;
|
|---|
| 175 | equation
|
|---|
| 176 | OFF=true;
|
|---|
| 177 | end Open;
|
|---|
| 178 | Open open;
|
|---|
| 179 | block Closed
|
|---|
| 180 | outer output Boolean ON;
|
|---|
| 181 | equation
|
|---|
| 182 | ON=true;
|
|---|
| 183 | end Closed;
|
|---|
| 184 | Closed closed;
|
|---|
| 185 | equation
|
|---|
| 186 | initialState(open);
|
|---|
| 187 | transition(open,closed,pick,immediate=true);
|
|---|
| 188 | transition(closed,open,drop,immediate=true);
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 | public
|
|---|
| 192 | block Off5
|
|---|
| 193 | outer output Boolean up;
|
|---|
| 194 | equation
|
|---|
| 195 | up=true;
|
|---|
| 196 | end Off5;
|
|---|
| 197 | Off5 off5;
|
|---|
| 198 | block On5
|
|---|
| 199 | outer output Boolean up;
|
|---|
| 200 | equation
|
|---|
| 201 | up=true;
|
|---|
| 202 | end On5;
|
|---|
| 203 | On5 on5;
|
|---|
| 204 | equation
|
|---|
| 205 | initialState(off5);
|
|---|
| 206 | transition(off5,on5,ON,immediate=true);
|
|---|
| 207 | transition(on5,off5,OFF,immediate=true);
|
|---|
| 208 |
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 | end PickPlace;
|
|---|