示例#1
0
		void ProcessList_Added(ProcessEditorVm processVm)
		{
			//create choice menuitems for process
			processVm.Choices.Clear();
			foreach (var choice in Choices)
			{
				var choiceVm = new ChoiceEditorVm(choice.Model);
				choiceVm.Selected += ch =>
					processVm.SelectedChoice = Choices.FirstOrDefault(x => x.ManHour == ch.ManHour);
				processVm.Choices.Add(choiceVm);
			}

			//notify Block about selection and delete
			processVm.Selected += Process_Selected;
			processVm.Deleted += Process_Deleted;

			//notify Block about changes in times
			processVm.TimesChanged += Process_TimesChanged;

			//change selected choice for the process
			processVm.SelectedOperatorsCountChanged += Process_OperatorsCountChanged;

			//Updates process TargetPoint or DurationSeconds based on Block fixed data (deferred, fixedDuration, fixedTP)
			processVm.SelectedChoiceChanged += Process_SelectedChoiceChanged;

			if (processVm.Model.StateStationActivity != null)
			{
				//select the right choice based on manHour
				//processVm.SelectedChoice = Choices.FirstOrDefault(x => x.ManHour == processVm.SelectedOperatorsCount);

				//select the right choice based on SSA
				processVm.SelectedChoice = Choices.FirstOrDefault(x => x.ManHour == processVm.Model.StateStationActivity.ManHour);
			}
		}
示例#2
0
		/// <summary>
		/// Updates machines, model and operators and fires SelectedChoiceChanged event
		/// </summary>
		/// <param name="oldVal"></param>
		/// <param name="newVal"></param>
		private void choiceIsChanged(ChoiceEditorVm oldVal, ChoiceEditorVm newVal)
		{
			if (newVal == null)
			{
				//invalid choice
				Model.StateStationActivity = null;
				Message.AddEmbeddedException("نفرساعت مورد استفاده این فعالیت نامعتبر است");
				OperatorCountError = true;

				//Update Machines according to the choice
				foreach (var machineFamilyVm in MachineFamilyList)
				{
					foreach (var machineVm in machineFamilyVm.MachineList)
					{
						machineVm.CanBeUsed = false;
					}
				}
				foreach (var smVm in SelectedMachines)
				{
					smVm.CanBeUsed = false;
				}
			}
			else
			{
				//valid choice
				Model.StateStationActivity = newVal.Model;
				Message.ResetEmbeddedException();

				//compare manhour of selected choice with number of assigned operators
				OperatorCountError = ((int)Math.Ceiling(newVal.ManHour) != Model.ProcessOperators.Count);

				//Update Machines according to the choice
				foreach (var machineFamilyVm in MachineFamilyList)
				{
					foreach (var machineVm in machineFamilyVm.MachineList)
					{
						machineVm.CanBeUsed = newVal.Model.StateStationActivityMachines.Any(ssam => ssam.Machine.Id == machineVm.MachineId);
					}
				}
				foreach (var smVm in SelectedMachines)
				{
					smVm.CanBeUsed = newVal.Model.StateStationActivityMachines.Any(ssam => ssam.Machine.Id == smVm.MachineId);
				}
			}
			//fire event
			if (SelectedChoiceChanged != null)
				SelectedChoiceChanged(this, newVal);
		}
示例#3
0
		void Process_SelectedChoiceChanged(ProcessEditorVm processVm, ChoiceEditorVm newChoice)
		{
			if (SelectedChoiceChanged != null)
				SelectedChoiceChanged(processVm, newChoice);
		}
示例#4
0
		void activityVm_SelectedChoiceChanged(ProcessEditorVm processVm, ChoiceEditorVm newChoice) 
		{
			if (newChoice == null) return;

			if (IsTargetPointFixed)
			{
				processVm.Timing.TargetPoint = 0;
				processVm.Timing.TargetPoint = FixedTargetPoint;
			}
			else if (IsDurationFixed)
			{
				processVm.Timing.DurationSeconds = 0;
				processVm.Timing.DurationSeconds = FixedDurationSeconds;
			}
			else if (IsDeferred)
			{
				//set target point
				if (processVm.Timing.DurationSeconds > 0)
					processVm.Timing.TargetPoint = (int)(processVm.Timing.DurationSeconds / newChoice.CycleTime);
				//or set duration seconds
				else
					processVm.Timing.DurationSeconds = (int)(processVm.Timing.TargetPoint * newChoice.CycleTime);
			}
		}