Пример #1
0
		/// <summary>
		/// Updates the Machines list of Toolbox according to specified stateStation
		/// </summary>
		/// <param name="ss"></param>
		public void OnStationSelected(StateStationVm ss)
		{
			MachineFamilies.Clear();
			if (ss == null) return;
			if (ShowAllMachines)
			{
				foreach (var mf in _allMachineFamilies)
				{
					MachineFamilies.Add(mf);
				}
			}
			else
			{
				foreach (var item in (ss.Containment as StationVm).StationMachines)
				{
					//find existing family
					var family = MachineFamilies.FirstOrDefault(x => x.Id == item.Machine.Family.Id);

					//if family is not yet added, clear its machines and then add it
					if (family == null)
					{
						family = item.Machine.Family;
						family.Machines.Clear();
						MachineFamilies.Add(family);
					}

					//make sure the machine exists in that family
					if (!family.Machines.Any(x => x.Id == item.Machine.Id))
					{
						family.Machines.Add(item.Machine);
					}
				}
			}
		}
Пример #2
0
		/// <summary>
		/// Creates an instance of StateVm from the given model
		/// </summary>
		/// <param name="model">Must be full of data</param>
		/// <param name="parentWindowVm">parent window vm</param>
		/// <param name="isPlaced">a value that indicates whether this state is officially a part of its fpc</param>
		public StateVm(Model.State model, FpcWindowVm parentWindowVm, bool isPlaced = true)
		{
			InitializingPhase = true;
			ParentWindowVm = parentWindowVm;
			IsPlaced = isPlaced;
			if (isPlaced) { IsFixed = model.StateStations.Any(ss => ss.Blocks.Any()); }

			initCommands();

			//fetch from db and update state basics
			Model = model;
			Name = Model.Name;
			Code = Model.Code;
			if (StateType == Common.StateType.Mid || StateType == Common.StateType.Rework)
				if (Model.OnProductRework != null)
					ProductRework = ParentWindowVm.ProductReworks.FirstOrDefault(x => x.Id == Model.OnProductRework.Id);
			Location = new Vector(model.X, model.Y);


			//fetch from db and update state config
			Config = new StateConfigVm(this);
			foreach (var ss in Model.StateStations)
			{
				var stateStation = new StateStationVm(ParentWindowVm, ss)
				{
					Container = Config,
					Containment = new StationVm(ss.Station),
				};
				foreach (var ssa in ss.StateStationActivities)
				{
					var stateStationActivity = new StateStationActivityVm(ParentWindowVm, ssa)
					{
						Container = stateStation,
						ManHour = ssa.ManHour,
						CycleTime = ssa.CycleTime,
						IsMany = ssa.IsMany,
						Containment = new ActivityVm(ssa.Activity, null),
						//CreatedDate
						//ModifiedBy
						//ModifiedDate
						//Status
					};
					foreach (var ssam in ssa.StateStationActivityMachines)
					{
						stateStationActivity.ContentsList.Add(new StateStationActivityMachineVm(ParentWindowVm, ssam)
						{
							Container = stateStationActivity,
							Containment = new MachineVm(ssam.Machine, null),
							IsDefault = ssam.IsFixed,
						});
					}
					stateStation.ContentsList.Add(stateStationActivity);
				}
				Config.ContentsList.Add(stateStation);
			}
		}