예제 #1
0
 public Computer(Memory memory)
 {
     _memory = memory;
     _jumpTo = -1;
     _entity = InstructionEntity.NoInstruction;
     _index  = 0;
 }
예제 #2
0
        public State Run(bool debug = false)
        {
            Debug = debug;
            if (debug)
            {
                _memory.SetDebugMode();
            }
            while (_entity.Instruction != Instruction.Terminate)
            {
                _entity = GetInstruction(_index);
                if (debug)
                {
                    WriteLine($"Executing {_entity.Instruction} [{_index}]");
                }

                if (!_entity.Execute())
                {
                    return(State.WaitingForInput);
                }

                if (_jumpTo >= 0)
                {
                    _index  = _jumpTo;
                    _jumpTo = -1;
                }
                else
                {
                    _index += _entity.Step;
                }
            }

            return(State.Finished);
        }
예제 #3
0
 public Computer(Memory memory, Robot robot)
 {
     _robot  = robot;
     _memory = memory;
     _jumpTo = -1;
     _entity = InstructionEntity.NoInstruction;
     _index  = 0;
 }
예제 #4
0
 public Computer(Memory memory, IConnector connector)
 {
     _connector = connector;
     _memory    = memory;
     _jumpTo    = -1;
     _entity    = InstructionEntity.NoInstruction;
     _index     = 0;
 }
예제 #5
0
 public Computer(Memory memory, Arcade arcade)
 {
     _arcade = arcade;
     _memory = memory;
     _jumpTo = -1;
     _entity = InstructionEntity.NoInstruction;
     _index  = 0;
 }
예제 #6
0
 public static InstructionViewModel ToModel(this InstructionEntity entity)
 {
     return(new InstructionViewModel()
     {
         Id = entity.Id,
         Name = entity.Name,
         Description = entity.Description,
         IsSupported = entity.IsSupported
     });
 }
예제 #7
0
        private void RefreshInstructionItem(DataRow row, ref bool needRefreshAdd, ref bool needRefreshCancel)
        {
            var type                = row["inst_type"].ToString().Trim();
            var clientID            = row["client_id"].ToString().Trim();;
            InstructionEntity order = null;

            if (type == "O")
            {
                if (AddInstructionDict.ContainsKey(clientID))
                {
                    order = AddInstructionDict[clientID];
                }
                else
                {
                    order = new InstructionEntity()
                    {
                        ClientId = clientID
                    };
                    AddInstructionDict[clientID] = order;
                    needRefreshAdd = true;
                }
            }
            else if (type == "C")//撤单命令,以订单号为key
            {
                if (CancelInstructionDict.ContainsKey(clientID))
                {
                    order = CancelInstructionDict[clientID];
                }
                else
                {
                    order = new InstructionEntity()
                    {
                        ClientId = clientID
                    };
                    CancelInstructionDict[clientID] = order;
                    needRefreshCancel = true;
                }
            }
            order.OrderNo   = row["ord_no"].ToString();
            order.InstType  = row["inst_type"].ToString();
            order.AcctType  = row["acct_type"].ToString();
            order.Acct      = row["acct"].ToString();
            order.Symbol    = row["symbol"].ToString();
            order.TradeSide = row["tradeside"].ToString();

            order.OrdQty   = int.Parse(row["ord_qty"].ToString());
            order.OrdPrice = decimal.Parse(row["ord_price"].ToString());
            order.OrdType  = row["ord_type"].ToString();
            order.OrdParam = row["ord_param"].ToString();
        }
예제 #8
0
        public void RunOneInstruction()
        {
            _entity = GetInstruction(_index);
            if (!_entity.Execute())
            {
                return;
            }

            if (_jumpTo >= 0)
            {
                _index  = _jumpTo;
                _jumpTo = -1;
            }
            else
            {
                _index += _entity.Step;
            }
        }
예제 #9
0
        public State Run(int maxInstructionCount = 0, bool debug = false)
        {
            _maxInstructionCount = maxInstructionCount;
            checked
            {
                Debug = debug;
                if (debug)
                {
                    _memory.SetDebugMode();
                }
                while (_entity.Instruction != Instruction.Terminate && !_requestTermination)
                {
                    _entity = GetInstruction(_index);
                    if (debug)
                    {
                        WriteLine($"Executing {_entity.Instruction} [{_index}]");
                    }

                    if (!_entity.Execute())
                    {
                        return(State.WaitingForInput);
                    }
                    _currentInstructionCount++;

                    if (_jumpTo >= 0)
                    {
                        _index  = _jumpTo;
                        _jumpTo = -1;
                    }
                    else
                    {
                        _index += _entity.Step;
                    }

                    if (_maxInstructionCount > 0 && _currentInstructionCount >= _maxInstructionCount)
                    {
                        _currentInstructionCount = 0;
                        return(State.FinishedInstructionChunk);
                    }
                }
            }
            return(State.Terminated);
        }
예제 #10
0
        public State Run(bool debug = false)
        {
            DebugHash = new HashSet <EntityDebug>();
            checked {
                Debug = debug;
                if (debug)
                {
                    _memory.SetDebugMode();
                }
                while (_entity.Instruction != Instruction.Terminate && !_requestTermination)
                {
                    _entity = GetInstruction(_index);
                    if (debug)
                    {
                        WriteLine($"Executing {_entity.Instruction} [{_index}]");
                    }

                    var entityDebug = new EntityDebug {
                        Instruction = _entity.Instruction, ParameterModes = _entity.ParameterModes?.ToArray() ?? Enumerable.Empty <ParameterMode>().ToArray()
                    };
                    if (!DebugHash.Contains(entityDebug))
                    {
                        DebugHash.Add(entityDebug);
                    }

                    if (!_entity.Execute())
                    {
                        return(State.WaitingForInput);
                    }

                    if (_jumpTo >= 0)
                    {
                        _index  = _jumpTo;
                        _jumpTo = -1;
                    }
                    else
                    {
                        _index += _entity.Step;
                    }
                }
            }
            return(State.Finished);
        }
예제 #11
0
        public Task <int> SubmitForm(InstructionEntity entity, string keyValue)
        {
            var claimsIdentity = _httpContext.HttpContext.User.Identity as ClaimsIdentity;

            claimsIdentity.CheckArgumentIsNull(nameof(claimsIdentity));
            var claim = claimsIdentity?.FindFirst(t => t.Type == ClaimTypes.NameIdentifier);

            if (!string.IsNullOrEmpty(keyValue))
            {
                entity.Modify(keyValue);
                entity.F_LastModifyUserId = claim?.Value;
                return(_service.UpdateAsync(entity));
            }
            else
            {
                entity.Create();
                entity.F_CreatorUserId = claim?.Value;
                return(_service.InsertAsync(entity));
            }
        }
        public async Task <IActionResult> SavePics(IFormFile reportFile, int id)
        {
            var serialNo   = Common.CreateNo();
            var targetPath = Path.Combine(AppConsts.AppRootPath, "GuideInstruction");

            FileHelper.CreateDirectory(targetPath);
            var fileName      = reportFile.FileName /*Path.Combine(targetPath, serialNo + Path.GetExtension(reportFile.FileName))*/;
            var fileExtension = Path.GetExtension(reportFile.FileName);//.TrimStart('.').ToUpper();
            var fileSize      = reportFile.Length;

            //var fileName = Path.Combine(targetPath, serialNo + Path.GetExtension(reportFile.FileName));
            using (var stream =
                       new FileStream(Path.Combine(targetPath, serialNo + fileExtension), FileMode.Create))
            {
                await reportFile.CopyToAsync(stream);

                stream.Flush();
            }

            var pathUrl = Path.Combine(targetPath, serialNo + fileExtension).Replace(AppConsts.AppRootPath, "")
                          .Replace("\\", "/").TrimStart('/');
            var instruction = new InstructionEntity
            {
                F_FileIndex       = serialNo + fileExtension,
                F_FileSize        = FileHelper.ToFileSize(fileSize),
                F_InstructionName = fileName,
                F_FileType        = fileExtension.TrimStart('.'),
                F_FilePath        = pathUrl,//Path.Combine(targetPath, serialNo + fileExtension),
                F_UploadDate      = DateTime.Now,
                F_EnabledMark     = true,
                F_UploadPerson    = ""
            };
            await _instructionApp.SubmitForm(instruction, null);

            var data = new
            {
                pathUrl
            };

            return(Success(data.ToJson()));
        }
예제 #13
0
 public Task <int> UpdateForm(InstructionEntity entity, bool isPartial = false)
 {
     return(_service.UpdateAsync(entity, isPartial));
 }