Esempio n. 1
0
        public UInt16Array ChooseAttackPosition(Critter npc, Critter target, AttackChoice attackChoice)
        {
            var weapon = npc.GetItemById (attackChoice.WeaponId);
            if (weapon == null)
                return null;

            var weaponDistance = weapon.Proto.WeaponMaxDist (attackChoice.WeaponUse);
            var distance = Global.GetDistance (npc, target);

            if (weaponDistance < distance) {
                var direction = Global.GetDirection (npc, target);
                var hexX = npc.HexX;
                var hexY = npc.HexY;

                do {
                    npc.GetMap ().MoveHexByDir (ref hexX, ref hexY, direction, 1);
                } while(!npc.GetMap ().IsHexPassed (hexX, hexY));

                var result = new UInt16Array ();
                result.Add (hexX);
                result.Add (hexY);
                result.Add ((ushort)direction);
                return result;
            }

            return null;
        }
Esempio n. 2
0
        private bool FindPatrolHex(ref ushort hexX, ref ushort hexY)
        {
            var map = GetCritter ().GetMap ();
            if (map == null) {
                return false;
            }

            UIntArray entires = new UIntArray ();
            UInt16Array hexXs = new UInt16Array ();
            UInt16Array hexYs = new UInt16Array ();

            var entireCount = map.GetEntires (entireNumber, entires, hexXs, hexYs);
            if (entireCount == 0)
                return false;

            for (int i = 0; i < 10; i++) {
                var index = Global.Random (0, (int)entireCount - 1);
                if (hexX != hexXs [index] && hexY != hexYs [index]) {
                    hexX = hexXs [index];
                    hexY = hexYs [index];
                    return true;
                }
            }
            //not found any suitable entire
            return false;
        }
Esempio n. 3
0
        public void init(ReaderCapabilities readerCapabilities)
        {
            //Antenna Configuration
            this.Hopping                = false;
            this.HopTableID             = 0;
            this.HoppingStep            = 0;
            this.ChannelIndex           = 1;
            this.TagInventoryStateAware = false;
            this.ModeIndex              = 1000;
            this.Tari                        = 0;
            this.SelectedSession             = "Session 0";
            this.SelectedSessionIndex        = 1;
            this.TagPopulation               = 32;
            this.TagTransitTime              = 0;
            this.SelectedSearchMode          = "Dual_Target";
            this.FixedFrequencyMode          = "Disabled";
            this.FixedChannelList            = UInt16Array.FromString("");
            this.FrequencyHopList            = UInt16Array.FromString("");
            this.ReducedPowerFrequencyMode   = false;
            this.ReducedPowerChannelList     = UInt16Array.FromString(string.Empty);
            this.LowDutyCycleMode            = false;
            this.EmptyFieldTimeout           = 2000;
            this.FieldPingInterval           = 250;
            this.MaxNumberOfAntennaSupported = readerCapabilities.MaxNumberOfAntennaSupported;
            this.AntennaID                   =
                new ushort[readerCapabilities.MaxNumberOfAntennaSupported];
            this.AntennaConnected =
                new bool[readerCapabilities.MaxNumberOfAntennaSupported];
            this.SelectedReceiverSensitivity =
                new short[readerCapabilities.MaxNumberOfAntennaSupported];
            this.SelectedReceiverSensitivityIndex =
                new ushort[readerCapabilities.MaxNumberOfAntennaSupported];
            this.SelectedTransmiterPower =
                new double[readerCapabilities.MaxNumberOfAntennaSupported];
            this.SelectedTransmiterPowerIndex =
                new ushort[readerCapabilities.MaxNumberOfAntennaSupported];
            for (int i = 0; i < readerCapabilities.MaxNumberOfAntennaSupported; i++)
            {
                this.AntennaID[i] = (ushort)(i + 1);

                if (i == 0)
                {
                    this.AntennaConnected[i] = true;
                }
                else
                {
                    this.AntennaConnected[i] = false;
                }

                this.SelectedReceiverSensitivity[i]      = -70;
                this.SelectedReceiverSensitivityIndex[i] =
                    readerCapabilities.ReceiveSensitivityDic[-70];
                this.SelectedTransmiterPower[i]      = 30;
                this.SelectedTransmiterPowerIndex[i] =
                    readerCapabilities.TransmiterPowerDic[30];
            }
        }
Esempio n. 4
0
        public void OutOfRangeIndexUInt16()
        {
            var buf = new ArrayBuffer(2);
            var i16 = new UInt16Array(buf);

            i16[2] = 12;             //Setting value by index out of range does not lead to exception.
            var x = i16[2];

            Assert.AreEqual(0, i16[2]);            //Indeed it should return 'undefined' in JS.
        }
Esempio n. 5
0
 public static PARAM_C1G2BlockWrite DataMessage(UInt16Array data, ushort offset, ushort opSpecId = 111)
 {
     return(new PARAM_C1G2BlockWrite()
     {
         MB = new TwoBits(3),
         OpSpecID = opSpecId,
         WordPointer = offset,
         WriteData = data,
         AccessPassword = 0,
     });
 }
Esempio n. 6
0
        /// <summary>
        /// Converts a UInt16Array of words stored in MSP430 native endiness to a byte array.
        /// </summary>
        public static byte[] Msp430WordsToBytes(UInt16Array words)
        {
            var bytes = new byte[words.Count * 2];

            for (var i = 0; i < words.Count; ++i)
            {
                bytes[i * 2]     = (byte)((words[i] & 0xFF00) >> 8);
                bytes[i * 2 + 1] = (byte)(words[i] & 0x00FF);
            }
            return(bytes);
        }
Esempio n. 7
0
        public static PARAM_C1G2BlockWrite ControlMessage(ushort state, ushort value)
        {
            var data = new UInt16Array();

            data.Add(value);

            return(new PARAM_C1G2BlockWrite()
            {
                MB = new TwoBits(0),
                OpSpecID = 111,
                WordPointer = state,
                WriteData = data,
                AccessPassword = 0,
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Generates a "true" BlockWrite command from an offset and an array of data, taking care to
        /// avoid overlapping with the control messages we generate
        /// </summary>
        private PARAM_C1G2BlockWrite BlockWriteCmd(ushort offset, byte[] dataBlock)
        {
            var words = new UInt16Array();

            for (var i = 0; i < dataBlock.Length; i += 2)
            {
                words.Add((ushort)((dataBlock[i + 1] << 8) | dataBlock[i]));
            }

            var accessSpec = LLRPHelpers.DataMessage(words, offset, (ushort)this.nextAccessCmdId);

            this.nextAccessCmdId += 1;

            return(accessSpec);
        }
Esempio n. 9
0
        private static void AddWriteAccessCommand(MSG_ADD_ACCESSSPEC msg, string data)
        {
            //define access spec
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec = new UNION_AccessCommandOpSpec();

            PARAM_C1G2Write wr = new PARAM_C1G2Write();

            wr.AccessPassword = 0;
            wr.MB             = new TwoBits(1);
            wr.OpSpecID       = 111;
            wr.WordPointer    = 2;
            //Data to be written. ex: "EEEE11112222333344445555"
            wr.WriteData = UInt16Array.FromString(data);

            msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr);
        }
Esempio n. 10
0
        private static PARAM_AISpec WispInventoryAISpec(ushort tagPopulation = 4)
        {
            var antennaConfig = new PARAM_AntennaConfiguration()
            {
                AntennaID = 1,
                AirProtocolInventoryCommandSettings = new UNION_AirProtocolInventoryCommandSettings(),
            };
            var inventoryCommand = new PARAM_C1G2InventoryCommand()
            {
                C1G2RFControl = new PARAM_C1G2RFControl()
                {
                    ModeIndex = 0, Tari = 0
                },
                C1G2SingulationControl = new PARAM_C1G2SingulationControl()
                {
                    Session = new TwoBits(1), TagPopulation = tagPopulation
                },
                TagInventoryStateAware = false,
            };

            antennaConfig.AirProtocolInventoryCommandSettings.Add(inventoryCommand);

            var enabledAntennas = new UInt16Array();

            enabledAntennas.Add(1);

            return(new PARAM_AISpec()
            {
                AntennaIDs = enabledAntennas,

                AISpecStopTrigger = new PARAM_AISpecStopTrigger()
                {
                    AISpecStopTriggerType = ENUM_AISpecStopTriggerType.Null
                },

                InventoryParameterSpec = new PARAM_InventoryParameterSpec[]
                {
                    new PARAM_InventoryParameterSpec()
                    {
                        InventoryParameterSpecID = 1234,
                        ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2,
                        AntennaConfiguration = new PARAM_AntennaConfiguration[] { antennaConfig },
                    }
                }
            });
        }
Esempio n. 11
0
        /// <summary>
        /// Send Configurations to Mainfrom through RFIDReaderParameter
        /// </summary>
        public void SendConfigToMainForm()
        {
            //Get parameterd from MoreSettings form
            //------Antenna Confiuration------
            RFIDReaderParameter.AntennaConfiguration.TagInventoryStateAware = Convert.ToBoolean(cbTagInventoryStateAware.Text);
            RFIDReaderParameter.AntennaConfiguration.ModeIndex            = RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable[cbModeIndex.Text];
            RFIDReaderParameter.AntennaConfiguration.Tari                 = Convert.ToUInt16(tbxTari.Text);
            RFIDReaderParameter.AntennaConfiguration.SelectedSession      = cbSession.Text;
            RFIDReaderParameter.AntennaConfiguration.SelectedSessionIndex = RFIDReaderParameter.ReaderCapabilities.Sessions[cbSession.Text];
            RFIDReaderParameter.AntennaConfiguration.TagPopulation        = Convert.ToUInt16(tbxTagPopulation.Text);
            RFIDReaderParameter.AntennaConfiguration.TagTransitTime       = Convert.ToUInt16(tbxTagTransitTime.Text);
            RFIDReaderParameter.AntennaConfiguration.SelectedSearchMode   = cbImpiJSearchMode.Text;

            RFIDReaderParameter.AntennaConfiguration.ReducedPowerFrequencyMode = cbImpinjReducedPowerFrequencyMode.Checked;
            if (cbImpinjReducedPowerFrequencyMode.Checked)
            {
                string[]    strs     = tbxReducedChannelList.Text.Trim().Split(',');
                UInt16Array channels = new UInt16Array();
                for (int i = 0; i < strs.Length; i++)
                {
                    channels.Add(Convert.ToUInt16(strs[i]));
                }
                RFIDReaderParameter.AntennaConfiguration.ReducedPowerChannelList = channels;
            }
            else
            {
                RFIDReaderParameter.AntennaConfiguration.ReducedPowerChannelList = UInt16Array.FromString(String.Empty);
            }

            RFIDReaderParameter.AntennaConfiguration.LowDutyCycleMode = cbImpinjLowDutyCycleMode.Checked;
            if (cbImpinjLowDutyCycleMode.Checked)
            {
                RFIDReaderParameter.AntennaConfiguration.EmptyFieldTimeout = Convert.ToUInt16(tbxEmptyFieldTimeout.Text);
                RFIDReaderParameter.AntennaConfiguration.FieldPingInterval = Convert.ToUInt16(tbxFieldPingInterval.Text);
            }
            else
            {
                RFIDReaderParameter.AntennaConfiguration.EmptyFieldTimeout = 0;
                RFIDReaderParameter.AntennaConfiguration.FieldPingInterval = 0;
            }

            CheckBox[] checkboxs     = new CheckBox[] { cbAntenna1, cbAntenna2, cbAntenna3, cbAntenna4 };
            ComboBox[] comboboxReces = new ComboBox[] { cbReceiverSensitivity1, cbReceiverSensitivity2, cbReceiverSensitivity3, cbReceiverSensitivity4 };
            ComboBox[] comboboxTrans = new ComboBox[] { cbTransmiterPower1, cbTransmiterPower2, cbTransmiterPower3, cbTransmiterPower4 };
            SetAntennaIndependentSettings(checkboxs, comboboxReces, comboboxTrans);
            //------Antenna Confiuration------

            //-----Reader Operation Report Sepc-------
            RFIDReaderParameter.ROReportSpec.SelectedROReportTrigger = cbROReportTrigger.Text;
            RFIDReaderParameter.ROReportSpec.ROReportTriggerN        = Convert.ToUInt16(nudN.Value);

            RFIDReaderParameter.ROReportSpec.EnableROSpecID  = cbEnableROSpecID.Checked;
            RFIDReaderParameter.ROReportSpec.EnableSpecIndex = cbEnableSpecIndex.Checked;
            RFIDReaderParameter.ROReportSpec.EnableInventoryParameterSPecID = cbEnableInventoryParameterSpecID.Checked;
            RFIDReaderParameter.ROReportSpec.EnableAntennaID          = cbEnableAntennaID.Checked;
            RFIDReaderParameter.ROReportSpec.EnableChannelIndex       = cbEnableChannelIndex.Checked;
            RFIDReaderParameter.ROReportSpec.EnablePeakRSSI           = cbEnablePeakRSSI.Checked;
            RFIDReaderParameter.ROReportSpec.EnableFirstSeenTimestamp = cbEnableFirstSeenTimestamp.Checked;
            RFIDReaderParameter.ROReportSpec.EnableLastSeenTimestamp  = cbEnableLastSeenTimestamp.Checked;
            RFIDReaderParameter.ROReportSpec.EnableTagSeenCount       = cbEnableTagSeenCount.Checked;
            RFIDReaderParameter.ROReportSpec.EnableAccessSpecID       = cbEnableAccessSpecID.Checked;
            RFIDReaderParameter.ROReportSpec.EnableCRC    = cbEnableCRC.Checked;
            RFIDReaderParameter.ROReportSpec.EnablePCbits = cbEnablePCBits.Checked;

            RFIDReaderParameter.ROReportSpec.ImpinJEnableSerializedTID      = cbImpinjEnableSerializedTID.Checked;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableRFPhaseAngle       = cbImpinjEnableRFPhaseAngle.Checked;
            RFIDReaderParameter.ROReportSpec.ImpinJEnablePeakRSSI           = cbImpinjEnablePeakRSSI.Checked;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableGPSCoordinates     = cbImpinjEnableGPSCoordinates.Checked;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableOptimizedRead      = cbImpinjEnableOptimizedRead.Checked;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableRFDopplerFrequency = cbImpinjEnableRFDopplerFrequency.Checked;
            //-----Reader Operation Report Sepc-------
        }
Esempio n. 12
0
        /// <summary>
        /// Before starting inventorying, save settings in the mainform
        /// </summary>
        public bool SaveSettings()
        {
            RFIDReaderParameter.Reset     = cbResetToFactoryDefault.Checked;
            RFIDReaderParameter.Mask      = cbMask.Text;
            RFIDReaderParameter.ExtraMask = cbExtraMask.Text;

            if (rbtnManualReadMode.Checked)
            {
                RFIDReaderParameter.ReadMode = "Manual";
            }
            else
            {
                RFIDReaderParameter.ReadMode = "Timer";
                RFIDReaderParameter.Duration = Convert.ToUInt32(tbxDuration.Text);
            }


            RFIDReaderParameter.AntennaConfiguration.FixedFrequencyMode = cbFreqMode.Text;
            if (RFIDReaderParameter.AntennaConfiguration.FixedFrequencyMode != "Disabled")
            {
                RFIDReaderParameter.AntennaConfiguration.Hopping          = true;
                RFIDReaderParameter.AntennaConfiguration.HoppingStep      = Convert.ToUInt16(nudHop.Value);
                RFIDReaderParameter.AntennaConfiguration.FixedChannelList = new UInt16Array();
                UInt16Array channelList = new UInt16Array();

                if (clbFreqSet.CheckedIndices.Count < 2)
                {
                    MessageBox.Show("Must choose at least 2 frequencies");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < clbFreqSet.CheckedIndices.Count; i++)
                    {
                        channelList.Add((ushort)(clbFreqSet.CheckedIndices[i] + 1));
                    }

                    if (RFIDReaderParameter.AntennaConfiguration.HoppingStep <= 0)
                    {
                        MessageBox.Show("HoppingStep must be larger than 0");
                        return(false);
                    }
                    else if (RFIDReaderParameter.AntennaConfiguration.HoppingStep >= channelList.Count)
                    {
                        MessageBox.Show("HoppingStep must be smaller than Chosen List");
                        return(false);
                    }
                    else
                    {
                        int len = channelList.Count;
                        RFIDReaderParameter.AntennaConfiguration.FixedChannelList.Add(channelList[0]);
                        for (int i = 1; i < len; i++)
                        {
                            int nextIndex = (0 + i * RFIDReaderParameter.AntennaConfiguration.HoppingStep) % len;
                            if (nextIndex == 0)
                            {
                                break;
                            }
                            RFIDReaderParameter.AntennaConfiguration.FixedChannelList.Add(channelList[nextIndex]);
                        }
                        return(true);
                    }
                }
            }
            else
            {
                RFIDReaderParameter.AntennaConfiguration.Hopping     = false;
                RFIDReaderParameter.AntennaConfiguration.HoppingStep = 0;
                if (clbFreqSet.CheckedIndices.Count < 1)
                {
                    MessageBox.Show("Please choose one frequency!");
                    return(false);
                }
                else if (clbFreqSet.CheckedIndices.Count > 1)
                {
                    MessageBox.Show("Can only choose one frequency!");
                    return(false);
                }
                else
                {
                    RFIDReaderParameter.AntennaConfiguration.ChannelIndex = (ushort)(clbFreqSet.CheckedIndices[0] + 1);
                    return(true);
                }
            }
        }
Esempio n. 13
0
        public void Add_AccessSpec()
        {
            MSG_ERROR_MESSAGE  msg_err;
            MSG_ADD_ACCESSSPEC msg = new MSG_ADD_ACCESSSPEC();

            msg.AccessSpec = new PARAM_AccessSpec();

            /////////////////////////////////////////////////
            // AccessSpec
            /////////////////////////////////////////////////
            // AccessSpecID should be set to a unique identifier.
            msg.AccessSpec.AccessSpecID = 456;
            msg.AccessSpec.AntennaID    = 0;
            // We're writing to a Gen2 tag
            msg.AccessSpec.ProtocolID = ENUM_AirProtocols.EPCGlobalClass1Gen2;
            // AccessSpecs must be disabled when you add them.
            msg.AccessSpec.CurrentState = ENUM_AccessSpecState.Disabled;
            msg.AccessSpec.ROSpecID     = 0;
            // Setup the triggers
            msg.AccessSpec.AccessSpecStopTrigger =
                new PARAM_AccessSpecStopTrigger();
            msg.AccessSpec.AccessSpecStopTrigger.AccessSpecStopTrigger =
                ENUM_AccessSpecStopTriggerType.Null;
            // OperationCountValue indicate the number of times this Spec is
            // executed before it is deleted. If set to 0, this is equivalent
            // to no stop trigger defined.
            msg.AccessSpec.AccessSpecStopTrigger.OperationCountValue = 0;

            /////////////////////////////////////////////////
            // AccessCommand
            //
            // Define which tags we want to write to.
            /////////////////////////////////////////////////
            msg.AccessSpec.AccessCommand = new PARAM_AccessCommand();
            msg.AccessSpec.AccessCommand.AirProtocolTagSpec =
                new UNION_AirProtocolTagSpec();
            PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec();

            // Specify the target tag. Which tag do we want to write to?
            tagSpec.C1G2TargetTag          = new PARAM_C1G2TargetTag[1];
            tagSpec.C1G2TargetTag[0]       = new PARAM_C1G2TargetTag();
            tagSpec.C1G2TargetTag[0].Match = true;
            // We'll use the tag's EPC to determine if this is the label we want.
            // Set the memory bank to 1 (The EPC memory bank on a Monza 4 tag).
            tagSpec.C1G2TargetTag[0].MB = new TwoBits(1);
            // The first (msb) bit location of the specified memory
            // bank against which to compare the TagMask.
            // We'll set it to 0x20, to skip the protocol
            // control bits and CRC.
            tagSpec.C1G2TargetTag[0].Pointer = 0x20;
            tagSpec.C1G2TargetTag[0].TagMask =
                LLRPBitArray.FromHexString("FFFFFFFFFFFFFFFFFFFFFFFF");
            tagSpec.C1G2TargetTag[0].TagData =
                LLRPBitArray.FromHexString("300833B2DDD9014000000000");
            msg.AccessSpec.AccessCommand.AirProtocolTagSpec.Add(tagSpec);

            /////////////////////////////////////////////////
            // AccessCommandOpSpec
            //
            // Define the data we want to write.
            /////////////////////////////////////////////////
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec =
                new UNION_AccessCommandOpSpec();
            PARAM_C1G2Write wr = new PARAM_C1G2Write();

            wr.AccessPassword = 0;
            // Bank 3 is user memory on a Monza 4 tag.
            wr.MB = new TwoBits(3);
            // OpSpecID should be set to a unique identifier.
            wr.OpSpecID = 111;
            // Write to the base of user memory.
            wr.WordPointer = 0x00;
            // Data to be written.
            wr.WriteData = UInt16Array.FromHexString("0123456789ABCDEF");
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr);

            /////////////////////////////////////////////////
            // AccessReportSpec
            //
            // Define when we want to receive AccessReports
            /////////////////////////////////////////////////
            msg.AccessSpec.AccessReportSpec = new PARAM_AccessReportSpec();
            msg.AccessSpec.AccessReportSpec.AccessReportTrigger =
                ENUM_AccessReportTriggerType.End_Of_AccessSpec;

            // Send the message and check the reply
            MSG_ADD_ACCESSSPEC_RESPONSE rsp =
                reader.ADD_ACCESSSPEC(msg, out msg_err, 2000);

            if (rsp != null)
            {
                // Success
                Console.WriteLine(rsp.ToString());
            }
            else if (msg_err != null)
            {
                // Error
                Console.WriteLine(msg_err.ToString());
            }
            else
            {
                // Timeout
                Console.WriteLine("Timeout Error.");
            }
        }
Esempio n. 14
0
 public virtual uint GetInternalBag(UInt16Array pids, UIntArray min_counts, UIntArray max_counts, IntArray slots)
 {
     return Crit_GetInternalBag(thisptr,
         pids != null ? pids.ThisPtr : IntPtr.Zero,
         min_counts != null ? min_counts.ThisPtr : IntPtr.Zero,
         max_counts != null ? max_counts.ThisPtr : IntPtr.Zero,
         slots != null ? slots.ThisPtr : IntPtr.Zero);
 }
Esempio n. 15
0
 public uint GetBagItems(uint bag_id, UInt16Array pids, UIntArray min_counts, UIntArray max_counts, IntArray slots)
 {
     return Global_GetBagItems(bag_id, (IntPtr)pids, (IntPtr)min_counts, (IntPtr)max_counts, (IntPtr)slots);
 }
Esempio n. 16
0
        /// <summary>
        /// 参数化建模
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDriveModel_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (polyline != null)
                {
                    center = polyline.Envelope.Center;
                    IModelPoint mp = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint;
                    mp.SpatialCRS = datasetCRS;
                    mp.Position   = center;

                    IModel         model     = new ResourceFactory().CreateModel();
                    IDrawGroup     group     = new DrawGroup();
                    IDrawPrimitive primitive = new DrawPrimitive();
                    IDrawMaterial  material  = new DrawMaterial();
                    material.TextureName = (strMediaPath + @"\shp\road\textrure.jpg");
                    material.CullMode    = gviCullFaceMode.gviCullNone;
                    material.WrapModeS   = gviTextureWrapMode.gviTextureWrapRepeat;
                    material.WrapModeT   = gviTextureWrapMode.gviTextureWrapRepeat;
                    IFloatArray va = new FloatArray();
                    IFloatArray ta = new FloatArray();
                    // 逐点外扩
                    for (int i = 0; i < polyline.PointCount; i++)
                    {
                        #region 单独处理最后一个点
                        if (i == polyline.PointCount - 1)
                        {
                            curPoint  = polyline.GetPoint(i);
                            vecCurPos = curPoint.Position;
                            // 最后一个点重用最后的方向向量
                            vecTarget = vecDirect.CrossProduct(vecZ);
                            vecTarget.Normalize();
                            vecTarget.MultiplyByScalar(width / 2);
                            vecP = vecCurPos.Add(vecTarget);
                            vecTarget.MultiplyByScalar(-1);
                            vecQ = vecCurPos.Add(vecTarget);
                            // 设置外扩点
                            P          = curPoint.Clone() as IPoint;
                            P.Position = vecP;
                            Q          = curPoint.Clone() as IPoint;
                            Q.Position = vecQ;
                            // 把点坐标加进顶点数组
                            va.Append((float)(vecP.X - center.X));
                            va.Append((float)(vecP.Y - center.Y));
                            va.Append((float)(vecP.Z - center.Z));
                            va.Append((float)(vecQ.X - center.X));
                            va.Append((float)(vecQ.Y - center.Y));
                            va.Append((float)(vecQ.Z - center.Z));
                            // 加纹理坐标
                            ta.Append(0);  //P点纹理
                            if (i == 0)
                            {
                                lastV = 0.0;
                            }
                            else
                            {
                                lastV = lastV + length / 10;  //v方向上每隔10米重复一次
                            }
                            ta.Append((float)lastV);
                            ta.Append(1);  //Q点纹理
                            ta.Append((float)lastV);

                            {
                                ISimplePointSymbol ps = new SimplePointSymbol();
                                ps.FillColor = System.Drawing.Color.Yellow;
                                ps.Size      = 5;
                                rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(P, ps, rootId));
                                rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(Q, ps, rootId));
                            }

                            break;
                        }
                        #endregion

                        // 当不是最后一个点时:
                        curPoint   = polyline.GetPoint(i);
                        nextPoint  = polyline.GetPoint(i + 1);
                        vecCurPos  = curPoint.Position;
                        vecNextPos = nextPoint.Position;
                        // 运算
                        vecNextPos.MultiplyByScalar(-1);
                        vecDirect = vecCurPos.Add(vecNextPos);  //方向向量
                        vecZ.Set(0, 0, 1);
                        vecTarget = vecDirect.CrossProduct(vecZ);
                        vecTarget.Normalize();
                        vecTarget.MultiplyByScalar(width / 2);
                        vecP = vecCurPos.Add(vecTarget);
                        vecTarget.MultiplyByScalar(-1);
                        vecQ = vecCurPos.Add(vecTarget);
                        // 设置外扩点
                        P          = curPoint.Clone() as IPoint;
                        P.Position = vecP;
                        Q          = curPoint.Clone() as IPoint;
                        Q.Position = vecQ;
                        // 把点坐标加进顶点数组
                        va.Append((float)(vecP.X - center.X));
                        va.Append((float)(vecP.Y - center.Y));
                        va.Append((float)(vecP.Z - center.Z));
                        va.Append((float)(vecQ.X - center.X));
                        va.Append((float)(vecQ.Y - center.Y));
                        va.Append((float)(vecQ.Z - center.Z));
                        // 加纹理坐标
                        ta.Append(0);  //P点纹理
                        if (i == 0)
                        {
                            lastV = 0.0;
                        }
                        else
                        {
                            lastV = lastV + length / 5; //v方向上每隔10米重复一次
                        }
                        length = vecDirect.Length;      //计算长度给奇数点用
                        ta.Append((float)lastV);
                        ta.Append(1);                   //Q点纹理
                        ta.Append((float)lastV);

                        {
                            ISimplePointSymbol ps = new SimplePointSymbol();
                            ps.FillColor = System.Drawing.Color.Yellow;
                            ps.Size      = 5;
                            rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(P, ps, rootId));
                            rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(Q, ps, rootId));
                        }
                    }
                    // 计算索引坐标
                    IUInt16Array ia = new UInt16Array();
                    for (int i = 0; i < va.Length / 6 - 1; i++)
                    {
                        ia.Append((ushort)(2 * i));
                        ia.Append((ushort)(2 * i + 1));
                        ia.Append((ushort)(2 * i + 2));
                        ia.Append((ushort)(2 * i + 1));
                        ia.Append((ushort)(2 * i + 3));
                        ia.Append((ushort)(2 * i + 2));
                    }
                    primitive.VertexArray   = va;
                    primitive.TexcoordArray = ta;
                    primitive.IndexArray    = ia;
                    primitive.Material      = material;
                    group.AddPrimitive(primitive);
                    model.AddGroup(group);

                    // 在内存中临时存储模型
                    string modelName = fid.ToString();
                    this.axRenderControl1.ObjectManager.AddModel(modelName, model);
                    mp.ModelName     = modelName;
                    mp.ModelEnvelope = model.Envelope;
                    // 可视化临时模型
                    IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId);
                    rmp.MaxVisibleDistance = 100000;
                    rmp.MouseSelectMask    = gviViewportMask.gviViewNone;
                    rModelpointToDelList.Add(rmp);
                }
            }
            catch (System.Exception ex)
            {
                if (ex.GetType().Name.Equals("UnauthorizedAccessException"))
                {
                    MessageBox.Show("需要标准runtime授权");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Esempio n. 17
0
 public bool Get(string name, UInt16Array data)
 {
     var ss = new ScriptString(name);
     return Global_GetAnyData(ss.ThisPtr, data.ThisPtr);
 }
Esempio n. 18
0
 public virtual void SetInternalBag(UInt16Array pids, UIntArray min_counts, UIntArray max_counts, IntArray slots)
 {
     Crit_SetInternalBag(thisptr, pids.ThisPtr, min_counts.ThisPtr, max_counts.ThisPtr, slots.ThisPtr);
 }
Esempio n. 19
0
        private bool ADD_ACCESSSPEC(string tagdata, int type)
        {
            MSG_ADD_ACCESSSPEC msg = new MSG_ADD_ACCESSSPEC();

            msg.AccessSpec = new PARAM_AccessSpec();

            msg.AccessSpec.AccessSpecID = 1001;
            msg.AccessSpec.AntennaID    = 1;
            msg.AccessSpec.ProtocolID   = ENUM_AirProtocols.EPCGlobalClass1Gen2;
            msg.AccessSpec.CurrentState = ENUM_AccessSpecState.Disabled;
            msg.AccessSpec.ROSpecID     = 123;

            //define trigger
            msg.AccessSpec.AccessSpecStopTrigger = new PARAM_AccessSpecStopTrigger();
            msg.AccessSpec.AccessSpecStopTrigger.AccessSpecStopTrigger = ENUM_AccessSpecStopTriggerType.Operation_Count;
            msg.AccessSpec.AccessSpecStopTrigger.OperationCountValue   = 100;

            //define access command

            //define air protocol spec
            msg.AccessSpec.AccessCommand = new PARAM_AccessCommand();
            msg.AccessSpec.AccessCommand.AirProtocolTagSpec = new UNION_AirProtocolTagSpec();

            PARAM_C1G2TagSpec tagSpec = new PARAM_C1G2TagSpec();

            tagSpec.C1G2TargetTag            = new PARAM_C1G2TargetTag[1];
            tagSpec.C1G2TargetTag[0]         = new PARAM_C1G2TargetTag();
            tagSpec.C1G2TargetTag[0].Match   = false; //change to "true" if you want to the following parameters take effect.
            tagSpec.C1G2TargetTag[0].MB      = new TwoBits(1);
            tagSpec.C1G2TargetTag[0].Pointer = 0x20;
            tagSpec.C1G2TargetTag[0].TagData = LLRPBitArray.FromString("1111");
            tagSpec.C1G2TargetTag[0].TagMask = LLRPBitArray.FromBinString("1111111111111111");

            msg.AccessSpec.AccessCommand.AirProtocolTagSpec.Add(tagSpec);

            //define access spec
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec = new UNION_AccessCommandOpSpec();

            PARAM_C1G2Write wr = new PARAM_C1G2Write();

            wr.AccessPassword = 0;
            wr.MB             = new TwoBits(1);
            wr.OpSpecID       = 111;
            wr.WordPointer    = 2;
            //Data to be written.
            wr.WriteData = UInt16Array.FromHexString(tagdata);
            msg.AccessSpec.AccessCommand.AccessCommandOpSpec.Add(wr);

            msg.AccessSpec.AccessReportSpec = new PARAM_AccessReportSpec();
            msg.AccessSpec.AccessReportSpec.AccessReportTrigger = ENUM_AccessReportTriggerType.End_Of_AccessSpec;

            MSG_ADD_ACCESSSPEC_RESPONSE rsp = reader.ADD_ACCESSSPEC(msg, out msg_err, 12000);

            if (rsp != null)
            {
                //return rsp.ToString();
                return(true);
            }
            else if (msg_err != null)
            {
                //return msg_err.ToString();
                return(false);
            }
            else
            {
                //return "Command time out!";
                return(false);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Before starting inventorying, get parameters from ReaderSettingsFrom and Save them in the RFIDReaderParameter
        /// </summary>
        /// <returns>if sending successfully, return true; otherwise, return false</returns>
        public bool SendConfigToRFIDReaderPara()
        {
            //------Basic Settings------
            RFIDReaderParameter.Reset = cbResetToFactoryDefault.Checked;
            // Read Mode
            if (rbtnManualReadMode.Checked)
            {
                RFIDReaderParameter.ReadMode = "Manual";
            }
            else
            {
                RFIDReaderParameter.ReadMode = "Timer";
                if (tbxDuration.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("Please input duration for timer mode", "Reader Settings Error");
                    return(false);
                }
                else if (Convert.ToUInt32(tbxDuration.Text) == 0)
                {
                    MessageBox.Show("Duration for timer mode should be larger than 0", "Reader Settings Error");
                    return(false);
                }
                else
                {
                    RFIDReaderParameter.Duration = Convert.ToUInt32(tbxDuration.Text);
                }
            }
            // Frequency Information
            RFIDReaderParameter.antennaConfiguration.FixedFrequencyMode = cbFreqMode.Text;
            if (RFIDReaderParameter.antennaConfiguration.FixedFrequencyMode != "Disabled")
            {
                RFIDReaderParameter.antennaConfiguration.Hopping          = true;
                RFIDReaderParameter.antennaConfiguration.HoppingStep      = Convert.ToUInt16(nudHop.Value);
                RFIDReaderParameter.antennaConfiguration.FixedChannelList = new UInt16Array();
                UInt16Array channelList = new UInt16Array();

                if (clbFreqSet.CheckedIndices.Count < 2)
                {
                    MessageBox.Show("Must choose at least 2 frequencies", "Reader Settings Error");
                    return(false);
                }
                else
                {
                    for (int i = 0; i < clbFreqSet.CheckedIndices.Count; i++)
                    {
                        channelList.Add((ushort)(clbFreqSet.CheckedIndices[i] + 1));
                    }

                    if (RFIDReaderParameter.antennaConfiguration.HoppingStep <= 0)
                    {
                        MessageBox.Show("HoppingStep must be larger than 0", "Reader Settings Error");
                        return(false);
                    }
                    else if (RFIDReaderParameter.antennaConfiguration.HoppingStep >= channelList.Count)
                    {
                        MessageBox.Show("HoppingStep must be smaller than Chosen List", "Reader Settings Error");
                        return(false);
                    }
                    else
                    {
                        int len = channelList.Count;
                        RFIDReaderParameter.antennaConfiguration.FixedChannelList.Add(channelList[0]);
                        for (int i = 1; i < len; i++)
                        {
                            int nextIndex = (0 + i * RFIDReaderParameter.antennaConfiguration.HoppingStep) % len;
                            if (nextIndex == 0)
                            {
                                break;
                            }
                            RFIDReaderParameter.antennaConfiguration.FixedChannelList.Add(channelList[nextIndex]);
                        }
                    }
                }
            }
            else
            {
                RFIDReaderParameter.antennaConfiguration.Hopping     = false;
                RFIDReaderParameter.antennaConfiguration.HoppingStep = 0;
                if (clbFreqSet.CheckedIndices.Count < 1)
                {
                    MessageBox.Show("Please choose one frequency!");
                    return(false);
                }
                else if (clbFreqSet.CheckedIndices.Count > 1)
                {
                    MessageBox.Show("Can only choose one frequency!");
                    return(false);
                }
                else
                {
                    RFIDReaderParameter.antennaConfiguration.ChannelIndex = (ushort)(clbFreqSet.CheckedIndices[0] + 1);
                }
            }
            // Tag Filter
            RFIDReaderParameter.antennaConfiguration.mask = this.includeTextBox.Text;
            //  RFIDReaderParameter.antennaConfiguration.extraMask = this.excludeTextBox.Text;
            //------Basic Settings------

            //------Antenna Settings------
            RFIDReaderParameter.antennaConfiguration.TagInventoryStateAware = Convert.ToBoolean(cbTagInventoryStateAware.Text);
            // C1G2 RF Control
            RFIDReaderParameter.antennaConfiguration.ModeIndex = RFIDReaderParameter.readerCapabilities.PreDefinedModeTable[cbModeIndex.Text];
            if (tbxTari.Text.Trim() == String.Empty)
            {
                MessageBox.Show("Please Input Tari!", "Reader Settings Error");
                return(false);
            }
            else
            {
                RFIDReaderParameter.antennaConfiguration.Tari = Convert.ToUInt16(tbxTari.Text);
            }
            // C1G2 Singulation Control
            RFIDReaderParameter.antennaConfiguration.SelectedSession      = cbSession.Text;
            RFIDReaderParameter.antennaConfiguration.SelectedSessionIndex = RFIDReaderParameter.readerCapabilities.Sessions[cbSession.Text];
            if (tbxTagPopulation.Text.Trim() == String.Empty)
            {
                MessageBox.Show("Please Input Tag Population!", "Reader Settings Error");
                return(false);
            }
            else
            {
                RFIDReaderParameter.antennaConfiguration.TagPopulation = Convert.ToUInt16(tbxTagPopulation.Text);
            }
            if (tbxTagTransitTime.Text.Trim() == String.Empty)
            {
                MessageBox.Show("Please Input Tag Transit Time!", "Reader Settings Error");
                return(false);
            }
            else
            {
                RFIDReaderParameter.antennaConfiguration.TagTransitTime = Convert.ToUInt16(tbxTagTransitTime.Text);
            }
            //ImpinJ
            RFIDReaderParameter.antennaConfiguration.SelectedSearchMode        = cbImpiJSearchMode.Text;
            RFIDReaderParameter.antennaConfiguration.ReducedPowerFrequencyMode = cbImpinjReducedPowerFrequencyMode.Checked;
            if (cbImpinjReducedPowerFrequencyMode.Checked)
            {
                if (tbxReducedChannelList.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("Please Input Channel List!");
                    return(false);
                }
                else
                {
                    string[]    strs     = tbxReducedChannelList.Text.Trim().Split(',');
                    UInt16Array channels = new UInt16Array();
                    for (int i = 0; i < strs.Length; i++)
                    {
                        channels.Add(Convert.ToUInt16(strs[i]));
                    }
                    RFIDReaderParameter.antennaConfiguration.ReducedPowerChannelList = channels;
                }
            }
            else
            {
                RFIDReaderParameter.antennaConfiguration.ReducedPowerChannelList = UInt16Array.FromString(String.Empty);
            }
            RFIDReaderParameter.antennaConfiguration.LowDutyCycleMode = cbImpinjLowDutyCycleMode.Checked;
            if (cbImpinjLowDutyCycleMode.Checked)
            {
                if (tbxEmptyFieldTimeout.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("Please Input Empty Field Timeout!");
                    return(false);
                }
                else
                {
                    RFIDReaderParameter.antennaConfiguration.EmptyFieldTimeout = Convert.ToUInt16(tbxEmptyFieldTimeout.Text);
                }

                if (tbxFieldPingInterval.Text.Trim() == String.Empty)
                {
                    MessageBox.Show("Please Input Field Ping Interval!");
                    return(false);
                }
                else
                {
                    RFIDReaderParameter.antennaConfiguration.FieldPingInterval = Convert.ToUInt16(tbxFieldPingInterval.Text);
                }
            }
            else
            {
                RFIDReaderParameter.antennaConfiguration.EmptyFieldTimeout = 0;
                RFIDReaderParameter.antennaConfiguration.FieldPingInterval = 0;
            }
            // Antenna Independent Settings
            if (!cbAntenna1.Checked && !cbAntenna2.Checked && !cbAntenna3.Checked && !cbAntenna4.Checked)
            {
                MessageBox.Show("Please choose at least one Antenna!");
                return(false);
            }
            else
            {
                CheckBox[] checkboxs     = new CheckBox[] { cbAntenna1, cbAntenna2, cbAntenna3, cbAntenna4 };
                ComboBox[] comboboxReces = new ComboBox[] { cbReceiverSensitivity1, cbReceiverSensitivity2, cbReceiverSensitivity3, cbReceiverSensitivity4 };
                ComboBox[] comboboxTrans = new ComboBox[] { cbTransmiterPower1, cbTransmiterPower2, cbTransmiterPower3, cbTransmiterPower4 };
                SetAntennaIndependentSettings(checkboxs, comboboxReces, comboboxTrans);
            }
            //------Antenna Confiuration------

            //-----Reader Operation Report Sepc-------
            RFIDReaderParameter.rOReportSpec.SelectedROReportTrigger = cbROReportTrigger.Text;
            RFIDReaderParameter.rOReportSpec.ROReportTriggerN        = Convert.ToUInt16(nudN.Value);
            // Tag Report Content Selector
            RFIDReaderParameter.rOReportSpec.EnableROSpecID  = cbEnableROSpecID.Checked;
            RFIDReaderParameter.rOReportSpec.EnableSpecIndex = cbEnableSpecIndex.Checked;
            RFIDReaderParameter.rOReportSpec.EnableInventoryParameterSPecID = cbEnableInventoryParameterSpecID.Checked;
            RFIDReaderParameter.rOReportSpec.EnableAntennaID          = cbEnableAntennaID.Checked;
            RFIDReaderParameter.rOReportSpec.EnableChannelIndex       = cbEnableChannelIndex.Checked;
            RFIDReaderParameter.rOReportSpec.EnablePeakRSSI           = cbEnablePeakRSSI.Checked;
            RFIDReaderParameter.rOReportSpec.EnableFirstSeenTimestamp = cbEnableFirstSeenTimestamp.Checked;
            RFIDReaderParameter.rOReportSpec.EnableLastSeenTimestamp  = cbEnableLastSeenTimestamp.Checked;
            RFIDReaderParameter.rOReportSpec.EnableTagSeenCount       = cbEnableTagSeenCount.Checked;
            RFIDReaderParameter.rOReportSpec.EnableAccessSpecID       = cbEnableAccessSpecID.Checked;
            RFIDReaderParameter.rOReportSpec.EnableCRC    = cbEnableCRC.Checked;
            RFIDReaderParameter.rOReportSpec.EnablePCbits = cbEnablePCBits.Checked;
            // ImpinJ Tag Report Content Selector
            RFIDReaderParameter.rOReportSpec.ImpinJEnableSerializedTID      = cbImpinjEnableSerializedTID.Checked;
            RFIDReaderParameter.rOReportSpec.ImpinJEnableRFPhaseAngle       = cbImpinjEnableRFPhaseAngle.Checked;
            RFIDReaderParameter.rOReportSpec.ImpinJEnablePeakRSSI           = cbImpinjEnablePeakRSSI.Checked;
            RFIDReaderParameter.rOReportSpec.ImpinJEnableGPSCoordinates     = cbImpinjEnableGPSCoordinates.Checked;
            RFIDReaderParameter.rOReportSpec.ImpinJEnableOptimizedRead      = cbImpinjEnableOptimizedRead.Checked;
            RFIDReaderParameter.rOReportSpec.ImpinJEnableRFDopplerFrequency = cbImpinjEnableRFDopplerFrequency.Checked;
            //-----Reader Operation Report Sepc-------
            return(true);
        }
Esempio n. 21
0
 public virtual uint GetEntires(int entire, UIntArray entires, UInt16Array hx, UInt16Array hy)
 {
     return Map_GetEntires(thisptr, entire, (IntPtr)entires, (IntPtr)hx, (IntPtr)hy);
 }
Esempio n. 22
0
 public void Visit(UInt16Array array) => CreateBuffers(array);
Esempio n. 23
0
        public RFIDReaderParameter()
        {
            //------Initialize capabilities------
            // Predefine mode indentifier and official name by ImpinJ_Octane_LLRP.pdf
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable = new Dictionary <string, ushort>();
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("Max Throughput", 0);         //Not supported on R220
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("Hybrid Mode (M=2)", 1);      //Also called High throughput (M=2), Not supported on R220
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("Dense Reader (M=4)", 2);
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("Dense Reader (M=8)", 3);
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("Max Miller(M=4)", 4);        //Also called High throughput (M=4), Not supported by regions that support mode 5.ETSI, China, India, Japan, Korea, and South Africa, Not supported on R220
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("Dense Reader 2 (M=4)", 5);   //Faster forward link than mode 2 Only available with regions: ETSI, China, India, Japan, Korea, and South Africa.
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("AutoSet", 1000);
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("AutoSet Static", 1002);      //Not supported on R220
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("AutoSet Static Fast", 1003); //Not supported on R220
            RFIDReaderParameter.ReaderCapabilities.PreDefinedModeTable.Add("AutoSet Static DRM", 1004);  //Not supported on R220

            RFIDReaderParameter.ReaderCapabilities.Sessions = new Dictionary <string, ushort>();
            RFIDReaderParameter.ReaderCapabilities.Sessions.Add("Session 0", 1);
            RFIDReaderParameter.ReaderCapabilities.Sessions.Add("Session 1", 2);
            RFIDReaderParameter.ReaderCapabilities.Sessions.Add("Session 2", 3);
            RFIDReaderParameter.ReaderCapabilities.Sessions.Add("Session 3", 4);
            //------Initialize capabilities------



            //------Set Default value------
            RFIDReaderParameter.Reset       = true;
            RFIDReaderParameter.IsConnected = false;

            RFIDReaderParameter.ReadMode = "Maunal";
            RFIDReaderParameter.Duration = 90000;

            RFIDReaderParameter.Mask      = String.Empty;
            RFIDReaderParameter.ExtraMask = String.Empty;

            //Antenna Configuration
            RFIDReaderParameter.AntennaConfiguration.Hopping                = false;
            RFIDReaderParameter.AntennaConfiguration.HopTableID             = 0;
            RFIDReaderParameter.AntennaConfiguration.HoppingStep            = 0;
            RFIDReaderParameter.AntennaConfiguration.ChannelIndex           = 1;
            RFIDReaderParameter.AntennaConfiguration.TagInventoryStateAware = false;
            RFIDReaderParameter.AntennaConfiguration.ModeIndex              = 1000;
            RFIDReaderParameter.AntennaConfiguration.Tari                      = 0;
            RFIDReaderParameter.AntennaConfiguration.SelectedSession           = "Session 0";
            RFIDReaderParameter.AntennaConfiguration.SelectedSessionIndex      = 1;
            RFIDReaderParameter.AntennaConfiguration.TagPopulation             = 32;
            RFIDReaderParameter.AntennaConfiguration.TagTransitTime            = 0;
            RFIDReaderParameter.AntennaConfiguration.SelectedSearchMode        = "Dual_Target";
            RFIDReaderParameter.AntennaConfiguration.FixedFrequencyMode        = "Disabled";
            RFIDReaderParameter.AntennaConfiguration.FixedChannelList          = UInt16Array.FromString("");
            RFIDReaderParameter.AntennaConfiguration.FrequencyHopList          = UInt16Array.FromString("");
            RFIDReaderParameter.AntennaConfiguration.ReducedPowerFrequencyMode = false;
            RFIDReaderParameter.AntennaConfiguration.ReducedPowerChannelList   = UInt16Array.FromString(string.Empty);
            RFIDReaderParameter.AntennaConfiguration.LowDutyCycleMode          = false;
            RFIDReaderParameter.AntennaConfiguration.EmptyFieldTimeout         = 2000;
            RFIDReaderParameter.AntennaConfiguration.FieldPingInterval         = 250;

            RFIDReaderParameter.AntennaConfiguration.AntennaID =
                new ushort[RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported];
            RFIDReaderParameter.AntennaConfiguration.AntennaConnected =
                new bool[RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported];
            RFIDReaderParameter.AntennaConfiguration.SelectedReceiverSensitivity =
                new short[RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported];
            RFIDReaderParameter.AntennaConfiguration.SelectedReceiverSensitivityIndex =
                new ushort[RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported];
            RFIDReaderParameter.AntennaConfiguration.SelectedTransmiterPower =
                new double[RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported];
            RFIDReaderParameter.AntennaConfiguration.SelectedTransmiterPowerIndex =
                new ushort[RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported];

            for (int i = 0; i < RFIDReaderParameter.AntennaConfiguration.MaxNumberOfAntennaSupported; i++)
            {
                RFIDReaderParameter.AntennaConfiguration.AntennaID[i] = (ushort)(i + 1);

                if (i == 0)
                {
                    RFIDReaderParameter.AntennaConfiguration.AntennaConnected[i] = true;
                }
                else
                {
                    RFIDReaderParameter.AntennaConfiguration.AntennaConnected[i] = false;
                }

                RFIDReaderParameter.AntennaConfiguration.SelectedReceiverSensitivity[i]      = -70;
                RFIDReaderParameter.AntennaConfiguration.SelectedReceiverSensitivityIndex[i] =
                    RFIDReaderParameter.ReaderCapabilities.ReceiveSensitivityDic[-70];
                RFIDReaderParameter.AntennaConfiguration.SelectedTransmiterPower[i]      = 30;
                RFIDReaderParameter.AntennaConfiguration.SelectedTransmiterPowerIndex[i] =
                    RFIDReaderParameter.ReaderCapabilities.TransmiterPowerDic[30];
            }

            RFIDReaderParameter.ROReportSpec.SelectedROReportTrigger        = "Upon_N_Tags_Or_End_Of_ROSpec";
            RFIDReaderParameter.ROReportSpec.ROReportTriggerN               = 1;
            RFIDReaderParameter.ROReportSpec.EnableROSpecID                 = false;
            RFIDReaderParameter.ROReportSpec.EnableSpecIndex                = false;
            RFIDReaderParameter.ROReportSpec.EnableInventoryParameterSPecID = false;
            RFIDReaderParameter.ROReportSpec.EnableAntennaID                = true;
            RFIDReaderParameter.ROReportSpec.EnableChannelIndex             = true;
            RFIDReaderParameter.ROReportSpec.EnablePeakRSSI                 = true;
            RFIDReaderParameter.ROReportSpec.EnableFirstSeenTimestamp       = true;
            RFIDReaderParameter.ROReportSpec.EnableLastSeenTimestamp        = false;
            RFIDReaderParameter.ROReportSpec.EnableTagSeenCount             = true;
            RFIDReaderParameter.ROReportSpec.EnableAccessSpecID             = false;
            RFIDReaderParameter.ROReportSpec.EnableCRC    = false;
            RFIDReaderParameter.ROReportSpec.EnablePCbits = false;

            RFIDReaderParameter.ROReportSpec.ImpinJEnableSerializedTID      = false;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableRFPhaseAngle       = true;
            RFIDReaderParameter.ROReportSpec.ImpinJEnablePeakRSSI           = true;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableGPSCoordinates     = false;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableOptimizedRead      = false;
            RFIDReaderParameter.ROReportSpec.ImpinJEnableRFDopplerFrequency = true;
            //------Set Default value------
        }
Esempio n. 24
0
 public void Visit(UInt16Array array) => CompareArrays(array);
Esempio n. 25
0
        public static Func <int, T> GetGetter <T>(IArrowArray array)
        {
            if (array is null)
            {
                return(null);
            }

            // TODO: determine fastest way to read out a value from the array.

            if (typeof(T) == typeof(bool))
            {
                var booleanArray = new BooleanArray(array.Data);
                return((Func <int, T>)(object) new Func <int, bool>(
                           index => booleanArray.GetBoolean(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(bool?))
            {
                var booleanArray = new BooleanArray(array.Data);
                return((Func <int, T>)(object) new Func <int, bool?>(booleanArray.GetBoolean));
            }

            if (typeof(T) == typeof(sbyte))
            {
                var int8Array = new Int8Array(array.Data);
                return((Func <int, T>)(object) new Func <int, sbyte>(
                           index => int8Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(sbyte?))
            {
                var int8Array = new Int8Array(array.Data);
                return((Func <int, T>)(object) new Func <int, sbyte?>(int8Array.GetValue));
            }

            if (typeof(T) == typeof(byte))
            {
                var uint8Array = new UInt8Array(array.Data);
                return((Func <int, T>)(object) new Func <int, byte>(
                           index => uint8Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(byte?))
            {
                var uint8Array = new UInt8Array(array.Data);
                return((Func <int, T>)(object) new Func <int, byte?>(uint8Array.GetValue));
            }

            if (typeof(T) == typeof(short))
            {
                var int16Array = new Int16Array(array.Data);
                return((Func <int, T>)(object) new Func <int, short>(
                           index => int16Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(short?))
            {
                var int16Array = new Int16Array(array.Data);
                return((Func <int, T>)(object) new Func <int, short?>(int16Array.GetValue));
            }

            if (typeof(T) == typeof(ushort))
            {
                var uint16Array = new UInt16Array(array.Data);
                return((Func <int, T>)(object) new Func <int, ushort>(
                           index => uint16Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(ushort?))
            {
                var uint16Array = new UInt16Array(array.Data);
                return((Func <int, T>)(object) new Func <int, ushort?>(uint16Array.GetValue));
            }

            if (typeof(T) == typeof(int))
            {
                var int32Array = new Int32Array(array.Data);
                return((Func <int, T>)(object) new Func <int, int>(
                           index => int32Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(int?))
            {
                var int32Array = new Int32Array(array.Data);
                return((Func <int, T>)(object) new Func <int, int?>(int32Array.GetValue));
            }

            if (typeof(T) == typeof(uint))
            {
                var uint32Array = new UInt32Array(array.Data);
                return((Func <int, T>)(object) new Func <int, uint>(
                           index => uint32Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(uint?))
            {
                var uint32Array = new UInt32Array(array.Data);
                return((Func <int, T>)(object) new Func <int, uint?>(uint32Array.GetValue));
            }

            if (typeof(T) == typeof(long))
            {
                var int64Array = new Int64Array(array.Data);
                return((Func <int, T>)(object) new Func <int, long>(
                           index => int64Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(long?))
            {
                var int64Array = new Int64Array(array.Data);
                return((Func <int, T>)(object) new Func <int, long?>(int64Array.GetValue));
            }

            if (typeof(T) == typeof(ulong))
            {
                var uint64Array = new UInt64Array(array.Data);
                return((Func <int, T>)(object) new Func <int, ulong>(
                           index => uint64Array.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(ulong?))
            {
                var uint64Array = new UInt64Array(array.Data);
                return((Func <int, T>)(object) new Func <int, ulong?>(uint64Array.GetValue));
            }

            if (typeof(T) == typeof(double))
            {
                var doubleArray = new DoubleArray(array.Data);
                return((Func <int, T>)(object) new Func <int, double>(
                           index => doubleArray.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(double?))
            {
                var doubleArray = new DoubleArray(array.Data);
                return((Func <int, T>)(object) new Func <int, double?>(doubleArray.GetValue));
            }

            if (typeof(T) == typeof(float))
            {
                var floatArray = new FloatArray(array.Data);
                return((Func <int, T>)(object) new Func <int, float>(
                           index => floatArray.GetValue(index).GetValueOrDefault()));
            }
            if (typeof(T) == typeof(float?))
            {
                var floatArray = new FloatArray(array.Data);
                return((Func <int, T>)(object) new Func <int, float?>(floatArray.GetValue));
            }

            if (typeof(T) == typeof(DateTime))
            {
                if (array.Data.DataType.TypeId == ArrowTypeId.Date32)
                {
                    var date32Array = new Date32Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTime>(
                               index => date32Array.GetDate(index).GetValueOrDefault().DateTime));
                }
                else if (array.Data.DataType.TypeId == ArrowTypeId.Date64)
                {
                    var date64Array = new Date64Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTime>(
                               index => date64Array.GetDate(index).GetValueOrDefault().DateTime));
                }
            }
            if (typeof(T) == typeof(DateTime?))
            {
                if (array.Data.DataType.TypeId == ArrowTypeId.Date32)
                {
                    var date32Array = new Date32Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTime?>(
                               index => date32Array.GetDate(index)?.DateTime));
                }
                else if (array.Data.DataType.TypeId == ArrowTypeId.Date64)
                {
                    var date64Array = new Date64Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTime?>(
                               index => date64Array.GetDate(index)?.DateTime));
                }
            }

            if (typeof(T) == typeof(DateTimeOffset))
            {
                if (array.Data.DataType.TypeId == ArrowTypeId.Date32)
                {
                    var date32Array = new Date32Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTimeOffset>(
                               index => date32Array.GetDate(index).GetValueOrDefault()));
                }
                else if (array.Data.DataType.TypeId == ArrowTypeId.Date64)
                {
                    var date64Array = new Date64Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTimeOffset>(
                               index => date64Array.GetDate(index).GetValueOrDefault()));
                }
            }
            if (typeof(T) == typeof(DateTimeOffset?))
            {
                if (array.Data.DataType.TypeId == ArrowTypeId.Date32)
                {
                    var date32Array = new Date32Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTimeOffset?>(
                               date32Array.GetDate));
                }
                else if (array.Data.DataType.TypeId == ArrowTypeId.Date64)
                {
                    var date64Array = new Date64Array(array.Data);
                    return((Func <int, T>)(object) new Func <int, DateTimeOffset?>(
                               date64Array.GetDate));
                }
            }

            if (typeof(T) == typeof(TimeSpan))
            {
                var timestampArray = new TimestampArray(array.Data);
                return((Func <int, T>)(object) new Func <int, TimeSpan>(
                           index => timestampArray.GetTimestamp(index).GetValueOrDefault().TimeOfDay));
            }
            if (typeof(T) == typeof(TimeSpan?))
            {
                var timestampArray = new TimestampArray(array.Data);
                return((Func <int, T>)(object) new Func <int, TimeSpan?>(
                           index => timestampArray.GetTimestamp(index)?.TimeOfDay));
            }

            if (typeof(T) == typeof(byte[]))
            {
                var binaryArray = new BinaryArray(array.Data);
                return((Func <int, T>)(object) new Func <int, byte[]>(
                           // TODO: how to avoid this allocation/copy?
                           index => binaryArray.GetBytes(index).ToArray()));
            }

            if (typeof(T) == typeof(string))
            {
                var stringArray = new StringArray(array.Data);
                return((Func <int, T>)(object) new Func <int, string>(
                           index => stringArray.GetString(index)));
            }

            // It's something else we don't yet support.
            switch (array.Data.DataType.TypeId)
            {
            case ArrowTypeId.Decimal:
            case ArrowTypeId.Dictionary:
            case ArrowTypeId.FixedSizedBinary:
            case ArrowTypeId.HalfFloat:
            case ArrowTypeId.Interval:
            case ArrowTypeId.List:
            case ArrowTypeId.Map:
            case ArrowTypeId.Null:
            case ArrowTypeId.Struct:
            case ArrowTypeId.Time32:
            case ArrowTypeId.Time64:
            case ArrowTypeId.Union:
            default:
                // TODO: support additional types?
                throw new NotSupportedException(
                          $"Not supported array type: {array.Data.DataType.TypeId}");
            }
        }