Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This file is autogenerated by TAIRSC : Trainz Air Scheme Compiler
- // DO NOT RELY ON ANY CONTENTS OF THIS FILE
- // Created 12/05/2012 15:51:14
- // Scheme statistics:
- // node count: 12
- // link count: 23
- // unique: 20
- // to atm: 5
- // with name: 19
- // matrix non-zeros: 32
- // matrix density: 0.2222222222222222222222222222
- // object count: 1
- include "spairscheme.gs"
- include "Freight483M.spec.gs"
- final class Freight483M isclass SPAirScheme
- {
- public float[] nodePresure;
- public float[] nodeVolume;
- public float[] linkFlowRate;
- public float[] alinkFlowRate;
- public SPAirObject[] objects;
- public Freight483MSpec spec;
- public SPVehicle owner;
- public SPVehicle GetOwner() { return owner; }
- public int GetSubNode(string name) { return spec.GetSubNode(name); }
- public int GetSubLink(string name) { return spec.GetSubLink(name); }
- public SPAirObject GetSubObject(string name) { return spec.GetSubObject(name); }
- public int GetNode(string name) { if (spec.nodeIds.TryGet(name) return spec.nodeIds.LastValue; return InvalidNodeId; }
- public int GetLink(string name) { if (spec.linkIds.TryGet(name) return spec.linkIds.LastValue; return InvalidLinkId; }
- public SPAirObject GetObject(string name) { if (spec.objectIds.TryGet(name)) return objects[spec.objectIds.LastValue]; return null; }
- public float GetPressure(int id) { return nodePressure[id]; }
- public float GetPressure(string node) { return nodePressure[GetNode(node)]; }
- public void SetPressure(int id, float value) { nodePressure[id] = value; }
- public void SetPressure(string node, float value) { nodePressure[GetNode(node)] = value; }
- public float GetVolume(int id) { return nodeVolume[id]; }
- public float GetVolume(string node) { return nodeVolume[GetNode(node)]; }
- public void SetVolume(int id, float value) { nodeVolume[id] = value; }
- public void SetVolume(string node, float value) { nodeVolume[GetNode(node)] = value; }
- public float GetCurrentFlow(int id)
- {
- if (id < 0)
- return alinkFlowRate[~id] * Math.Sqrt(nodePressure[spec.alinkSrc[~id]]);
- float delta = nodePressure[spec.linkSrc[id]] - nodePressure[spec.linkDst[id]];
- float deltaSign = 1.0f;
- if (delta < 0.0f)
- deltaSign = -1.0f;
- return deltaSign * linkFlowRate[id] * Math.Sqrt(deltaSign * delta);
- }
- public float GetCurrentFlow(string link) { return GetCurrentFlow(GetLink(link)); }
- public float GetFlowRate(int id)
- {
- if (id < 0)
- return alinkFlowRate[~id] / spec.alinkNominalFlowRate[~id];
- return linkFlowRate[id] / spec.linkNominalFlowRate[id];
- }
- public float GetFlowRate(string link) { return GetFlowRate(GetLink(link)); }
- public void SetFlowRate(int id, float value) {
- if (id < 0) {
- alinkFlowRate[~id] = value * spec.alinkNominalFlowRate[~id];
- return;
- }
- linkFlowRate[id] = value * spec.linkNominalFlowRate[id];
- }
- public void SetFlowRate(string link, float value) { SetFlowRate(GetLink(link), value); }
- public Soup GetProperties()
- {
- return spec.GetSchemeProperties(me);
- }
- public void SetProperties(Soup sp)
- {
- spec.SetSchemeProperties(me, sp);
- }
- public void Update(float dt)
- {
- spec.UpdateInstance(me, dt);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement