Exemple #1
0
        public async void Request()
        {
            if (!IsComplete)
            {
                return;
            }
            await Task.Run(() => {
                IsComplete = false;
                try
                {
                    bool res = IsGenerateAction();

                    if (res)
                    {
                        Thread.Sleep(1000);
                        object time = null, x = null, y = null, l_y = null, z = null, l_z = null, wgt = null, l_wgt = null, symbol = null,
                        count       = null, cNum = null;

                        time   = ACTION_TIME == null ? null : Operator.Read(ACTION_TIME);
                        x      = ACTION_X == null?null: Operator.Read(ACTION_X);
                        y      = ACTION_Y == null ? null : Operator.Read(ACTION_Y);
                        l_y    = ACTION_LITTLE_Y == null ? null : Operator.Read(ACTION_LITTLE_Y);
                        z      = ACTION_Z == null ? null : Operator.Read(ACTION_Z);
                        l_z    = ACTION_LITTLE_Z == null ? null : Operator.Read(ACTION_LITTLE_Z);
                        wgt    = ACTION_WEIGHT == null ? null : Operator.Read(ACTION_WEIGHT);
                        l_wgt  = ACTION_LITTLE_WEIGHT == null ? null : Operator.Read(ACTION_LITTLE_WEIGHT);
                        symbol = ACTION_SYMBOL == null ? null : Operator.Read(ACTION_SYMBOL);
                        count  = ACTION_OBJ_COUNT == null ? null : Operator.Read(ACTION_OBJ_COUNT);
                        cNum   = ACTION_CACHE_NUM == null ? null : Operator.Read(ACTION_CACHE_NUM);


                        int result = dC_Service.InsertAction(Cra_ID, time, x, y, l_y, z, l_z, wgt, l_wgt, symbol, count, cNum);
                        if (result == 1)
                        {
                            Operator.Write(ACTION_READED_NUM, cNum);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.WriteLog(E_ProcessLogType.Error, $"读取动作异常。cra:{Cra_ID}。" + ex.Message + ex.StackTrace);
                }
                finally
                {
                    IsComplete = true;
                }
            });
        }