Пример #1
0
    public void TestMCSUniqueness()
    {
        Dictionary <TagEPCURI_SGTIN, int> TIDmap = new Dictionary <TagEPCURI_SGTIN, int>();

        for (int index = 0; index < _NumTags - 1; index++)
        {
            object          tag  = _Reader.SingulateTagAssisted(index);
            TagEPCURI_SGTIN epc  = default(TagEPCURI_SGTIN);
            taginfo         info = _TagInfos[index];
            TID             tid  = default(TID);

            Console.WriteLine("Testing tag at position {0}", index);

            DecodeError res0 = default(DecodeError);
            res0 = _Reader.ReadTID(tag, out tid);
            Assert.AreEqual(res0, DecodeError.None);

            res0 = _Reader.ReadEPC_SGTIN(tag, out epc);
            Assert.AreEqual(res0, DecodeError.None);

            Console.WriteLine("Generating serial via MCS");

            bool            resB = false;
            TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN);
            resB = MCS.GenerateEPC(ref tid, ref epc, out epc1);
            Assert.AreEqual(resB, true);

            // there should not be any equal values
            Assert.AreEqual(false, TIDmap.ContainsKey(epc1));
            TIDmap.Add(epc1, index);
        }
    }
        private string type; //"cit" or "com"
        public ViewTransactions(string n, int id)
        {
            ID   = id;
            name = n;
            InitializeComponent();
            DataTable dt = controllerObj.SelectAllCompanies();

            Company.DataSource    = dt;
            Company.DisplayMember = "Name";
            Company.ValueMember   = "CID";
            Company.SelectedIndex = -1;
            From.SelectedIndex    = -1;
            Citizen.Enabled       = false;
            Company.Enabled       = false;
            if (ID != 0)
            {
                Edit.Hide();
                Delete.Hide();
                TID.Hide();
            }
            comboBox_Bank.SelectedIndex = -1;
            if (ID != 0 && ID != -1)
            {
                Add.Visible = false;
            }
        }
Пример #3
0
    public void UpdateTemplate()
    {
        if (SessionBox.GetUserSession().Role.Contains("矿级管理员"))
        {
            rKuangJi.Enabled = true;
            rKuangJi.Checked = true;
        }
        else
        {
            rKuangJi.Enabled = false;
            rGeRen.Checked   = true;
        }
        RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel;

        if (sm.SelectedRows.Count > 0)
        {
            TID.SetValue(sm.SelectedRows[0].RecordID.Trim());
            txtTName.Text = "";
            Window1.Show();
        }
        else
        {
            Ext.Msg.Alert("提示", "请选择要修改的模板!").Show();
        }
    }
Пример #4
0
        /// <summary>
        /// Gets the run env.
        /// </summary>
        /// <returns>The run env.</returns>
        /// <param name="tid">Tid.</param>
        public RunEnv GetRunEnv(TID tid)
        {
            RunEnv env = null;

            tid2EnvDict.TryGetValue(tid, out env);
            return(env);
        }
Пример #5
0
        public bool Init()
        {
            bool result = true;

            this.Name = this.template.name.Str;

            if (this.template.services != null)
            {
                for (int i = 0; i < this.template.services.Length; ++i)
                {
                    TID tid = this.template.services[i];
                    if (tid != TID.None)
                    {
                        GameService service = App.TemplateMgr.CreateObject(tid) as GameService;
                        if (service != null)
                        {
                            service.Init(this);
                            this.services.Add(service);
                        }
                    }
                }
            }

            this.runServices.AddRange(services);
            this.curFrameTick        = System.Environment.TickCount;
            this.lastFrameTick       = System.Environment.TickCount;
            this.logicTick           = 0;
            this.lastFixedUpdateTick = System.Environment.TickCount;

            return(result);
        }
Пример #6
0
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                if (reader.TokenType == JsonToken.Null)
                {
                    return(null !);
                }

                TID id = (TID)_idConverter.ReadJson(reader, typeof(TID), null, serializer);

                return(Ref.FromIdentifier <TTarget, TID>(id));
            }
Пример #7
0
        public T CreateObject <T>(TID tid) where T : EnvObject
        {
            T ret = CreateObject(tid) as T;

            if (ret == null)
            {
                Logger.Error("CreateObject failed: " + tid);
                return(null);
            }

            return(ret);
        }
Пример #8
0
        public byte[] Serialize()
        {
            var bytes = new List <byte>();

            bytes.AddRange(Etag.ToBytes(24));
            bytes.AddRange(Station.ToBytes());
            bytes.AddRange(Lane.ToBytes());
            bytes.AddRange(Plate.ToBytes(10));
            bytes.AddRange(TID.ToBytes(12));
            bytes.AddRange(HashValue.ToBytes(8));
            return(bytes.ToArray());
        }
Пример #9
0
            public int GetHashCode(MsgKey obj)
            {
                TID  tid = obj.remoteValidatorTid;
                uint id  = 0;

                if (tid != TID.None)
                {
                    id = (uint)tid.id;
                }
                //都是从低往高分配的id,移位后冲突更少
                uint objId = (uint)obj.msgType ^ ((id << 16) + (id >> 16));

                return(objId.GetHashCode());
            }
Пример #10
0
        public bool CreateMod(string modName)
        {
            ModInfo info;

            if (!modInfos.TryGetValue(modName, out info))
            {
                Logger.Error("CreateMod failed, can't find ModInfo of {0}", modName);
                return(false);
            }

            // 有父mod要先确定父mod是否已加载
            if (!string.IsNullOrEmpty(info.baseMod))
            {
                //
                if (!name2ModDict.ContainsKey(info.baseMod))
                {
                    if (!CreateMod(info.baseMod))
                    {
                        return(false);
                    }
                }
            }

            // load mod
            if (!LoadModTemplate(info, "mod_bin.bytes"))
            {
                Logger.Error("error load mod {0}'s main template", modName);
                return(false);
            }

            Mod mod = TemplateMgr.CreateObject(TID.FromString(info.tid)) as Mod;

            if (mod != null)
            {
                mod.SetApp(this);
                if (!string.IsNullOrEmpty(info.baseMod))
                {
                    mod.parent = this.name2ModDict[info.baseMod];
                }
                this.name2ModDict.Add(modName, mod);
            }
            else
            {
                Logger.Error("mod {0} create failed!", modName);
                return(false);
            }

            return(true);
        }
Пример #11
0
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            Animator uo = (Animator)obj;

            avatar = ToID(uo.avatar);
            if (!m_assetDB.IsMapped(avatar))
            {
                animatorAvatar = new PersistentAvatar <TID>();
                animatorAvatar.ReadFrom(uo.avatar);
            }
        }
Пример #12
0
    public static void PlaceTile(Coordinate coordinate, TID id, TileBehavior behavior, int spriteIndex)
    {
        Tile oldTile = tree.GetTile(coordinate);

        if (oldTile.IsFilled())
        {
            return;
        }
        tree.InsertTile(coordinate, id, behavior != null, spriteIndex);
        if (behavior != null)
        {
            behavior.coordinate = coordinate;
            behavior.Initialize();
            tileBehaviors[coordinate] = behavior;
        }
        worldRenderer.UpdateAtCoordinate(coordinate);
    }
Пример #13
0
 public Tile(bool isFilled,
             bool isBacked,
             TID tileID,
             BID backID,
             bool randomSprite = false, int spriteIndex = 0, bool hasBehavior = false, bool hasWire = false, bool hasOverlay = false)
 {
     this.data = isFilled ? Masks.FILL : 0;
     data      = data | (isBacked ? Masks.BACK : 0);
     data      = data | (hasBehavior ? Masks.BEHAVIOR : 0);
     data      = data | (hasWire ? Masks.WIRE : 0);
     data      = data | (hasOverlay ? Masks.OVERLAY : 0);
     data      = data | (randomSprite ? Masks.RANDOM_SPRITE : 0);
     data      = data | (Masks.TID & (int)tileID);
     data      = data | (Masks.BID & ((int)backID << Masks.BID_SHIFT));
     data      = data | (Masks.SPRITE & (spriteIndex << Masks.SPRITE_SHIFT));
     //this.data = data32;
 }
Пример #14
0
        public EnvObject CreateObject(TID tid, int specifyUid = 0)
        {
            EnvObject ret;

            if (tidInsts.TryGetValue(tid, out ret))
            {
                return(ret);
            }

            EnvObject obj = Env.TemplateMgr.CreateObject(tid) as EnvObject;

            if (obj == null)
            {
                Logger.Error("CreateObject failed: " + tid);
                return(null);
            }

            obj.Env = this.Env;
            obj.OnInitEnvObject();

            if (specifyUid != 0)
            {
                obj.Uid = specifyUid;
            }
            else
            {
                obj.Uid = ++uidSeq;
            }

            // singleton
            BaseTemplate tmpl = Env.TemplateMgr.GetTemplate(tid);

            if (tmpl.singletonType == SingletonType.RunEnv)
            {
                tidInsts.Add(tid, obj);
            }

//todo: #if DEBUG_MODE
            if (uidSeq > Env.template.minUid + 10000000)
            {
                Logger.Error("uid seq is overflow!");
            }
//#endif
            return(obj);
        }
Пример #15
0
    public void TestMCS()
    {
        Console.WriteLine("Testing MCS");

        for (int index = 0; index < _NumTags; index++)
        {
            object          tag  = _Reader.SingulateTagAssisted(index);
            TID             tid  = default(TID);
            TagEPCURI_SGTIN epc  = default(TagEPCURI_SGTIN);
            taginfo         info = _TagInfos[index];

            Console.WriteLine("Testing tag at position {0}", index);

            DecodeError res = default(DecodeError);
            res = _Reader.ReadTID(tag, out tid);
            Assert.AreEqual(res, DecodeError.None);

            DecodeError res0 = _Reader.ReadEPC_SGTIN(tag, out epc);
            Assert.AreEqual(res0, DecodeError.None);

            Console.WriteLine("Generating a new EPC");

            if ((tid.Serial != null) && tid.Serial.Length > 0)
            {
                TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN);
                var             res1 = MCS.GenerateEPC(ref tid, ref epc, out epc1);
                Assert.IsTrue(res1);

                Console.WriteLine("New EPC SGTIN Pure Identity Tag URI {0}", epc1.Identity.URI);

                // Round-tripping should produce exactly the data that we want to see
                //res = _Reader.WriteEPC(tag, epc1)
                //Assert.IsTrue(res)

                //Dim epc1 As TagEPCURI_SGTIN
                //res = _Reader.ReadEPC(tag, epc1)
                //Assert.IsTrue(res)
                //Assert.AreEqual(epc, epc1)
            }
            else
            {
                Console.WriteLine("Skipping, because the TID does not provide a serial number");
            }
        }
    }
Пример #16
0
        public bool Open()
        {
            bool result = true;

            //gameapp init已经初始化了parent
            LoadFileCache();
            LoadTemplates();

            // init env
            TID[] envs = template.configs[App.Tid].envs;
            for (int i = 0; i < envs.Length; ++i)
            {
                TID tid = envs[i];
                if (tid != TID.None)
                {
                    // todo: GameApp:templateMgr
                    RunEnv env = App.TemplateMgr.CreateObject(tid) as RunEnv;
                    if (env != null)
                    {
                        env.SetApp(App);
                        env.SetMod(this);
                        env.SetTemplateMgr(templateMgr);
                        env.Init();

                        App.AddEnvToDict(env);
                        App.AddEnvToMainloop(env);
                        AddMainloopEnv(env);

                        //if (env.modService != null) {
                        //    if (env.modService.SetMod(this) <= 0) {
                        //        result = false;
                        //    }
                        //}
                    }
                    else
                    {
                        Logger.Error("init mod: runenv {0} create failed!", tid);
                        result = false;
                    }
                }
            }

            return(result);
        }
Пример #17
0
    public void TestEPCReading()
    {
        for (int index = 0; index < _NumTags; index++)
        {
            object          tag  = _Reader.SingulateTagAssisted(index);
            TID             tid  = default(TID);
            TagEPCURI_SGTIN epc  = default(TagEPCURI_SGTIN);
            taginfo         info = _TagInfos[index];

            Console.WriteLine("Testing tag at position {0}", index);

            DecodeError res = default(DecodeError);
            res = _Reader.ReadTID(tag, out tid);
            Assert.AreEqual(res, DecodeError.None);

            if (!string.IsNullOrEmpty(info.STID_URI))
            {
                Assert.AreEqual(tid.STID_URI, info.STID_URI);
            }
            if ((info.UTID != null) && info.UTID.Length > 0)
            {
                CollectionAssert.AreEqual(tid.Serial, info.UTID);
            }

            DecodeError res0 = default(DecodeError);
            res0 = _Reader.ReadEPC_SGTIN(tag, out epc);
            Assert.AreEqual(res0, DecodeError.None);
            Assert.AreEqual(epc.Identity.URI, info.PureIdentityURI);

            Console.WriteLine("Trying to round-trip");

            // Round-tripping should produce exactly the same data
            bool res1 = _Reader.WriteEPC(tag, epc);
            Assert.IsTrue(res1);

            TagEPCURI_SGTIN epc1 = default(TagEPCURI_SGTIN);
            res0 = _Reader.ReadEPC_SGTIN(tag, out epc1);
            Assert.AreEqual(res0, DecodeError.None);
            Assert.AreEqual(epc, epc1);
        }
    }
Пример #18
0
        public async Task <string> Get(
            bool ccaPerRequest = true,
            Flow flow          = Flow.S2S,
            int userForObo     = 1,
            TID tenantId       = TID.A,
            Scope scope        = Scope.S1,
            bool staticL1      = false,
            bool useL2         = true)
        {
            char c   = tenantId.ToString().ToCharArray()[0];
            var  tid = new string(Enumerable.Repeat(c, 16).ToArray());

            IConfidentialClientApplication cca = GetOrCreateCCA(ccaPerRequest, staticL1, useL2);

            AuthenticationResult res;

            if (flow == Flow.S2S)
            {
                res = await cca.AcquireTokenForClient(new[] { scope.ToString() })
                      .WithAuthority($"https://login.microsoftonline.com/{tid}")
                      .ExecuteAsync().ConfigureAwait(false);
            }
            else
            {
                var user = $"user_{userForObo}";

                // must be in this format. MSAL will use {user} as the object id
                string fakeUpstreamToken = $"upstream_token_{user}";

                res = await cca.AcquireTokenOnBehalfOf(new[] { scope.ToString() }, new UserAssertion(fakeUpstreamToken))
                      .WithAuthority($"https://login.microsoftonline.com/{tid}")
                      .ExecuteAsync()
                      .ConfigureAwait(false);
            }



            return(res.AuthenticationResultMetadata.TokenSource.ToString());
        }
Пример #19
0
    // Without changing any other data at the location, insert a new tile
    public bool InsertTile(Coordinate coordinate, TID id, bool hasBehavior, int spriteIndex)
    {
        if (!(coordinate.WithinBox(this.bottomLeft, this.topRight - 1)))
        {
            return(false);
        }

        if (this.scale == 1)
        {
            this.tile.Fill();
            this.tile.SetBehavior(hasBehavior);
            this.tile.SetID(id);
            this.tile.SetSprite(spriteIndex);
            return(true);
        }

        int subTreeIndex = this.GetSubTreeIndex(coordinate);

        if (this.subTrees[subTreeIndex] == null)
        {
            this.MakeSubTree(subTreeIndex, this.tile);
        }
        return(this.subTrees[subTreeIndex].InsertTile(coordinate, id, hasBehavior, spriteIndex));
    }
Пример #20
0
    public void RouteMan()
    {
        RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel;

        if (sm.SelectedRows.Count > 0)
        {
            HBBLL hb = new HBBLL();
            TID.SetValue(sm.SelectedRows[0].RecordID.Trim());
            TID.Value = sm.SelectedRows[0].RecordID.Trim();
            TID.Text  = sm.SelectedRows[0].RecordID.Trim();

            string id = TID.Value.ToString();
            id             = TID.Text;
            lblDetail.Text = hb.GetYPPTNameByID(int.Parse(id));

            DetailWindow.Show();
            UpdateStatus1();
            Ext.DoScript("#{YPPTDetailStore}.reload();");
        }
        else
        {
            Ext.Msg.Alert("提示", "请选择一个模板!").Show();
        }
    }
Пример #21
0
        public override void ReadFrom(object obj)
        {
            base.ReadFrom(obj);
            if (obj == null)
            {
                return;
            }

            Material o = (Material)obj;

            if (o.shader == null)
            {
                shader       = m_assetDB.NullID;
                m_shaderName = null;
                return;
            }

            shader       = ToID(o.shader);
            m_shaderName = o.shader.name;

            RuntimeShaderInfo  shaderInfo = null;
            IRuntimeShaderUtil shaderUtil = IOC.Resolve <IRuntimeShaderUtil>();

            if (shaderUtil != null)
            {
                shaderInfo = shaderUtil.GetShaderInfo(o.shader);
            }
            if (shaderInfo == null)
            {
                return;
            }

            m_propertyNames  = new string[shaderInfo.PropertyCount];
            m_propertyTypes  = new RTShaderPropertyType[shaderInfo.PropertyCount];
            m_propertyValues = new PrimitiveContract[shaderInfo.PropertyCount];
            m_textureOffset  = new List <Vector2>();
            m_textureScale   = new List <Vector2>();
            for (int i = 0; i < shaderInfo.PropertyCount; ++i)
            {
                string name = shaderInfo.PropertyNames[i];
                RTShaderPropertyType type = shaderInfo.PropertyTypes[i];
                m_propertyNames[i] = name;
                m_propertyTypes[i] = type;
                switch (type)
                {
                case RTShaderPropertyType.Color:
                    m_propertyValues[i] = PrimitiveContract.Create((PersistentColor <TID>)o.GetColor(name));
                    break;

                case RTShaderPropertyType.Float:
                    m_propertyValues[i] = PrimitiveContract.Create(o.GetFloat(name));
                    break;

                case RTShaderPropertyType.Range:
                    m_propertyValues[i] = PrimitiveContract.Create(o.GetFloat(name));
                    break;

                case RTShaderPropertyType.TexEnv:
                    Texture texture = o.GetTexture(name);
                    if (texture == null)
                    {
                        m_propertyValues[i] = PrimitiveContract.Create(m_assetDB.NullID);
                    }
                    else
                    {
                        m_propertyValues[i] = PrimitiveContract.Create(ToID(texture));
                    }
                    m_textureOffset.Add(o.GetTextureOffset(name));
                    m_textureScale.Add(o.GetTextureScale(name));
                    break;

                case RTShaderPropertyType.Vector:
                    m_propertyValues[i] = PrimitiveContract.Create((PersistentVector4 <TID>)o.GetVector(name));
                    break;

                case RTShaderPropertyType.Unknown:
                    m_propertyValues[i] = null;
                    break;
                }
            }

            m_keywords    = o.shaderKeywords;
            m_renderQueue = o.renderQueue;
        }
Пример #22
0
 /// <summary>
 /// Request oxygen sensor monitoring test results request SID
 /// </summary>
 /// <param name="TID">Test ID</param>
 /// <param name="O2SNO">o2 sensor number</param>
 /// <returns>Data record of test ID</returns>
 public ServiceResult Mode05(TID TID, O2 O2SNO)
 {
     return(serviceTransaction((byte)J1979Mode.REQ_O2_MON_RESULTS, 2, new byte[] { (byte)TID, (byte)O2SNO }));
 }
Пример #23
0
 public T FromID <T>(TID id)
 {
     throw new InvalidOperationException();
 }
Пример #24
0
 public static void PlaceTileAtCursor(TID id, TileBehavior behavior, int spriteIndex = 0)
 {
     PlaceTile(CursorCoordinate(), id, behavior, spriteIndex);
 }
Пример #25
0
 protected void AddDep(TID depenency, object context)
 {
     throw new InvalidOperationException();
 }
Пример #26
0
 internal RepoHandle(TID id, TObject obj, SyncRepo <TID, TObject> repo)
 {
     this.ID     = id;
     this.Object = obj;
     this.Repo   = repo;
 }
Пример #27
0
 public MsgKey(int msgType, TID remoteValidatorTid)
 {
     this.msgType            = msgType;
     this.remoteValidatorTid = remoteValidatorTid;
 }
Пример #28
0
 public void SetID(TID tileID)
 {
     this.data = this.data & ~Masks.TID;
     this.data = this.data | (((int)tileID) & Masks.TID);
 }
Пример #29
0
        void Reader_TagInventoryEvent(object sender, CSLibrary.Events.OnAsyncCallbackEventArgs e)
        {
            // Check Callback Type
            if (e.type != CSLibrary.Constants.CallbackType.TAG_RANGING)
            {
                return;
            }

            UInt32 TID, TID1;
            string EPC;

            UInt16[] tagdata = e.info.epc.ToUshorts();

            // Check TID code (exclude if scan temp)
            //TID = (UInt32)((tagdata[e.info.pc.EPCLength] << 16) | tagdata[e.info.pc.EPCLength + 1]) & 0xffffffc0U;
            //if (TID != 0xe2806e80U && TID != 0xe2806e8fU && TID != 0xe2806800U)
            //    return;

            TID  = (UInt32)((tagdata[e.info.pc.EPCLength] << 16) | tagdata[e.info.pc.EPCLength + 1]);
            TID1 = TID & 0xffffffc0U;
            if (TID1 != 0xe2806e80U && TID1 != 0xe2806e8fU && TID1 != 0xe2806800U)
            {
                return;
            }

            EPC = e.info.epc.ToString().Substring(0, (int)(e.info.pc.EPCLength * 4)) + ":" + TID.ToString("X8");

            BeginInvoke((System.Threading.ThreadStart) delegate()
            {
                lock (listView1)
                {
                    int cnt;

                    for (cnt = 0; cnt < listView1.Items.Count; cnt++)
                    {
                        if (listView1.Items[cnt].SubItems[1].Text == EPC)
                        {
                            break;
                        }
                    }

                    if (cnt == listView1.Items.Count)
                    {
                        ListViewItem ins = new ListViewItem((listView1.Items.Count + 1).ToString());
                        ins.SubItems.Add(EPC);

                        if ((tagdata[e.info.pc.EPCLength + 2] & 0x0800) != 0x0000)
                        {
                            ins.SubItems.Add("1");
                        }
                        else
                        {
                            ins.SubItems.Add("0");
                        }

                        if ((tagdata[e.info.pc.EPCLength + 2] & 0x0040) != 0x0000)
                        {
                            ins.SubItems.Add("1");
                        }
                        else
                        {
                            ins.SubItems.Add("0");
                        }

                        if ((tagdata[e.info.pc.EPCLength + 2] & 0x0001) != 0x0000)
                        {
                            ins.SubItems.Add("1");
                        }
                        else
                        {
                            ins.SubItems.Add("0");
                        }

                        listView1.Items.Add(ins);
                    }
                    else
                    {
                        if ((tagdata[e.info.pc.EPCLength + 2] & 0x0800) != 0x0000)
                        {
                            listView1.Items[cnt].SubItems[2].Text = "1";
                        }
                        else
                        {
                            listView1.Items[cnt].SubItems[2].Text = "0";
                        }

                        if ((tagdata[e.info.pc.EPCLength + 2] & 0x0040) != 0x0000)
                        {
                            listView1.Items[cnt].SubItems[3].Text = "1";
                        }
                        else
                        {
                            listView1.Items[cnt].SubItems[3].Text = "0";
                        }

                        if ((tagdata[e.info.pc.EPCLength + 2] & 0x0001) != 0x0000)
                        {
                            listView1.Items[cnt].SubItems[4].Text = "1";
                        }
                        else
                        {
                            listView1.Items[cnt].SubItems[4].Text = "0";
                        }
                    }
                }
            });
        }