Пример #1
0
        private void IIns_OnCommandRequest(I2CInstrument instrument, InstrumentCommand command)
        {
            // Send the range change command
            // Get = Set in reverse

            //#define GetFloatTBC 0
            //#define GetFloat 1
            //#define GetKeyChar 2
            //#define ChangeI2CInstrumentRange 3
            //#define SetI2CInstrumentParameter 4
            byte[] bytes = new byte[4 + command.DataBytes.Length];
            bytes[0] = 4;                                  // SetI2CInstrumentParameter
            bytes[1] = (byte)instrument.InstrumentAddress; // instrument address
            bytes[2] = command.ID;                         // param id
            bytes[3] = 1;                                  // dataType from instrument types
            Buffer.BlockCopy(command.DataBytes, 0, bytes, 4, command.DataBytes.Length);
            PacketCommandMini rChangeCom = new PacketCommandMini(PhysLoggerPacketCommandID.GetValue, bytes);

            CommandSendRequest(rChangeCom);
        }
Пример #2
0
        private void I2CInstruments_OnRangeChanged(I2CInstrument instrument, InstrumentRange range)
        {
            // Send the range change command
            // Get = Set in reverse

            //#define GetFloatTBC 0
            //#define GetFloat 1
            //#define GetKeyChar 2
            //#define ChangeI2CInstrumentRange 3
            //#define SetI2CInstrumentParameter 4
            PacketCommandMini rChangeCom = new PacketCommandMini(
                PhysLoggerPacketCommandID.GetValue,
                new byte[] {
                3,
                (byte)instrument.InstrumentAddress,
                range.Code
            }
                );

            CommandSendRequest(rChangeCom);
        }
Пример #3
0
        public static I2CInstrument FromI2C(int i2cAddress, int instrumentID)
        {
            InstrumentCollection list = new InstrumentCollection();

            foreach (var insFile in Directory.GetFiles("Instruments", "*.plf"))
            {
                var ins_ = FromFile(insFile);
                if (ins_ != null)
                {
                    I2CInstrument ins = null;
                    if (ins_ is I2CInstrument)
                    {
                        ins = (I2CInstrument)ins_;
                        if (ins.InstrumentTypeIndex == instrumentID)
                        {
                            ins.InstrumentAddress = i2cAddress;
                            return(ins);
                        }
                    }
                }
            }
            return(null);
        }