internal ItemDefaultSettings(Medium_T AddressSpace, ulong Address)
 {
     addressSpace = AddressSpace;
     address      = Address;
 }
Exemplo n.º 2
0
 private static int HashIndex(int station, int myAddress, Medium_T myDataType)
 {
     return(myAddress);
 }
        AL_ReadData_Result IApplicationLayerSniffer.ReadData(out IBlockDescription block, out IReadValue data)
        {
            lock (this)
            {
                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
                data = null;
                System.Random rand    = new Random((int)(System.DateTime.Now.Ticks % 10000));
                int           station = 1;
                if (rand.Next(10) > 5)
                {
                    station = 2; //tylko 2 stacje - 1 i 2
                }
                data = (IReadValue)pool.GetEmptyISesDBuffer();
                Medium_T dt = Medium_T.Flag;
                if (rand.Next(10) > 5)
                {
                    dt = Medium_T.Register; // 50% szans ze to rejestry
                }
                int    address = 0;         // adres startowy 0-5
                int    len     = 5;         //maksymalna dlugosc bloku 5
                object _value  = false;
                for (int i = address; i < address + len; i++)
                {
                    if (station == 1)
                    {
                        switch (dt)
                        {
                        case Medium_T.Flag:
                        case Medium_T.Input:
                        case Medium_T.Output:
                        {
                            _value = false;
                            if (rand.Next(10) > 4)
                            {
                                _value = true;
                            }
                            break;
                        }

                        case Medium_T.Counter:
                        case Medium_T.Register:
                        case Medium_T.Timer:
                        {
                            _value = (int)rand.Next(1000);
                            break;
                        }
                        }
                    }
                    else
                    {
                        switch (dt)
                        {
                        case Medium_T.Flag:
                        case Medium_T.Input:
                        case Medium_T.Output:
                        {
                            _value = false;
                            break;
                        }

                        case Medium_T.Counter:
                        case Medium_T.Register:
                        case Medium_T.Timer:
                        {
                            _value = 0;
                            break;
                        }
                        }
                    }

                    ((NULL_message)data).setDBTag(station, address, (short)dt, _value);
                }
                ((NULL_message)data).SetBlockDescription(station, address, (short)dt, len);
                ((NULL_message)data).ReadFromDB();
                block = ((NULL_message)data);
                myStatistic.IncStTxFrameCounter();
                myStatistic.IncStRxFrameCounter();
                myStatistic.RxDataBlock(true);
                return(AL_ReadData_Result.ALRes_Success);
            }
        }//ReadData