Exemple #1
0
        static void ConfigureUser()
        {
            var person = PersonBuilder
                         .Person()
                         .WithFirstName("Max")
                         .WithLastName("Planc")
                         .WithPrimaryContact(new EmailAdress("*****@*****.**"))
                         .WithSecondaryContact(new EmailAdress("*****@*****.**"))
                         .AndNoMoreContacts()
                         .Build();

            // builder.SetPrimaryContact(email);
            Console.WriteLine(person);

            IUserFactory  factory = new PersonFactory();
            IUser         user    = factory.CreateUser("Max", "Planck");
            IUserIdentity id      = factory.CreateIdentity();

            user.SetIdentity(id);

            var factoryM = new MachineFactory(
                new System.Collections.Generic.Dictionary <string, Producer>
            {
                ["pc"] = new Producer()
            });
            var machine = factoryM.CreateUser("pc", "1000");
            var id2     = factoryM.CreateIdentity();

            machine.SetIdentity(id2);
        }
    public List <Machine> reScanMachines()
    {
        CurrentContext.Validate();
        var ips = NetworkScanner.GetAllMAchines();

        foreach (int i in ips.Keys)
        {
            var ip = ips[i];
            if (string.IsNullOrEmpty(ip.Name))
            {
                continue;
            }
            var m = MachineFactory.Find(ip.Name.ToUpper());
            if (m != null)
            {
                bool bchange = false;
                if (m.IP != ip.IpAddress)
                {
                    m.IP    = ip.IpAddress;
                    bchange = true;
                }
                if (m.MAC != ip.MacAddress)
                {
                    m.MAC   = ip.MacAddress;
                    bchange = true;
                }
                if (bchange)
                {
                    MachineFactory.Update(m);
                }
            }
        }
        return(getMachines());
    }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            //AmountRpt amountRpt = MachineFactory.Machine.QueryAmount();
            //if (amountRpt != null)
            //{
            //    MessageBox.Show(amountRpt.Amount.ToString());
            //}
            //else
            //{
            //    MessageBox.Show("无");
            //}
            string        com     = "COM3";
            IMachine      machine = MachineFactory.GetMachine(com);
            OperateResult result  = machine.Shipment(1, 2, 3, false, 0, false);

            if (result.Success)
            {
                MessageBox.Show("成功");
            }
            else
            {
                MessageBox.Show(result.ErrorMsg);
            }
            //machine.RefundMoney(100);
            //machine.ClearAmount();
        }
Exemple #4
0
        public void CreateMachines()
        {
            MachineFactory mfact = new MachineFactory();

            mfact.CreateMachines();
            Console.Read();
        }
Exemple #5
0
        /// <summary>
        ///  Create machines using <c>MachineFactory</c> class. And assign to property named 'machines' list. 'machines' is a <c>List<IMachineBase></c> type.
        /// </summary>
        void CreateMachines()
        {
            MachineFactory machineFactory = new MachineFactory();

            machineFactory.CreateMachines();
            this.machines = machineFactory.Machines.ToList();
        }
        static void Main(string[] args)
        {
            var machineFactory = new MachineFactory();

            var client = new MachineClient(machineFactory);

            client.PutMachineToWorkAndStop();
        }
Exemple #7
0
 private void Form1_Load(object sender, EventArgs e)
 {
     new Thread(new ThreadStart(delegate()
     {
         MachineFactory.Init();
         OpenWCFServer();
     })).Start();
 }
        /// <summary>
        ///  Create machines using <c>MachineFactory</c> class. And assign to property named 'machines' list.
        ///  'machines' is either LCM or UCM type.
        /// </summary>
        void CreateMachines()
        {
            MachineFactory machineFactory = new MachineFactory();

            machineFactory.CreateMachines();
            this.lcmmachines = machineFactory.LCMs.ToList();
            this.ucmmachines = machineFactory.UCMs.ToList();
        }
Exemple #9
0
        static void Main()
        {
            IPilotFactory    pilotFactory    = new PilotFactory();
            IMachineFactory  machineFactory  = new MachineFactory();
            IMachinesManager machinesManager = new MachinesManager(machineFactory, pilotFactory);
            IEngine          engine          = new Engine(machinesManager, pilotFactory, machineFactory);

            engine.Run();
        }
    public void scanMachine(string m)
    {
        CurrentContext.Validate();
        try
        {
            Machine ma    = MachineFactory.FindOrCreate(m);
            string  scope = string.Format("\\\\{0}\\root\\CIMV2", ma.PCNAME);
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, "SELECT * FROM Win32_NetworkAdapterConfiguration");
            string newmac     = "";
            string sIPAddress = "";
            foreach (ManagementObject queryObj in searcher.Get())
            {
                object o   = queryObj["MACAddress"];
                object cap = queryObj["Caption"];
                if (o == null || cap == null || cap.ToString().ToUpper().Contains("VIRTUALBOX"))
                {
                    continue;
                }
                if (string.IsNullOrEmpty(newmac))
                {
                    newmac = o.ToString().Replace(":", "");
                }
                else
                {
                    newmac += " " + o.ToString().Replace(":", "");
                }

                string[] arrIPAddress = (string[])(queryObj["IPAddress"]);
                if (arrIPAddress != null)
                {
                    sIPAddress = arrIPAddress.FirstOrDefault(s => s.Contains('.'));
                    if (!string.IsNullOrEmpty(sIPAddress))
                    {
                        ma.IP = sIPAddress;
                    }
                }
            }

            var cpu = new ManagementObjectSearcher(scope, "select * from Win32_Processor").Get().Cast <ManagementObject>().First();
            var wmi = new ManagementObjectSearcher(scope, "select * from Win32_OperatingSystem").Get().Cast <ManagementObject>().First();
            if (!string.IsNullOrEmpty(newmac))
            {
                int memory = Convert.ToInt32(wmi["TotalVisibleMemorySize"]) / 1024;
                ma.DETAILS = wmi["Caption"].ToString() + "<br/>" + cpu["Name"].ToString() + "<br/>" + memory.ToString() + "Mb";
                ma.MAC     = newmac;
                MachineFactory.Update(ma);
            }
        }
        catch (Exception e)
        {
            Logger.Log(e);
        }
    }
    public void catMachine(string m, string category)
    {
        if (string.IsNullOrEmpty(m))
        {
            return;
        }
        CurrentContext.Validate();
        Machine ms = MachineFactory.FindOrCreate(m);

        ms.CATEGORY = category;
        MachineFactory.Update(ms);
    }
    public void shutMachine(string m)
    {
        CurrentContext.Validate();
        Machine ma      = MachineFactory.FindOrCreate(m);
        Process process = new Process();

        process.StartInfo.RedirectStandardOutput = true;
        process.StartInfo.UseShellExecute        = false;
        process.StartInfo.CreateNoWindow         = true;
        process.StartInfo.FileName  = "shutdown";
        process.StartInfo.Arguments = string.Format(@"/s /m \\{0} /t 0", ma.PCNAME);
        process.Start();
    }
Exemple #13
0
        public static void Main()
        {
            IPilotRepository   pilotRepository   = new PilotRepository();
            IMachineRepository machineRepository = new MachineRepository();
            IPilotFactory      pilotFactory      = new PilotFactory();
            IMachineFactory    machineFactory    = new MachineFactory();

            IMachinesManager machinesManager = new MachinesManager(pilotRepository, machineRepository, pilotFactory, machineFactory);

            ICommandInterpreter commandInterpreter = new CommandInterpreter(machinesManager);
            IEngine             engine             = new Engine(commandInterpreter);

            engine.Run();
        }
Exemple #14
0
        private void BtnStart_Click(object sender, EventArgs e)
        {
            //IMachine computer = new Computer();

            string instance = "laptop";

            //IMachine machine = GetInstance(instance);

            IMachine machine = new MachineFactory().CreatInstance(instance);

            TxtName.Text    = machine.Name;
            TxtTurnOn.Text  = machine.TurnOn();
            TxtTurnOff.Text = machine.TurnOff();
        }
        internal void OnEnable()
        {
            if (!followCamera)
            {
                Debug.LogError("no camera found");
                return;
            }
            FileTools.Start();
            //LuaManager.Init();
            //new Lua_Starter(() => { Debug.Log("lua init complete"); }).Start();
            GameObject o = GameObject.Find("HudCanvas");

            if (o)
            {
                HudManager.panel = o.GetComponent <RectTransform>();
            }
            _hostEntity = new TestHost(gameObject, speed);
            _hostEntity.Initialize();
            MachineWrap.Init();
            TreeWrap.Init();
            string stream = FileTools.wwwStreamingAssetsPath;

            if (string.IsNullOrEmpty(stream))
            {
                return;
            }
            CpxRetriever r = new CpxRetriever {
                actionRetriever    = CpxMachineFactory.GetAction,
                stateRetriever     = CpxMachineFactory.GetState,
                conditionRetriever = CpxMachineFactory.GetCondition
            };

            MachineFactory.Start();
            MachineChart  m    = MachineFileManager.Load(AssetDatabase.GetAssetPath(machineFile));
            CpxController ctrl = new ChartToMachine().Transfer(m, r);

            _hostEntity.runtimeController.Inititalize(ctrl);
            TreeEditorFactory.Start();
            _fireSettings = new FireFxRoot[_fxAssets.Length];
            for (int i = 0, len = _fireSettings.Length; i < len; i++)
            {
                _fireSettings[i] = GetFireSetting(_fxAssets[i]);
            }
        }
Exemple #16
0
        /// <summary>
        /// 货柜信息
        /// </summary>
        /// <param name="com">货柜串口号</param>
        /// <param name="box">货柜号</param>
        public BoxRpt BoxInfo(string com, int box)
        {
            BoxRpt boxRpt;

            try
            {
                IMachine machine = MachineFactory.GetMachine(com);
                boxRpt = machine.BoxInfo(box);
            }
            catch (Exception ex)
            {
                boxRpt          = new BoxRpt();
                boxRpt.HasError = true;
                boxRpt.ErrorMsg = ex.Message;
                FileLogger.LogError("获取货柜信息失败" + ex.Message);
            }

            return(boxRpt);
        }
Exemple #17
0
        /// <summary>
        /// 出货
        /// </summary>
        /// <param name="com">串口号</param>
        /// <param name="box">货柜</param>
        /// <param name="floor">货道层</param>
        /// <param name="num">货道列</param>
        /// <param name="cash">是否现金支付</param>
        /// <param name="cost">金额(单位:分)</param>
        /// <param name="check">是否掉货检测</param>
        public OperateResult Shipment(string com, int box, int floor, int num, bool cash, int cost, bool check)
        {
            OperateResult operateResult;

            try
            {
                IMachine machine = MachineFactory.GetMachine(com);
                operateResult = machine.Shipment(box, floor, num, cash, cost, check);
            }
            catch (Exception ex)
            {
                operateResult          = new OperateResult();
                operateResult.Success  = false;
                operateResult.ErrorMsg = ex.Message;
                FileLogger.LogError("出货失败" + ex.Message);
            }

            return(operateResult);
        }
Exemple #18
0
        /// <summary>
        /// 查询单个货道信息
        /// </summary>
        public RoadRpt QueryRoadRpt(string com, int box, int floor, int num)
        {
            RoadRpt roadRpt;

            try
            {
                IMachine machine = MachineFactory.GetMachine(com);
                roadRpt = machine.QueryRoadRpt(box, floor, num);
            }
            catch (Exception ex)
            {
                roadRpt          = new RoadRpt();
                roadRpt.IsOK     = false;
                roadRpt.ErrorMsg = ex.Message;
                FileLogger.LogError("查询单个货道信息失败" + ex.Message);
            }

            return(roadRpt);
        }
Exemple #19
0
        public SimulationController(RunConfiguration configuration)
        {
            CurrentConfiguration   = configuration;
            MachineTableObject     = new MachineTable();
            UtilizationTable       = new UtilizationTable();
            AccountingModuleObject = new AccountingModule(MachineTableObject, UtilizationTable,
                                                          CurrentConfiguration);
            _networkSwitchObject = new NetworkSwitch(MachineTableObject, AccountingModuleObject, configuration.NetworkDealy);

            MachineControllerObject
                = new MachineController(UtilizationTable, MachineTableObject, CurrentConfiguration.ContainersType);
            _masterFactory
                = new MasterFactory(_networkSwitchObject, MachineControllerObject, UtilizationTable,
                                    CurrentConfiguration.Strategy, CurrentConfiguration.PushAuctionType, CurrentConfiguration.PullAuctionType, CurrentConfiguration.SchedulingAlgorithm, CurrentConfiguration.TestedHosts);
            var h = new Load(Global.DataCenterHostConfiguration);

            _hostFactory = new HostFactory(h,
                                           _networkSwitchObject, CurrentConfiguration.LoadPrediction, CurrentConfiguration.Strategy, CurrentConfiguration.ContainersType, configuration.SimulationSize);
            _registryFactory  = new RegistryFactory(_networkSwitchObject, configuration.SimulationSize);
            _containerFactory = new ContainerFactory(CurrentConfiguration.ContainersType, configuration.SimulationSize, configuration.LoadPrediction);
        }
    public void wakeMachine(string m)
    {
        CurrentContext.Validate();
        Machine mach = MachineFactory.FindOrCreate(m);

        if (string.IsNullOrEmpty(mach.MAC))
        {
            return;
        }
        string[] macs = mach.MAC.Split(' ');
        foreach (var mac in macs)
        {
            Process process = new Process();
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.FileName  = HttpRuntime.AppDomainAppPath + "bin\\WolCmd.exe";
            process.StartInfo.Arguments = mac + " 192.168.0.1 255.255.255.0 3";
            process.Start();
        }
    }
Exemple #21
0
    public Simulation()
    {
        Floor = new Floor(this, floorWidth, floorHeight);
        machineFactory = new MachineFactory(this);
        supplyContractFactory = new ContractFactory(false);
        deliveryContractFactory = new ContractFactory(true);

        //Populate machine shop
        for(int i = 0; i < machineShopSizeLimit; i++)
        {
            MachineShop.Add (machineFactory.GetMachineForShop());
        }

        //Populate contracts
        for(int i = 0; i < contractShopSizeLimit; i++)
        {
            SupplyShop.Add(supplyContractFactory.GetContractForShop());
            DeliveryShop.Add(deliveryContractFactory.GetContractForShop());
        }

        //Create contract slots
        Vector2[] slotPositions = new Vector2[]
        {
            new Vector2(1, -0.666f),
            new Vector2(3, -0.666f),
            new Vector2(5, -0.666f),
            new Vector2(7, -0.666f),
            new Vector2(1, 8.666f),
            new Vector2(3, 8.666f),
            new Vector2(5, 8.666f),
            new Vector2(7, 8.666f)
        };
        for (int i = 0; i < contractSlotLimit; i++)
        {
            ContractSlot slot = new ContractSlot();
            slot.FloorPosition = slotPositions[i];
            ContractSlots.Add(slot);
        }
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="MachineTestingRuntime"/> class.
        /// </summary>
        internal MachineTestingRuntime(Type machineType, Configuration configuration)
            : base(configuration)
        {
            if (!machineType.IsSubclassOf(typeof(Machine)))
            {
                this.Assert(false, "Type '{0}' is not a machine.", machineType.FullName);
            }

            var mid = new MachineId(machineType, null, this);

            this.Machine = MachineFactory.Create(machineType);
            IMachineStateManager stateManager = new MachineStateManager(this, this.Machine, Guid.Empty);
            this.MachineInbox = new EventQueue(stateManager);

            this.Machine.Initialize(this, mid, stateManager, this.MachineInbox);
            this.Machine.InitializeStateInformation();

            this.Logger.OnCreateMachine(this.Machine.Id, null);

            this.MachineMap.TryAdd(mid, this.Machine);

            this.IsMachineWaitingToReceiveEvent = false;
        }
 public void remMachine(string m)
 {
     CurrentContext.Validate();
     MachineFactory.Delete(m);
 }
 public List <Machine> getMachines()
 {
     CurrentContext.Validate();
     return(MachineFactory.Enum());
 }
Exemple #25
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public SandwichMachineTest()
 {
     machine = MachineFactory.CreateAndReturn(MachineImplementations.Patient);
 }