Advertisement
Guest User

Proper Curry

a guest
Jul 20th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SCL 3.49 KB | None | 0 0
  1. //Function takes total distance over the X number of block specified from the input.
  2. //If the destination block is found within the X number the remaining distance is
  3. //provided.
  4.  
  5. //Check if our current block is our destination
  6. IF #Navigation.Destination.Final <> #Block AND #Navigation.Destination.Intermediate <> #Block THEN
  7.     //Subtract current distance in block from total distance of block
  8.     #Distance := "DB_BLOCKS".Block[#Block].EndValue - #Position;
  9.     #tBlock := #Block;
  10.     //------------------------------------Drive Without Communication---------------------------------------------------
  11.     //------------------------------------Needed for cuts in DP Rail----------------------------------------------------
  12.     IF "DB_BLOCKS".Block[#Block].NoComm.START <> 0 AND "DB_BLOCKS".Block[#Block].NoComm.STOP <> 0 THEN
  13.         "DriveNoComm" := #Position <= "DB_BLOCKS".Block[#Block].NoComm.STOP AND #Position >= "DB_BLOCKS".Block[#Block].NoComm.START;
  14.     ELSE
  15.         "DriveNoComm" := FALSE;
  16.     END_IF;
  17.    
  18.     //Loop through total number of blocks to look ahead
  19.     FOR #i := 1 TO #Count DO
  20.         #tBlock := "DB_BLOCKS".Block[#tBlock].NextBlockIndex; //Set block to next position
  21.         //Block found is the final destination block and has a positioning point
  22.         IF "DB_BLOCKS".Block[#Navigation.Destination.Final].PositionPoint <> 0 AND #tBlock = #Navigation.Destination.Final THEN
  23.                 #Distance := #Distance + ("DB_BLOCKS".Block[#Navigation.Destination.Final].EndValue - "DB_BLOCKS".Block[#Navigation.Destination.Final].PositionPoint );
  24.                 EXIT;
  25.         //Block found is the intermediate destination block and has a positioning point
  26.         ELSIF "DB_BLOCKS".Block[#Navigation.Destination.Intermediate].PositionPoint <> 0 AND #tBlock = #Navigation.Destination.Intermediate THEN
  27.             #Distance := #Distance + ("DB_BLOCKS".Block[#Navigation.Destination.Intermediate].EndValue - "DB_BLOCKS".Block[#Navigation.Destination.Intermediate].PositionPoint );
  28.                 EXIT;
  29.         //Block found is intermediate or final and does not have a positioning point        
  30.             ELSIF (#tBlock = #Navigation.Destination.Final OR #tBlock = #Navigation.Destination.Intermediate) AND "DB_BLOCKS".Block[#tBlock].PositionPoint = 0 THEN
  31.                
  32.             #Distance := #Distance + ("DB_BLOCKS".Block[#tBlock].EndValue - (("DB_BLOCKS".Block[#tBlock].EndValue - "DB_BLOCKS".Block[#tBlock].StartValue) / 2));
  33.         END_IF;
  34.         //Final or intermediate not found, add total distance of block
  35.         #Distance := #Distance + ("DB_BLOCKS".Block[#tBlock].EndValue - "DB_BLOCKS".Block[#tBlock].StartValue);
  36.     END_FOR;
  37.    
  38.    
  39. //Distance remaining if we are in the FINAL block with POS POINT
  40. ELSIF #Navigation.Destination.Final = #Block AND "DB_BLOCKS".Block[#Navigation.Destination.Final].PositionPoint <> 0 THEN
  41.     #Distance := "DB_BLOCKS".Block[#Navigation.Destination.Final].PositionPoint - #Position;
  42. //Distance remaining if we are in the INTERMEDIATE block with POS POINT
  43. ELSIF #Navigation.Destination.Intermediate = #Block AND "DB_BLOCKS".Block[#Navigation.Destination.Intermediate].PositionPoint <> 0 THEN
  44.     #Distance := "DB_BLOCKS".Block[#Navigation.Destination.Intermediate].PositionPoint - #Position;
  45. //Distance remaining in our block if there is no positioning point, block distance/2
  46. ELSE
  47.    
  48.     #Distance := ("DB_BLOCKS".Block[#Block].EndValue - (("DB_BLOCKS".Block[#Block].EndValue - "DB_BLOCKS".Block[#Block].StartValue) / 2)) - #Position;
  49. END_IF;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement