public void Controlunit_can_move_data_from_register_to_ram() { // Arrange var controlUnit = new ControlUnit(); // Act // Set A to 17 controlUnit.Do(new Byte2(17), false); controlUnit.Do(new Byte2(17), true); // Copy A to D var byte2 = new Byte2("1000100010010000"); controlUnit.Do(byte2, false); controlUnit.Do(byte2, true); // Set A to 0 controlUnit.Do(new Byte2(0), false); controlUnit.Do(new Byte2(0), true); // Copy D to Ram controlUnit.Do(new Byte2("1000000010001000"), false); controlUnit.Do(new Byte2("1000000010001000"), true); // Copy D to A controlUnit.Do(new Byte2("1000000010100000"), false); var controlUnitOutput = controlUnit.Do(new Byte2("1000000010100000"), true); // Assert controlUnitOutput.J.Should().BeFalse(); controlUnitOutput.A.ToInt16().Should().Be(17); }
} // end of FindControlForOutpatientAdmission #endregion #region FindControlForInpatientAdmission /// <summary> /// Finds a control unit that handles a specific inpatient admission type /// </summary> /// <param name="admission">The admission type that is searched for</param> /// <returns>Either a control unit that handles the admission or null if no such control unit exists</returns> public ControlUnit FindControlForInpatientAdmission(InpatientAdmissionTypes admission) { if (!HandledInpatientAdmissionTypes.Contains(admission)) { return(null); } if (this.ControlUnitType == Enums.ControlUnitType.Inpatient && this.HandledInpatientAdmissionTypes.Contains(admission)) { return(this); } else { foreach (ControlUnitHealthCare childControl in ChildHealthCareControlUnits) { ControlUnit foundControl = childControl.FindControlForInpatientAdmission(admission); if (foundControl != null) { return(foundControl); } } // end foreach } // end if return(null); } // end of FindControlForInpatientAdmission
//-------------------------------------------------------------------------------------------------- // Constructing //-------------------------------------------------------------------------------------------------- #region Constructor /// <summary> /// Basic constructor of emergency department controls /// </summary> /// <param name="name">String identifier of control unit</param> /// <param name="parentControlUnit">Parent management control unit</param> /// <param name="parentSimulationModel">Parent simulation model</param> /// <param name="inputData">Outpatient input data</param> /// <param name="handledOutpatientAdmissionTypes">Outpatient admission types that are handled by the control unit</param> /// <param name="waitinListControlUnit">Corresponding waiting list control unit</param> public ControlUnitOutpatient(string name, ControlUnit parentControlUnit, OutpatientAdmissionTypes[] handledOutpatientAdmissionTypes, SimulationModel parentSimulationModel, ControlUnit waitinListControlUnit, IInputOutpatient inputData) : base(ControlUnitType.Outpatient, name, parentControlUnit, parentSimulationModel, inputData) { if (handledOutpatientAdmissionTypes != null) { _handledOutpatientAdmissionTypes = handledOutpatientAdmissionTypes.ToArray(); } else { _handledOutpatientAdmissionTypes = Helpers <OutpatientAdmissionTypes> .EmptyArray(); } _waitingListControlUnit = waitinListControlUnit; _inputData = inputData; _delegateHandlingMethods.Add(typeof(DelegateAvailabilitiesForRequest), DefaultDelegateHandling.HandleImmediateSpecialServiceRequest); } // end of ControlUnitOutpatient
public void Controlunit_can_add_two_numbers() { // Arrange var controlUnit = new ControlUnit(); // Act // Set A to 17 controlUnit.Do(new Byte2(17), false); controlUnit.Do(new Byte2(17), true); // Copy A to D var byte2 = new Byte2("1000100010010000"); controlUnit.Do(byte2, false); controlUnit.Do(byte2, true); // Set A to 29 controlUnit.Do(new Byte2(29), false); controlUnit.Do(new Byte2(29), true); // Add A and D and store result in A controlUnit.Do(new Byte2("1000000010100000"), false); var controlUnitOutput = controlUnit.Do(new Byte2("1000000010100000"), true); // Assert controlUnitOutput.J.Should().BeFalse(); controlUnitOutput.A.ToInt16().Should().Be(46); }
private void InitControlUnit() { _networkScanner.Scan(); Assert.Greater(_networkScanner.Controllers.Count, 0, "No controller found on the network."); _controlUnit = new ControlUnit(_networkScanner.Controllers.First()); Assert.AreEqual(_controlUnit.TryConnect(), true, "Failed to connect to controller."); }
/// <summary> /// Basic constructor. /// </summary> /// <param name="parentControlUnit">Parent control unit, either a health care department control unit or a organizational unit</param> /// <param name="input">Input data of department model</param> /// <param name="patient">Patient receiving service</param> /// <param name="resources">Resources included in the activity</param> /// <param name="type">Type of activity (e.g. emergency action type)</param> /// <param name="patientPath">The current path of the patient (can vary for outpatient or emergency paths)</param> public ActivityHealthCareAction(ControlUnit parentControlUnit, IInputHealthCareDepartment input, EntityPatient patient, ResourceSet resources, T type, PatientPath <T> patientPath) : base(parentControlUnit, "ActivityHealthCareAction", type.IsPreemptable) { _inputData = input; _patient = patient; _actionType = type; _resourceSet = resources; _patientPath = patientPath; // in case that the parent control unit is a organizational control // the parent department control is set if (parentControlUnit is ControlUnitHealthCareDepartment) { _parentDepartmentControl = parentControlUnit as ControlUnitHealthCareDepartment; } else if (parentControlUnit is ControlUnitOrganizationalUnit) { _parentDepartmentControl = ((ControlUnitOrganizationalUnit)parentControlUnit).ParentDepartmentControl as ControlUnitHealthCareDepartment; } } // end of ActivityHealthCareAction
private void ClickRequirementUnitContainer(RequirementUnitContainer _container) { if (selectedUnitList.Count == _container.requirement.dishArr.Length) { List <int> list = new List <int>(); for (int i = 0; i < selectedUnitList.Count; i++) { ControlUnit controlUnit = selectedUnitList[i]; if (controlUnit is DishResultContainer) { DishResultContainer container = controlUnit as DishResultContainer; list.Add(container.index); } else { DishResultBt bt = controlUnit as DishResultBt; list.Add(-bt.dish.index - 1); } } if (client.CheckCanCompleteRequirement(list, _container.requirement)) { //send command client.CompleteRequirement(list, _container.requirement.uid); } } ClearSelectedUnitList(); }
/** * 坦克初始化 */ public void Setup(int idx, Color col, String name) { // 设置控制模式 controlMode = idx; switch (idx) { case 0: // 0 号手动机 control = new UserControlUnit(); break; case 1: // 1 号自瞄机 control = new ShootControlUnit(); break; case 2: // 2 号逃跑机 control = new EscapeControlUnit(); break; case 3: // 3 号学习机 control = new NetworkControlUnit(); ((NetworkControlUnit)control).NetworkSetup(inputNum, 3); break; default: // 其他靶子 control = new RandomControlUnit(); break; } //设置控制目标 target.SetTankColors(col); control.Setup(target); tankName = name; }
public override void TryDeliverProduct() { if (base.TryDeliverProduct(this)) { ControlUnit.SwitchToState(new InsertCoinState(ControlUnit)); } }
} // end of AdditionalStaticVisualization #endregion #region AdditionalDynamicVisualization /// <summary> /// Additionally to event handling methods for visualization, the number of patients waiting /// for a slot to be assigned or waiting for a slot are showed. /// </summary> /// <param name="currentTime">Time for additional dynamic visualization</param> /// <param name="simModel">Simulation model to be visualized</param> /// <param name="parentControlUnit">Control to be visualized</param> /// <param name="currentEvents">Events that have been triggered at current time</param> public override void AdditionalDynamicVisualization(DateTime currentTime, SimulationModel simModel, ControlUnit parentControlUnit, IEnumerable <Event> currentEvents) { ControlUnit waitingListControl = ((ControlUnitOutpatient)parentControlUnit).WaitingListControlUnit; NumberSlotAssignString.StringToDraw = waitingListControl.CurrentActivities.Where(p => p.ActivityName == "ActivityOutpatientWaitingListWaitToAssignSlot").Count().ToString(); NumberSlotWaitString.StringToDraw = waitingListControl.CurrentActivities.Where(p => p.ActivityName == "ActivityWait").Count().ToString(); } // end of AdditionalDynamicVisualization
void save(bool closeOnSuccess) { this.Cursor = Cursors.Hand; Helper.Remote.Invoke <int>(this.UpdateMethodName, (ret, err) => { this.Cursor = null; if (err != null) { MessageBox.Show(MainWindow.Instance, err); } else { ControlUnit unit = this.DataContext as ControlUnit; unit.ChangedProperties.Clear(); _originalModel.CopyValue(unit); _originalModel.ChangedProperties.Clear(); if (closeOnSuccess) { //关闭当前document MainWindow.Instance.CloseDocument(this); } } }, this.DataContext); }
//Lose Kopplung, MainViewModel ist indirekt abhängig von Memory jedoch nicht umgekehrt! public MainViewModel(Memory memory, ControlUnit controlUnit, Parser parser) { _memory = memory; _controlUnit = controlUnit; _parser = parser; _memory.PropertyChanged += _memory_PropertyChanged; }
} // end of HandleAvailabilitiesSpecialServiceRequest #endregion #region HandleRequireDocs /// <summary> /// Handles a request to send doctors for consultation or assisting between departments /// </summary> /// <param name="del">The original request for doctors to consult or assist</param> /// <param name="controlUnit">Control unit that filed request for assistance or consultation</param> /// <param name="time">Time request was filed</param> /// <param name="simEngine">SimEngine responsible for simulation execution</param> /// <returns>True if request has been handled</returns> static public bool HandleRequireDocs(IDelegate del, ControlUnit controlUnit, DateTime time, ISimulationEngine simEngine) { foreach (SkillSet reqSkill in ((DelegateRequestDocsForAssisting)del).RequiredSkillSets) { List <EntityDoctor> possibleDoc = ((ControlUnitHealthCare)controlUnit).FindDoctorWithSkillSet(reqSkill); if (possibleDoc.Count == 0) { break; } EntityDoctor chosenDoc = null; foreach (EntityDoctor doc in possibleDoc) { if (doc.ParentControlUnit == controlUnit) { ActivityMove possibleMove = doc.GetPossibleMovingActivity(); if (possibleMove != null && (possibleMove.Destination == del.OriginControlUnit || possibleMove.Destination == doc.BaseControlUnit)) { chosenDoc = doc; break; } // end if } // end if if (((ControlUnitHealthCare)doc.ParentControlUnit).ControlUnitType == Enums.ControlUnitType.Inpatient) { chosenDoc = doc; break; } // end if } // end foreach if (chosenDoc == null) { chosenDoc = possibleDoc.First(); } if (chosenDoc.ParentControlUnit == controlUnit) { ActivityMove possibleMove = chosenDoc.GetPossibleMovingActivity(); if (possibleMove != null && possibleMove.Destination == chosenDoc.BaseControlUnit) { simEngine.RemoveScheduledEvent(possibleMove.EndEvent); chosenDoc.StopCurrentActivities(time, simEngine); ActivityMove move = new ActivityMove(controlUnit, chosenDoc, controlUnit, del.OriginControlUnit, del, TimeSpan.FromMinutes(1)); move.StartEvent.Trigger(time, simEngine); } // end if } else { controlUnit.SendDelegateTo(chosenDoc.ParentControlUnit, new DelegateSentDocForAssistedTreatment((ControlUnitHealthCare)del.OriginControlUnit, reqSkill)); } // end if } // end foreach return(true); } // end of HandleRequireDocs
internal UnitAlarmSettingDocument(ControlUnit dataModel) { _originalModel = dataModel; InitializeComponent(); this.Title = $"“{dataModel.Name}”配置-报警"; this.DataContext = _originalModel.Clone <ControlUnit>(); }
public List <byte[]> Fetch() { // There will be two values output. List <byte[]> Output = new List <byte[]>(2); // If the destination is DI, use it as an effective address. if (Destination.Code == XRegCode.DI) { Output.Add(ControlUnit.Fetch(DestPtr, (int)Capacity)); } // Otherwise add its value. else { Output.Add(ValueOperand); } // IF the source is SI, use its as an address/ if (Source.Code == XRegCode.SI) { Output.Add(ControlUnit.Fetch(SrcPtr, (int)Capacity)); } // Otherwise add its value. else { Output.Add(ValueOperand); } return(Output); }
/// <summary> /// String representation of state is created /// </summary> /// <param name="timeStamp">Time for which the state is generated</param> /// <param name="loggingEngine">The logging engine for which the state is generated</param> /// <param name="controlUnit">The control unit for which the state is generated</param> public LogControlUnitState(DateTime timeStamp, BaseLoggingEngine loggingEngine, ControlUnit controlUnit) { StringBuilder description = new StringBuilder(); description.Append(timeStamp.ToString("MM.dd:HH:mm:ss:fff")).Append(": ").Append(controlUnit.Name).Append(": RAEL length: ").Append(controlUnit.RAEL.Count).Append(", "); foreach (KeyValuePair <Type, HashSet <Entity> > entityType in controlUnit.ControlledEntities) { description.Append(loggingEngine.GetStringRepDefaultEntityType(entityType.Key)).Append(": ,").Append(entityType.Value.Count).Append(", "); } // end foreach foreach (KeyValuePair <string, List <Activity> > activityType in controlUnit.CurrentActivitiesPerType) { description.Append(activityType.Key).Append(": ,").Append(activityType.Value.Count).Append(", "); } // end foreach description.AppendLine(); foreach (ControlUnit child in controlUnit.ChildControlUnits) { LogControlUnitState childState = new LogControlUnitState(timeStamp, loggingEngine, child); description.Append(childState.GetDescription()); } // end foreach _logState = description.ToString(); } // end of LogControlUnitState
public override void Execute() { ControlUnit.SetFlags(new FlagSet() { Carry = FlagState.OFF }); }
/// <summary> /// Basic constructor, just calling base constructor /// </summary> /// <param name="name">String identifier of control unit</param> /// <param name="parentControlUnit">Parent management control unit</param> /// <param name="parentSimulationModel">Parent simulation model</param> /// <param name="inputData">Emergency input data</param> public ControlUnitEmergencyExample(string name, ControlUnit parentControlUnit, SimulationModel parentSimulationModel, InputEmergency input) : base(name, parentControlUnit, parentSimulationModel, input) { } // end of ControlUnit
public override void SelectProduct(Coordinates coordinates) { if (base.SelectProduct(this, coordinates)) { ControlUnit.SwitchToState(new ConfirmOrderState(this, ControlUnit)); } }
public override void Execute() { // Set the carry flag on ControlUnit.SetFlags(new FlagSet() { Carry = FlagState.ON }); }
public int AddControlledObject(GameObject controlledObject, Func <bool> logicDelegate) { var temp = new ControlUnit(controlledObject); temp.AddLogicDelegate(logicDelegate); m_UnitList.Add(temp); return(m_UnitList.Count - 1); }
/// <summary> /// Basic constructor /// </summary> /// <param name="parentControlUnit">Parent waiting list control</param> /// <param name="waitingListSchedule">Waiting list schedule for slot booking</param> /// <param name="inputData">Outpatient input data</param> public EventOutpatientStartDispatching(ControlUnit parentControlUnit, EntityWaitingListSchedule waitingListSchedule, IInputOutpatient inputData) : base(EventType.Standalone, parentControlUnit) { _waitingListSchedule = waitingListSchedule; _inputData = inputData; } // end of Event
public override void Execute() { // If the carry flag is on, turn it off. If the carry flag is off, turn it on. ControlUnit.SetFlags(new FlagSet() { Carry = (ControlUnit.Flags.Carry == FlagState.ON) ? FlagState.OFF : FlagState.ON }); }
//-------------------------------------------------------------------------------------------------- // Constructor //-------------------------------------------------------------------------------------------------- #region Constructor /// <summary> /// Basic constructor. /// </summary> /// <param name="parentControlUnit">Parent outpatient control</param> /// <param name="patient">Arriving patient</param> /// <param name="inputData">Corresponding input data</param> public EventOutpatientWalkInPatientArrival(ControlUnit parentControlUnit, IInputOutpatient inputData, EntityPatient patient) : base(EventType.Standalone, parentControlUnit) { _patient = patient; _inputData = inputData; } // end of EventOutpatientWalkInPatientArrival
/// <summary> /// Basic constructor /// </summary> /// <param name="name">String identifier of control unit</param> /// <param name="parentControlUnit">Parent outpatient control</param> /// <param name="parentSimulationModel">Parent simulation model</param> /// <param name="input">Corresponding outpatient input data</param> /// <param name="assigningAtEvents">Flag if slots are assigned at events only, or immediately</param> public OutpatientWaitingListSingleScheduleControl(string name, ControlUnit parentControlUnit, SimulationModel parentSimulationModel, IInputOutpatient input, bool assigningAtTimes) : base(name, parentControlUnit, parentSimulationModel, input, assigningAtTimes) { }
/// <summary> /// Basic constructor /// </summary> /// <param name="name">String identifier of control unit</param> /// <param name="parentControlUnit">Parent control, equals null if this control is root</param> /// <param name="parentSimulationModel">Parent simulation control</param> /// <param name="inputData">Input data for management control</param> public ControlUnitHospital(string name, ControlUnit parentControlUnit, SimulationModel parentSimulationModel, IInputManagement inputData) : base(name, parentControlUnit, parentSimulationModel) { _inputData = inputData; }
private void Awake() { Instance = this; lcInput = new ControlUnit(transform.Find("LB").gameObject); rcInput = new ControlUnit(transform.Find("RB").gameObject); eInput = new ControlUnit(transform.Find("E").gameObject); }
//-------------------------------------------------------------------------------------------------- // Constructor //-------------------------------------------------------------------------------------------------- #region Constructor /// <summary> /// Basic constructor /// </summary> /// <param name="name">String identifier of control unit</param> /// <param name="parentControlUnit">Parent control, either a department control or another organizational control</param> /// <param name="parentDepartmentControl">Parent department control</param> /// <param name="parentSimulationModel">Parent simulation model</param> /// <param name="inputData">Parent department input</param> public ContorlUnitAssessmentTreatmentExample(string name, ControlUnit parentControlUnit, ControlUnitHealthCareDepartment parentDepartmentControl, SimulationModel parentSimulationModel, IInputHealthCareDepartment inputData) : base(name, parentControlUnit, parentDepartmentControl, parentSimulationModel, inputData) { } // end of
public override void Execute() { // Set the direction flag on ControlUnit.SetFlags(new FlagSet() { Direction = FlagState.ON }); }
protected override void OnExecute() { // Set flags ControlUnit.SetFlags(ResultFlags); // See base class. AdjustDI(); }