Пример #1
0
 public Conversation(Converse converse, String conversationName, IUtilityLog log)
 {
     Converse = converse;
     UtilityLog = log;
     Name = conversationName;
     Messages = new List<Message>();
 }
        public SMABluetooth_Converse(IUtilityLog log)
            : base(log, null)
        {
            initRun = false;

            //Variable var;
            /*
            //var = new BluetoothAddressVar("ADDR"); // used to store the blooth address - value loaded before conversations start
            //Variables.Add(var);
            var = new CRC("CRC", this); // calculates and supplies a CRC when sending a message - calculates the expected CRC for receive messages
            Variables.Add(var);
            var = new TimeVar("TIME", this); // supplies the system time as a protocol variable
            Variables.Add(var);
            var = new StringVar("PASSWORD", this); // supplies a password as a protocol variable
            ((StringVar)var).Value = "0000";
            Variables.Add(var);
            var = new StringVar("TMPL", this); // marks an ???? section in the protocol
            Variables.Add(var);
            var = new StringVar("TMMI", this); // marks an ???? section in the protocol
            Variables.Add(var);
            var = new TimeVar("TIMEFROM1", this); // supplies the FROM time for data retrieval as a protocol variable
            Variables.Add(var);
            var = new TimeVar("TIMETO1", this); // supplies the FROM time for data retrieval as a protocol variable
            Variables.Add(var);

            ByteVar byteVar = new ByteVar("ADD2", 6, this);
            Variables.Add(byteVar);

            byteVar = new ByteVar("INVCODE", 1, this);
            //Byte[] byteVal = new Byte[1];
            //byteVal[0] = 0;
            //byteVar.SetBytes(byteVal, 0, 1); // set an initial value - used for read length only
            Variables.Add(byteVar);

            byteVar = new ByteVar("SIGNAL", 1, this); // receives signal strength
            Variables.Add(byteVar);

            byteVar = new ByteVar("UNKNOWN", 4, this); // marks an unknown section in the protocol
            byteVar.IsUnknown = true;
            Byte[] byteVal = new Byte[4];
            byteVal[0] = 0x3f;
            byteVal[1] = 0x10;
            byteVal[2] = 0xfb;
            byteVal[3] = 0x39;
            byteVar.SetBytes(ref byteVal, 0, 4); // set an initial value - used for read length only
            Variables.Add(byteVar);
             */
        }
        public CC_EnviR_Converse(IUtilityLog log)
            : base(log, null)
        {
            // don't bother with ConversationLoader - it is a very simple pattern
            // below creates the conversation definition

            Conversation conv = new Conversation(this, "CC_EnviR_Receive", log);
            Conversations.Add(conv);
            Message message = new Message(conv, MessageType.Find, "");
            Literal literal = new Literal(Element.StringToHex("<msg>", " "), conv);
            message.Elements.Add(literal);
            conv.Messages.Add(message);

            message = new Message(conv, MessageType.ExtractDynamic, "");
            DynamicByteVar variable = new DynamicByteVar("DATA", 10000, conv);
            Variables.Add(variable);
            UseVariable useVar = new UseVariable(conv, "DATA");
            message.Elements.Add(useVar);
            literal = new Literal(Element.StringToHex("</msg>", " "), conv);
            message.Elements.Add(literal);
            conv.Messages.Add(message);
        }
Пример #4
0
        public GenDatabase(String server, String database, String username, String password, String dbType,
            String providerType, String providerName, String oleDbName, String connectionString, String defaultDirectory, IUtilityLog utilityLog)
        {
            DBLock = new Object();

            Server = server;
            Database = database;
            Username = username;
            Password = password;
            OleDbName = oleDbName;
            ProviderType = providerType;
            ProviderName = providerName;
            ConnectionString = connectionString;
            DBType = dbType;
            DefaultDirectory = defaultDirectory;

            UtilityLog = utilityLog;

            GenDBType = GetDBType(dbType);
            GenProviderType = GetProviderType(providerType);
            GlobalConnection = null;
            // Connections = new List<GenConnection>(10);
            ConnectionCount = 0;

            try
            {
                DbProviderFactory = DbProviderFactories.GetFactory(providerName);
            }
            catch (Exception e)
            {
                throw new GenException(GenExceptionType.ProviderNotFound, "GenDatabase - constructor - cannot find provider: " + providerName + " : " + e.Message, e);
            }

            if (ConnectionString == "")
            {
                ConnectionString = BuildConnectionString();
            }
        }
Пример #5
0
        public Converse(IUtilityLog log, IConverseCheckSum16 calculations, int sendGap = 1200)
        {
            LastSendTime = DateTime.Today;
            SendGap = sendGap;
            UtilityLog = log;
            Conversations = new List<Conversation>();
            Variables = new List<Variable>();
            DeviceStream = null;
            NoTimeout = false;
            if (calculations == null)
            {
                Calculations = (IConverseCheckSum16)new ConverseCalculations();
                // LogMessage("Converse", "Using standard Calculations: " + Calculations.GetType().ToString(), LogEntryType.DetailTrace);
            }
            else
            {
                Calculations = calculations;
                LogMessage("Converse", "Using custom Calculations: " + Calculations.GetType().ToString(), LogEntryType.DetailTrace);
            }

            EndianConverter16Bit = new EndianConverter16Bit(EndianConverter.BigEndian16Bit);
            EndianConverter32Bit = new EndianConverter32Bit(EndianConverter.BigEndian32Bit);
            CheckSumEndianConverter16Bit = EndianConverter16Bit;
        }
Пример #6
0
 public ConversationLoader(String fileName, IUtilityLog log)
 {
     UtilityLog = log;
     StreamReader = new StreamReader(fileName);
     EOF = false;
     Buffer = "";
     BufferPos = 0;
 }
Пример #7
0
 public Phoenixtec_Converse(IUtilityLog log)
     : base(log, null)
 {
     // ByteVar var = new ByteVar("SerialNo", 10);
     // Variables.Add(var);
 }