Esempio n. 1
0
        public void CanStoreByte()
        {
            var blob = new byte[1];
            var span = StoreOps.StoreByte(blob, 5);

            Assert.True(span.IsEmpty);
            Assert.Equal(5, blob[0]);
        }
Esempio n. 2
0
        public void UshortStoredBigEndian()
        {
            var blob = new byte[2];
            var span = StoreOps.StoreUshort(blob, 0xABCD);

            Assert.True(span.IsEmpty);
            Assert.Equal(0xCD, blob[0]);
            Assert.Equal(0xAB, blob[1]);
        }
Esempio n. 3
0
        /// <summary>
        /// Serialize a work unit so it goes over the wire to a device.
        /// The structure must be common to all devices and algorithm implementations but the header can really be
        /// arbitrary payload as long as it's in the format the device expects.
        /// Each algorithm implementation takes a different payload so this can't just consume a <see cref="RequestedWork"/>.
        /// </summary>
        /// <returns>Opaque blob to send back to device.</returns>
        static internal byte[] YourWork(uint wid, IReadOnlyList <byte> payload)
        {
            var blob  = new byte[1 + 4 + payload.Count];
            var store = StoreOps.StoreKind(blob, OutgoingKind.WorkUnit);

            store = StoreOps.StoreUint(store, wid);
            store = StoreOps.StoreByteList(store, payload);
            ThrowIfNotFullyConsumed(store);
            return(blob);
        }
Esempio n. 4
0
        /////////////////////////////////////////////////////////////////////////////////


        #region //  StoreAllInfoQuery Test
        public ActionResult StoreAllInfoQuery(string _USCode)
        {
            List <StoreBasicInfo> lsStoreBasicInfo = new List <StoreBasicInfo>();
            StoreBasicInfo        mStoreBasicInfo  = new StoreBasicInfo();

            lsStoreBasicInfo = StoreBasicInfo.Search(o => o.StoreCode.Contains(_USCode)).ToList <StoreBasicInfo>();
            if (lsStoreBasicInfo.Count > 0)
            {
                mStoreBasicInfo = lsStoreBasicInfo[0];
            }

            List <StoreDevelop> lsStoreDevelop = new List <StoreDevelop>();
            StoreDevelop        mStoreDevelop  = new StoreDevelop();

            lsStoreDevelop = StoreDevelop.Search(o => o.StoreCode.Contains(_USCode)).ToList <StoreDevelop>();
            if (lsStoreDevelop.Count > 0)
            {
                mStoreDevelop = lsStoreDevelop[0];
            }

            List <StoreOps> lsStoreOp = new List <StoreOps>();
            StoreOps        mStoreOp  = new StoreOps();

            lsStoreOp = StoreOps.Search(o => o.StoreCode.Contains(_USCode)).ToList <StoreOps>();
            if (lsStoreOp.Count > 0)
            {
                mStoreOp = lsStoreOp[0];
            }

            List <StoreContractInfo> lsStoreContractInfo = new List <StoreContractInfo>();
            StoreContractInfo        mStoreContractInfo  = new StoreContractInfo();

            lsStoreContractInfo = StoreContractInfo.Search(o => o.StoreCode.Contains(_USCode)).ToList <StoreContractInfo>();
            if (lsStoreContractInfo.Count > 0)
            {
                mStoreContractInfo = lsStoreContractInfo[0];
            }

            var resultStoreAllInfo = new
            {
                StoreBasicInfo    = mStoreBasicInfo,
                StoreDevelop      = mStoreDevelop,
                StoreOp           = mStoreOp,
                StoreContractInfo = new
                {
                    StoreContractInfo         = mStoreContractInfo,
                    StoreContractRevision     = "",
                    StoreContractInfoAttached = ""
                }
            };

            string result = JsonConvert.SerializeObject(resultStoreAllInfo);

            return(Content(result));
        }
Esempio n. 5
0
        /// <summary>
        /// Construct the reply to <see cref="TurnOnArgs{A}"/>. In line of principle you could not-reply to
        /// some devices as they could be mangled by somebody else but... for the time being it's just a matter
        /// of giving back the server address to perform unicast packet transmissions.
        /// </summary>
        /// <param name="reachme">An unicast address the device who originally talked can contact me.</param>
        /// <param name="identificator">Currently unused.</param>
        /// <param name="deviceSpecific">Currently unused.</param>
        /// <returns>
        /// Blob to send over the wire. I won't touch it anymore. If I don't want to deal with this device
        /// (maybe it belongs to another server) I will return null and you send nothing to it.
        /// </returns>
        static internal byte[]? Welcome(IPAddress reachme, byte[] identificator, byte[] deviceSpecific)
        {
            var addrBlob = reachme.GetAddressBytes();
            var blob     = new byte[1 + 1 + addrBlob.Length];
            var store    = StoreOps.StoreKind(blob, OutgoingKind.ServerAddress);

            store = StoreOps.StoreByte(store, 0); // this is really a bitflag of features. For the time being it must be zero so no big deal
            store = StoreOps.StoreByteArray(store, addrBlob);
            ThrowIfNotFullyConsumed(store);
            return(blob);
        }
Esempio n. 6
0
        public void UintStoredBigEndian()
        {
            var blob = new byte[4];
            var span = StoreOps.StoreUint(blob, 0xABCDEF01);

            Assert.True(span.IsEmpty);
            Assert.Equal(0x01, blob[0]);
            Assert.Equal(0xEF, blob[1]);
            Assert.Equal(0xCD, blob[2]);
            Assert.Equal(0xAB, blob[3]);
        }
Esempio n. 7
0
        public ActionResult StoreOpQuery(string _USCode)
        {
            List <StoreOps> lsStoreOp = new List <StoreOps>();
            StoreOps        storeOp   = new StoreOps();

            lsStoreOp = StoreOps.Search(o => o.StoreCode.Contains(_USCode)).ToList <StoreOps>();
            if (lsStoreOp.Count > 0)
            {
                storeOp = lsStoreOp[0];
            }

            string result = JsonConvert.SerializeObject(storeOp);

            return(Content(result));
        }
Esempio n. 8
0
        public void UlongStoredBigEndian()
        {
            var blob = new byte[8];
            var span = StoreOps.StoreUlong(blob, 0xABCDEF01_23456789);

            Assert.True(span.IsEmpty);
            Assert.Equal(0x89, blob[0]);
            Assert.Equal(0x67, blob[1]);
            Assert.Equal(0x45, blob[2]);
            Assert.Equal(0x23, blob[3]);
            Assert.Equal(0x01, blob[4]);
            Assert.Equal(0xEF, blob[5]);
            Assert.Equal(0xCD, blob[6]);
            Assert.Equal(0xAB, blob[7]);
        }