public void SetReference(NacelleStator reference) { this.reference = reference; }
/// <summary> /// Gets all managed stator blocks. /// </summary> private void GetBlocks() { // Reset static variables with stator data referenceStator = null; slaveStators.Clear(); maxStateMachines = 0; mirroredStators = 0; copiedStators = 0; referenceStatorName = ""; // Prepare a list of stators List <IMyMotorStator> statorList = new List <IMyMotorStator>(); // Get all stator blocks GridTerminalSystem.GetBlocksOfType(statorList); // Filter stator blocks foreach (IMyMotorStator stator in statorList) { NacelleStator managedStator; // Read Custom Data string val = stator.CustomData.ToLower(); // Check if stator is configured if (val.Contains(reference.ToLower())) { managedStator = new NacelleStator(stator, Log); referenceStator = managedStator; } else if (val.Contains(mirror.ToLower())) { managedStator = new NacelleStator(stator, true, Log); slaveStators.Add(managedStator); mirroredStators++; } else if (val.Contains(copy.ToLower())) { managedStator = new NacelleStator(stator, Log); slaveStators.Add(managedStator); copiedStators++; } else { continue; } maxStateMachines++; StatorProperties properties = managedStator.Update(); // Check if stator has an offset try { properties.Offset(float.Parse(IsolateSetValue(val, offset))); } catch { } // Check if stator has a lower limit try { properties.LowerLimit(float.Parse(IsolateSetValue(val, lowerLimit))); } catch { } // Check if stator has an upper limit try { properties.UpperLimit(float.Parse(IsolateSetValue(val, upperLimit))); } catch { } // Check if stator has a velocity try { properties.Velocity(float.Parse(IsolateSetValue(val, velocity))); } catch { } properties.Commit(); } if (referenceStator == null) { Log("ERROR: No reference stator."); return; } foreach (NacelleStator slave in slaveStators) { slave.SetReference(referenceStator); } // Get the reference stator's name (for info purposes) referenceStatorName = referenceStator.stator.CustomName; }