Advertisement
agmike

Freight483M.instance.gs

Dec 5th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.43 KB | None | 0 0
  1. // This file is autogenerated by TAIRSC : Trainz Air Scheme Compiler
  2. // DO NOT RELY ON ANY CONTENTS OF THIS FILE
  3. // Created 12/05/2012 15:51:14
  4. // Scheme statistics:
  5. // node count: 12
  6. // link count: 23
  7. //     unique: 20
  8. //     to atm: 5
  9. //  with name: 19
  10. // matrix non-zeros: 32
  11. // matrix density: 0.2222222222222222222222222222
  12. // object count: 1
  13.  
  14.  
  15. include "spairscheme.gs"
  16. include "Freight483M.spec.gs"
  17.  
  18.  
  19. final class Freight483M isclass SPAirScheme
  20. {
  21.     public float[] nodePresure;
  22.     public float[] nodeVolume;
  23.     public float[] linkFlowRate;
  24.     public float[] alinkFlowRate;
  25.     public SPAirObject[] objects;
  26.     public Freight483MSpec spec;
  27.     public SPVehicle owner;
  28.    
  29.     public SPVehicle GetOwner() { return owner; }
  30.    
  31.     public int GetSubNode(string name) { return spec.GetSubNode(name); }
  32.  
  33.     public int GetSubLink(string name) { return spec.GetSubLink(name); }
  34.  
  35.     public SPAirObject GetSubObject(string name) { return spec.GetSubObject(name); }
  36.  
  37.     public int GetNode(string name) { if (spec.nodeIds.TryGet(name) return spec.nodeIds.LastValue; return InvalidNodeId; }
  38.  
  39.     public int GetLink(string name) { if (spec.linkIds.TryGet(name) return spec.linkIds.LastValue; return InvalidLinkId; }
  40.  
  41.     public SPAirObject GetObject(string name) { if (spec.objectIds.TryGet(name)) return objects[spec.objectIds.LastValue]; return null; }
  42.  
  43.     public float GetPressure(int id) { return nodePressure[id]; }
  44.  
  45.     public float GetPressure(string node) { return nodePressure[GetNode(node)]; }
  46.  
  47.     public void SetPressure(int id, float value) { nodePressure[id] = value; }
  48.  
  49.     public void SetPressure(string node, float value) { nodePressure[GetNode(node)] = value; }
  50.  
  51.     public float GetVolume(int id) { return nodeVolume[id]; }
  52.  
  53.     public float GetVolume(string node) { return nodeVolume[GetNode(node)]; }
  54.  
  55.     public void SetVolume(int id, float value) { nodeVolume[id] = value; }
  56.  
  57.     public void SetVolume(string node, float value) { nodeVolume[GetNode(node)] = value; }
  58.  
  59.     public float GetCurrentFlow(int id)
  60.     {
  61.         if (id < 0)
  62.             return alinkFlowRate[~id] * Math.Sqrt(nodePressure[spec.alinkSrc[~id]]);
  63.         float delta = nodePressure[spec.linkSrc[id]] - nodePressure[spec.linkDst[id]];
  64.         float deltaSign = 1.0f;
  65.         if (delta < 0.0f)
  66.             deltaSign = -1.0f;
  67.         return deltaSign * linkFlowRate[id] * Math.Sqrt(deltaSign * delta);
  68.     }
  69.  
  70.     public float GetCurrentFlow(string link) { return GetCurrentFlow(GetLink(link)); }
  71.  
  72.     public float GetFlowRate(int id)
  73.     {
  74.         if (id < 0)
  75.             return alinkFlowRate[~id] / spec.alinkNominalFlowRate[~id];
  76.         return linkFlowRate[id] / spec.linkNominalFlowRate[id];
  77.     }
  78.  
  79.     public float GetFlowRate(string link) { return GetFlowRate(GetLink(link)); }
  80.  
  81.     public void SetFlowRate(int id, float value) {
  82.         if (id < 0) {
  83.             alinkFlowRate[~id] = value * spec.alinkNominalFlowRate[~id];
  84.             return;
  85.         }
  86.         linkFlowRate[id] = value * spec.linkNominalFlowRate[id];
  87.     }
  88.  
  89.     public void SetFlowRate(string link, float value) { SetFlowRate(GetLink(link), value); }
  90.    
  91.     public Soup GetProperties()
  92.     {
  93.         return spec.GetSchemeProperties(me);
  94.     }
  95.    
  96.     public void SetProperties(Soup sp)
  97.     {
  98.         spec.SetSchemeProperties(me, sp);
  99.     }
  100.    
  101.     public void Update(float dt)
  102.     {
  103.         spec.UpdateInstance(me, dt);
  104.     }
  105. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement