private void ProvideMaterial(object o)
        {
            var po      = o as ProductionOrderFinished;
            var request = po.Message as MaterialRequest;

            if (request.Material.Name == "Table")
            {
                Logger.Log(LogLevel.Info, "Simulation: Table No: {arg} has finished", new object[] { ++MaterialCounter });
            }
            //Console.WriteLine("Time: " + TimePeriod + " Number " + MaterialCounter + " Finished: " + request.Material.Name);
            if (!request.IsHead)
            {
                var parrent = WaitingItems.Single(x => x.Id == request.Parrent);
                parrent.ChildRequests[request.Id] = true;

                // now check if item can be deployd to ReadyQueue
                if (parrent.ChildRequests.All(x => x.Value == true))
                {
                    WaitingItems.Remove(parrent);
                    ReadyItems.Enqueue(parrent);
                }
            }
            Machines.Remove(Sender);
            Machines.Add(Sender, true);


            PushWork();
        }
        /// <summary>
        /// Adds or removes machines from the machines list.
        /// </summary>
        /// <param name="machine">Machine to add or delete.</param>
        /// <param name="listChangeType">List change type.</param>
        public void ChangeMachine(Machine machine, ListChangeType listChangeType)
        {
            switch (listChangeType)
            {
            case ListChangeType.AutoAdd:
            case ListChangeType.AddByLoad:
            case ListChangeType.AddByUser:
                // If Machine already exists we don't need to do anything else here;
                if (HasMachineWithId(machine.MachineId))
                {
                    return;
                }

                Machines.Add(machine);
                break;

            case ListChangeType.RemoveByUser:
                Machines.Remove(machine);
                break;

            case ListChangeType.RemoveByEvent:
                if (machine.Services.Count == 0)
                {
                    Machines.Remove(machine);
                }
                break;
            }

            OnMachineListChanged(machine, listChangeType);
        }
        private void FileOpenJsonCommandImplementation()
        {
            var dlg = new Microsoft.Win32.OpenFileDialog()
            {
                DefaultExt = "json", AddExtension = true, Filter = "Machine JSON struct |*.json"
            };
            var b = dlg.ShowDialog();

            if (b.HasValue && b.Value)
            {
                JsonSerializer serializer = new JsonSerializer();

                serializer.NullValueHandling = NullValueHandling.Ignore;
                serializer.Converters.Add(new LinkJsonConverter());
                serializer.Converters.Add(new MachineElementJsonConverter());

                using (StreamReader sr = new StreamReader(dlg.FileName))
                    using (JsonReader reader = new JsonTextReader(sr))
                    {
                        var m = serializer.Deserialize <MD.MachineElement>(reader);

                        if (m != null)
                        {
                            Machines.Add(m);
                        }
                    }
            }
        }
Beispiel #4
0
 public void AddMachine(Machine machine)
 {
     if (Machines == null)
     {
         Machines = new List <Machine>();
     }
     Machines.Add(machine);
 }
    public void AddMachine()
    {
        Machine tmp = new Machine {
            Brand = NewMachineBrand, Type = NewMachineType, Name = NewMachineName
        };

        Machines.Add(tmp);
        NewMachineBrand = NewMachineType = NewMachineName = null;
    }
Beispiel #6
0
        public void CreateMachine()
        {
            var mch = new MachineViewModel(new Machine {
                MchCode = "#New Machine"
            });

            Machines.Add(mch);
            SelectedMachine       = Machines.LastOrDefault();
            SelectedMachine.Dirty = true;
        }
        private void TemplatesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                _machines.Add((Machine)e.NewItems[0]);
            }

            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                _machines.Remove((Machine)e.OldItems[0]);
            }
        }
 private void PushWork()
 {
     if (Machines.ContainsValue(true) && ReadyItems.Count() != 0)
     {
         var key = Machines.First(X => X.Value == true).Key;
         Machines.Remove(key);
         var m = new MachineAgent.Work(ReadyItems.Dequeue(), key);
         Machines.Add(key, false);
         _SimulationContext.Tell(m, Sender);
     }
     ;
 }
        public Task CreateMachineAsync(string schematicName, string machineId, IDictionary <string, string> metadata, CancellationToken cancellationToken)
        {
            var machineRecord = Schematics[schematicName];

            Machines.Add(machineId, Tuple.Create(new InstanceRecord
            {
                SchematicName        = schematicName,
                StateName            = machineRecord.InitialState,
                CommitTag            = Guid.NewGuid().ToString(),
                StateChangedDateTime = DateTime.UtcNow
            }, metadata));

            return(Task.CompletedTask);
        }
Beispiel #10
0
        public void AddMachine()
        {
            if (_windows.ShowDialog(IoC.Get <AddMachineViewModel>()) == true)
            {
                // TODO: Donesn't work!
                //foreach (var newMachine in _machines.Find(x => Machines.All(y => x.Id != y.Id)).ToList())
                foreach (var newMachine in _machines.FindAll().Where(x => Machines.All(y => x.Id != y.Id)).ToList())
                {
                    Machines.Add(new MachineViewModel(newMachine, _machines));
                }

                NotifyOfPropertyChange(() => Machines);
            }
        }
        public void AddMachine(string machineName, OperatingSystems operatingSystem, IEnumerable <Kpi> kpis)
        {
            var machine = new Machine(machineName);

            if (operatingSystem == OperatingSystems.Unknown)
            {
                operatingSystem = GenericScanner.GetMachineOs(machineName, User, Password, SshKeyFileName);
            }
            var scanner = ScannerFactory.GetScanner(operatingSystem);

            scanner.Persistence = Persistence;
            scanner.SetKpis(kpis);
            Machines.Add(machine, scanner);
            Log.Debug("Machine {0} added to batch {1}", machineName, Name);
        }
Beispiel #12
0
        public void ReadMachines()
        {
            if (SelectedPrintShop != null)
            {
                using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(DatabaseHelper.dbFile))
                {
                    var machines = conn.Table <Machine>().Where(m => m.PrintShopId == SelectedPrintShop.Id).ToList();

                    Machines.Clear();
                    foreach (var machine in machines)
                    {
                        Machines.Add(machine);
                    }
                }
            }
        }
        private void AddNewMachine()
        {
            Machine newMachine = new Machine();

            GetMachine(newMachine);
            // send to webservice
            ServiceRequest.Post svc = new ServiceRequest.Post();
            //svc.RequestType = "addNewUser";
            svc.PostData = newMachine;
            svc.AddNewMachine();
            // if rc = 0 then add to collection
            if (svc.Success)
            {
                Machines.Add(newMachine);
                base.OnPropertyChanged("MachineList");
            }
        }
Beispiel #14
0
        void AddNewMachine(string newMachineName)
        {
            if (string.IsNullOrEmpty(newMachineName))
            {
                return;
            }
            if (Machines.Any(m => m.MachineName == newMachineName))
            {
                return;
            }

            var newMachine = new Machine {
                MachineName = newMachineName
            };

            Machines.Add(newMachine);

            Messenger.Default.Send(new MachineAdded(newMachine));
        }
Beispiel #15
0
        //private void GetRoutesFilter()
        //{
        //    int[] listaId = { 1, 2, 3 };

        //    lstRoutes = planowanieEntity.ARIT_TRANSPORT.Where(x => listaId.Contains(x.ID_ARIT_TRANSPORT)).ToList();
        //    Routes.Clear();
        //    foreach (ARIT_TRANSPORT Item in lstRoutes)
        //    {
        //        Routes.Add(Item);
        //    }

        //}
        //public void OnMouseRightButtonUp(ARIT_TRANSPORT item)
        //{
        //    ARIT_TRANSPORT it = new ARIT_TRANSPORT();
        //}

        private void GetMachines()
        {
            lstMachines = context.IHP_MASZYNA.ToList();
            lstMachines.Clear();
            foreach (IHP_MASZYNA Item in lstMachines)
            {
                //     if (Item.WIDOCZNY == 1)
                //       {
                //        Item.NAZWA = Item.NRREJ + " (" + Item.RODZPOJAZDUSTR + ") \n" + Item.ARIT_KIEROWCY.IMIE + " " + Item.ARIT_KIEROWCY.NAZWISKO + "\n tel.: " + Item.ARIT_KIEROWCY.TELEFON + "\n Ład. Dop.: "+ Item.DOPUSZCZALNALADOWNISC.ToString();
                Machines.Add(Item);
                //       }
                //    }
                //RoutesLst.Clear();
                //foreach (ARIT_TRANSPORT Item2 in lstRoutes)
                //{
                //  Item2.NAZWARODZP = Item2.NRREJ + " (" + Item2.RODZPOJAZDUSTR + ") \n" + Item2.ARIT_KIEROWCY.IMIE + " " + Item2.ARIT_KIEROWCY.NAZWISKO + "\n tel.: " + Item2.ARIT_KIEROWCY.TELEFON + "\n Ład. Dop.: " + Item2.DOPUSZCZALNALADOWNISC.ToString();
                //    RoutesLst.Add(Item2);
                //}
            }
        }
Beispiel #16
0
        public async Task Refresh()
        {
            Status = "Searching...";
            var vms = await Task.Run(() => Check());

            foreach (var item in Machines)
            {
                item.Dispose();
            }

            Machines.Clear();
            foreach (var item in vms)
            {
                item.RunPuTTY   += () => StartPuTTY(item);
                item.RunWinSCP  += () => StartWinSCP(item);
                item.RunBrowser += () => StartBrowser(item);
                Machines.Add(item);
            }

            Status = $"{Machines.Count} devices found.";
        }
        private void LoadMachineFromFile(string fileName)
        {
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MM.MachineElement));

            using (var reader = new System.IO.StreamReader(fileName))
            {
                var m = (MM.MachineElement)serializer.Deserialize(reader);

                if (m != null)
                {
                    var vm = m.ToMachineData(true);

                    if (vm is MD.RootElement re)
                    {
                        re.AssemblyName = Path.GetFileNameWithoutExtension(fileName);
                        re.RootType     = MDE.RootType.CX220;
                    }

                    Machines.Clear();
                    Machines.Add(vm);
                }
            }
        }
        private async void DbLoadCommandImplementation()
        {
            Machines.Clear();
            SelectedItem = null;

            using (var client = new HttpClient())
            {
                var response = await client.GetAsync("https://localhost:44306/api/Machine");

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsAsync <IEnumerable <MachineInfo> >();

                    foreach (var item in content)
                    {
                        var rr = await client.GetAsync($"https://localhost:44306/api/Machine/{item.MachineElementID}");

                        if (rr.IsSuccessStatusCode)
                        {
                            var cc = await rr.Content.ReadAsAsync <MD.MachineElement>(new[]
                            {
                                new JsonMediaTypeFormatter()
                                {
                                    SerializerSettings = new JsonSerializerSettings()
                                    {
                                        Converters = new List <JsonConverter>()
                                        {
                                            new LinkJsonConverter(),
                                            new MachineElementJsonConverter()
                                        },
                                        NullValueHandling = NullValueHandling.Ignore,
                                    }
                                }
                            });

                            Machines.Add(cc);
                        }
                    }

                    //var tasks = new List<Task<MD.MachineElement>>();

                    //foreach (var item in content)
                    //{
                    //    var rr = await client.GetAsync($"https://localhost:44306/api/Machine/{item.MachineElementID}");

                    //    if (rr.IsSuccessStatusCode)
                    //    {
                    //        tasks.Add(rr.Content.ReadAsAsync<MD.MachineElement>(new[]
                    //        {
                    //            new JsonMediaTypeFormatter()
                    //            {
                    //                SerializerSettings = new JsonSerializerSettings()
                    //                {
                    //                    Converters = new List<JsonConverter>()
                    //                    {
                    //                        new LinkJsonConverter(),
                    //                        new MachineElementJsonConverter()
                    //                    },
                    //                    NullValueHandling = NullValueHandling.Ignore,
                    //                }
                    //            }
                    //        }));

                    //        //Machines.Add(cc);
                    //    }
                    //}

                    //var elements = await Task.WhenAll<MD.MachineElement>(tasks.ToArray());

                    //foreach (var item in elements) Machines.Add(item);
                }
            }
        }
Beispiel #19
0
 public override void Start()
 {
     base.Start();
     Machines.Add(this);
 }
Beispiel #20
0
 public void Add(object item)
 {
     if (item is P_Root.AnyTypeDecl)
     {
         AnyTypeDecl.Add(item as P_Root.AnyTypeDecl);
     }
     else if (item is P_Root.MachineSends)
     {
         MachineSends.Add(item as P_Root.MachineSends);
     }
     else if (item is P_Root.MachineReceives)
     {
         MachineReceives.Add(item as P_Root.MachineReceives);
     }
     else if (item is P_Root.EventSetContains)
     {
         EventSetContains.Add(item as P_Root.EventSetContains);
     }
     else if (item is P_Root.EventSetDecl)
     {
         EventSetDecl.Add(item as P_Root.EventSetDecl);
     }
     else if (item is P_Root.InterfaceDef)
     {
         InterfaceDef.Add(item as P_Root.InterfaceDef);
     }
     else if (item is P_Root.ObservesDecl)
     {
         Observes.Add(item as P_Root.ObservesDecl);
     }
     else if (item is P_Root.Annotation)
     {
         Annotations.Add(item as P_Root.Annotation);
     }
     else if (item is P_Root.DoDecl)
     {
         Dos.Add(item as P_Root.DoDecl);
     }
     else if (item is P_Root.AnonFunDecl)
     {
         AnonFunctions.Add(item as P_Root.AnonFunDecl);
     }
     else if (item is P_Root.FunDecl)
     {
         Functions.Add(item as P_Root.FunDecl);
     }
     else if (item is P_Root.TransDecl)
     {
         Transitions.Add(item as P_Root.TransDecl);
     }
     else if (item is P_Root.VarDecl)
     {
         Variables.Add(item as P_Root.VarDecl);
     }
     else if (item is P_Root.StateDecl)
     {
         States.Add(item as P_Root.StateDecl);
     }
     else if (item is P_Root.MachineDecl)
     {
         Machines.Add(item as P_Root.MachineDecl);
     }
     else if (item is P_Root.MachineCard)
     {
         MachineCards.Add(item as P_Root.MachineCard);
     }
     else if (item is P_Root.MachineKind)
     {
         MachineKinds.Add(item as P_Root.MachineKind);
     }
     else if (item is P_Root.MachineStart)
     {
         MachineStarts.Add(item as P_Root.MachineStart);
     }
     else if (item is P_Root.EventDecl)
     {
         Events.Add(item as P_Root.EventDecl);
     }
     else if (item is P_Root.EnumTypeDef)
     {
         EnumTypeDefs.Add(item as P_Root.EnumTypeDef);
     }
     else if (item is P_Root.TypeDef)
     {
         TypeDefs.Add(item as P_Root.TypeDef);
     }
     else if (item is P_Root.DependsOn)
     {
         DependsOn.Add(item as P_Root.DependsOn);
     }
     else
     {
         throw new Exception("Cannot add into the Program : " + item);
     }
 }
 private void CreateMachines(int machineNumber, long time)
 {
     Logger.Log(LogLevel.Warn, "Creating Maschine No: {arg} !", new object[] { machineNumber });
     Machines.Add(Context.ActorOf(MachineAgent.Props(_SimulationContext, time), "Maschine_" + machineNumber), true);
 }
Beispiel #22
0
        // machine1,machine2,machine3...
        public KC_Resp(DataContext DataContext, string machines)
        {
            EOP = "kc_initial";
            try
            {
                machines = machines.Replace(" ", "");
                machines = machines.ToUpper();
                string[] machineList = machines.Split(new string[] { "," }, StringSplitOptions.None);
                foreach (var str in machineList)
                {
                    var mch = DataContext.AutoCutMachine.Where(i => i.MachineName == str).FirstOrDefault();
                    if (mch == null)
                    {
                        continue;
                    }

                    string date = DateTime.Now.ToString("dd/MM/yyyy");

                    var lastInitialize = DataContext.KC_MachineInitialize
                                         .Where(i => i.AutoCutMachineId == mch.Id)
                                         .OrderByDescending(i => i.Id)
                                         .FirstOrDefault();

                    bool reset = false;

                    if (lastInitialize != null)
                    {
                        if (!(lastInitialize.UpdateTime.Day == DateTime.Now.Day &&
                              lastInitialize.UpdateTime.Month == DateTime.Now.Month &&
                              lastInitialize.UpdateTime.Year == DateTime.Now.Year))
                        {
                            if (mch.ResetCounterDate != null && DateTime.Now.DayOfWeek.ToString().Contains(mch.ResetCounterDate))
                            {
                                reset = true;
                            }

                            DataContext.KC_MachineInitialize.Add(new KC_MachineInitialize
                            {
                                UpdateTime       = DateTime.Now,
                                AutoCutMachineId = mch.Id,
                                MachineName      = str,
                                ResetCounter     = reset,
                            });
                            DataContext.SaveChanges();
                        }
                    }
                    else
                    {
                        if (mch.ResetCounterDate != null && DateTime.Now.DayOfWeek.ToString().Contains(mch.ResetCounterDate))
                        {
                            reset = true;
                        }

                        DataContext.KC_MachineInitialize.Add(new KC_MachineInitialize
                        {
                            UpdateTime       = DateTime.Now,
                            AutoCutMachineId = mch.Id,
                            MachineName      = str,
                            ResetCounter     = reset,
                        });
                        DataContext.SaveChanges();
                    }

                    Machines.Add(new Machine
                    {
                        MachineName  = str,
                        ResetCounter = reset
                    });
                }
            }
            catch (Exception ex)
            {
                CurrentTime = ex.ToString();
            }
        }
Beispiel #23
0
        public void Add(object item)
        {
            if (IgnoreDecl)
            {
                return;
            }

            else if (item is P_Root.MachineSends)
            {
                MachineSends.Add(item as P_Root.MachineSends);
            }
            else if (item is P_Root.MachineReceives)
            {
                MachineReceives.Add(item as P_Root.MachineReceives);
            }
            else if (item is P_Root.MachineProtoDecl)
            {
                MachineProtoDecls.Add(item as P_Root.MachineProtoDecl);
            }
            else if (item is P_Root.FunProtoDecl)
            {
                FunProtoDecls.Add(item as P_Root.FunProtoDecl);
            }
            else if (item is P_Root.MachineExports)
            {
                MachineExports.Add(item as P_Root.MachineExports);
            }
            else if (item is P_Root.EventSetContains)
            {
                EventSetContains.Add(item as P_Root.EventSetContains);
            }
            else if (item is P_Root.EventSetDecl)
            {
                EventSetDecl.Add(item as P_Root.EventSetDecl);
            }
            else if (item is P_Root.InterfaceTypeDef)
            {
                InterfaceTypeDef.Add(item as P_Root.InterfaceTypeDef);
            }
            else if (item is P_Root.ObservesDecl)
            {
                Observes.Add(item as P_Root.ObservesDecl);
            }
            else if (item is P_Root.Annotation)
            {
                Annotations.Add(item as P_Root.Annotation);
            }
            else if (item is P_Root.DoDecl)
            {
                Dos.Add(item as P_Root.DoDecl);
            }
            else if (item is P_Root.AnonFunDecl)
            {
                AnonFunctions.Add(item as P_Root.AnonFunDecl);
            }
            else if (item is P_Root.FunDecl)
            {
                Functions.Add(item as P_Root.FunDecl);
            }
            else if (item is P_Root.TransDecl)
            {
                Transitions.Add(item as P_Root.TransDecl);
            }
            else if (item is P_Root.VarDecl)
            {
                Variables.Add(item as P_Root.VarDecl);
            }
            else if (item is P_Root.StateDecl)
            {
                States.Add(item as P_Root.StateDecl);
            }
            else if (item is P_Root.MachineDecl)
            {
                Machines.Add(item as P_Root.MachineDecl);
            }
            else if (item is P_Root.EventDecl)
            {
                Events.Add(item as P_Root.EventDecl);
            }
            else if (item is P_Root.ModelType)
            {
                ModelTypes.Add(item as P_Root.ModelType);
            }
            else if (item is P_Root.EnumTypeDef)
            {
                EnumTypeDefs.Add(item as P_Root.EnumTypeDef);
            }
            else if (item is P_Root.TypeDef)
            {
                TypeDefs.Add(item as P_Root.TypeDef);
            }
            else if (item is P_Root.DependsOn)
            {
                DependsOn.Add(item as P_Root.DependsOn);
            }
            else if (item is P_Root.FunProtoCreatesDecl)
            {
                FunProtoCreates.Add(item as P_Root.FunProtoCreatesDecl);
            }
            else
            {
                throw new Exception("Cannot add into the Program : " + item.ToString());
            }
        }
 private void CreateMachines(int machineNumber, long time)
 {
     Machines.Add(Context.ActorOf(MachineAgent.Props(_SimulationContext, time), "Maschine_" + machineNumber), true);
 }