Exemplo n.º 1
0
 public CloseWindowController(IAppWindow win, IIOPortHandler[] portHandlers)
 {
     _win = win;
     _state = ClosingState.NoClosing;
     _portHandlers = portHandlers;
     _portHandlerClosedStates = new Dictionary<IIOPortHandler, bool>();
     foreach (IIOPortHandler handler in portHandlers)
         _portHandlerClosedStates[handler] = false;
 }
Exemplo n.º 2
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     _adtRec = devices[0];
     if ((_adtRec.PortAddress.Nickname != null) && (_adtRec.PortAddress.Nickname != string.Empty))
     {
         tsrMainToolStrip.Nickname = _adtRec.PortAddress.Nickname;
     }
     else
     {
         tsrMainToolStrip.Nickname = "Device [" + _adtRec.UniqId + "]";
     }
     if (_adtRec.DeviceInfo.DeviceType.TypeID == DeviceTypeID.UDP001)
     {
         _ioph = new IOPH_DATA(_adtRec, this);
     }
     else
     {
         _ioph = new IOPH_DCP(_adtRec, this);
         _teleProcessor = new TelegramSeriesLocalProcessor(this);
     }
     return new IIOPortHandler[] { _ioph };
 }
Exemplo n.º 3
0
 public int setPortHandlers(IIOPortHandler[] portHandlers)
 {
     this._portHandlers = portHandlers;
     return 0;
 }
Exemplo n.º 4
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     this._adtRec = devices[0];
     this._ioph = new IOPH_DATA(this._adtRec, this);
     if ((this._adtRec.PortAddress.Nickname != null) && (this._adtRec.PortAddress.Nickname != string.Empty))
     {
         this.tsrMainToolStrip.Nickname = this._adtRec.PortAddress.Nickname;
     }
     else
     {
         this.tsrMainToolStrip.Nickname = "Device [" + this._adtRec.UniqId + "]";
     }
     this.sbDeviceType.Text = " Device: " + this._adtRec.DeviceInfo.ShowChipName + " " + this._adtRec.PortAddress.objectInfo();
     this.sbChipRevPane.Text = "Chip Revision: " + this._adtRec.DeviceInfo.ShowChipRevision;
     return new IIOPortHandler[] { this._ioph };
 }
Exemplo n.º 5
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] adtRecs)
 {
     if (adtRecs.Length != 1)
     {
         _log.Error("Unexpected number of I/O devices (ADT records)");
         return null;
     }
     this._adtRec = adtRecs[0];
     this._ioph = new IOPH_DATA(adtRecs[0], this);
     this._portHandlerTerminated = false;
     return new IIOPortHandler[] { this._ioph };
 }
Exemplo n.º 6
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] adtRecs)
 {
     if (adtRecs.Length != 1)
     {
         _log.Error("Error: unexpected number of I/O devices (ADT records)");
         return null;
     }
     _appId.Substring(_appId.Length - 3);
     string[] strArray = _appId.Split(new char[] { '_' });
     string nickname = adtRecs[0].PortAddress.Nickname;
     _WdsChipRevForConfigFiles = "WDS3_" + strArray[0] + "_" + adtRecs[0].DeviceInfo.ShowChipRevision;
     if ((adtRecs[0].DeviceInfo.DeviceType != null) && (adtRecs[0].DeviceInfo.DeviceType.TypeID == DeviceTypeID.UDP001))
         _ioph = new IOPH_DATA(adtRecs[0], this);
     else
         _ioph = new IOPH_DCP(adtRecs[0], this);
     _portHandlerTerminated = false;
     return new IIOPortHandler[] { _ioph };
 }
Exemplo n.º 7
0
        public static TelegramContainerItem[] createTelegramsFromBatchString(string commands, IIOPortHandler ioph, IAppMainWindow mainWin, bool ctsPoll, DeviceRegisterSet deviceRegSet, ChipCommandAndPpropertyDescriptor chipApiDescriptor, out string errorMessage)
        {
            errorMessage = "No Error";
            string[] strArray = commands.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            List<TelegramContainerItem> list = new List<TelegramContainerItem>();
            bool flag = false;
            for (int i = 0; i < strArray.Length; i++)
            {
                Telegram telegram;
                LastReplyPrecondition invalid;
                byte[] buffer;
                byte[][] bufferArray4;
                byte[] buffer8;
                flag = false;
                if ((strArray[i].Trim().Length >= 2) && !strArray[i].Trim().StartsWith("#"))
                {
                    if (strArray[i].Trim().ToUpper().StartsWith("DELAY"))
                    {
                        int num2;
                        if (int.TryParse(strArray[i].Trim().ToUpper().Replace("DELAY", "").Trim(), out num2))
                        {
                            list.Add(new TelegramContainerItem(num2));
                        }
                    }
                    else if (strArray[i].Trim().ToUpper().StartsWith("RESET"))
                    {
                        bufferArray4 = new byte[5][];
                        bufferArray4[0] = new byte[] { 0x12, 6, 1, 0 };
                        bufferArray4[1] = new byte[] { 0x13, 6, 1 };
                        buffer8 = new byte[3];
                        buffer8[0] = 0x13;
                        buffer8[1] = 6;
                        bufferArray4[2] = buffer8;
                        byte[] buffer9 = new byte[4];
                        buffer9[0] = 0x12;
                        buffer9[1] = 0x1b;
                        bufferArray4[3] = buffer9;
                        bufferArray4[4] = new byte[] { 20, 0x1b };
                        byte[][] bufferArray = bufferArray4;
                        LastReplyPrecondition[] preconditionArray = new LastReplyPrecondition[] { LastReplyPrecondition.ACK, LastReplyPrecondition.ACK, LastReplyPrecondition.ACK, LastReplyPrecondition.ACK, LastReplyPrecondition.DataACK };
                        for (int j = 0; j < bufferArray.Length; j++)
                        {
                            telegram = new Telegram(bufferArray[j].Length) {
                                uniqId = GlobalServices.uniqTelegramId(),
                                parentUniqId = -1,
                                type = TelegramType.Command
                            };
                            if (ioph is IOPH_DCP)
                            {
                                telegram.protocol = Protocol.DCP;
                                telegram.DCPCmdSet = 4;
                            }
                            else
                            {
                                telegram.protocol = Protocol.DCP2;
                                telegram.DCPCmdSet = 0x1c;
                            }
                            telegram.lastReplyPrecondition = preconditionArray[j];
                            telegram.replySize = 15;
                            telegram.UserData = new object[] { false };
                            if (j == 0)
                            {
                                telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                                telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                            }
                            if (telegram.replySize == -1)
                            {
                                throw new Exception("Not supported command.");
                            }
                            telegram.data.copy(bufferArray[j]);
                            telegram.portHandler = ioph;
                            telegram.mainWin = mainWin;
                            list.Add(new TelegramContainerItem(telegram));
                        }
                    }
                    else if (strArray[i].Trim().ToUpper().StartsWith("SHUTDOWN"))
                    {
                        byte[][] bufferArray2 = new byte[][] { new byte[] { 0x12, 6, 1, 0 }, new byte[] { 0x13, 6, 1 } };
                        LastReplyPrecondition[] preconditionArray2 = new LastReplyPrecondition[] { LastReplyPrecondition.ACK, LastReplyPrecondition.ACK };
                        for (int k = 0; k < bufferArray2.Length; k++)
                        {
                            telegram = new Telegram(bufferArray2[k].Length) {
                                uniqId = GlobalServices.uniqTelegramId(),
                                parentUniqId = -1,
                                type = TelegramType.Command
                            };
                            if (ioph is IOPH_DCP)
                            {
                                telegram.protocol = Protocol.DCP;
                                telegram.DCPCmdSet = 4;
                            }
                            else
                            {
                                telegram.protocol = Protocol.DCP2;
                                telegram.DCPCmdSet = 0x1c;
                            }
                            telegram.lastReplyPrecondition = preconditionArray2[k];
                            telegram.replySize = 15;
                            telegram.UserData = new object[] { false };
                            if (k == 0)
                            {
                                telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                                telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                            }
                            if (telegram.replySize == -1)
                            {
                                throw new Exception("Not supported command.");
                            }
                            telegram.data.copy(bufferArray2[k]);
                            telegram.portHandler = ioph;
                            telegram.mainWin = mainWin;
                            list.Add(new TelegramContainerItem(telegram));
                        }
                    }
                    else
                    {
                        if (!strArray[i].Trim().ToUpper().StartsWith("DCP"))
                        {
                            goto Label_064D;
                        }
                        invalid = LastReplyPrecondition.Invalid;
                        buffer = new byte[1];
                        if (strArray[i].Trim().Length <= 3)
                        {
                            goto Label_0523;
                        }
                        switch (strArray[i].Trim().ToUpper()[3])
                        {
                            case 'A':
                                invalid = LastReplyPrecondition.ACK;
                                goto Label_04F9;

                            case 'D':
                                invalid = LastReplyPrecondition.DataACK;
                                goto Label_04F9;

                            case 'I':
                                invalid = LastReplyPrecondition.Indication;
                                goto Label_04F9;
                        }
                    }
                }
                continue;
            Label_04F9:
                buffer = WDSConverters.ToByteArray(strArray[i].Substring(4).Trim().Replace(" ", "").ToUpper());
            Label_0523:
                telegram = new Telegram(buffer.Length);
                telegram.uniqId = GlobalServices.uniqTelegramId();
                telegram.parentUniqId = -1;
                telegram.type = TelegramType.Command;
                if (ioph is IOPH_DCP)
                {
                    telegram.protocol = Protocol.DCP;
                    telegram.DCPCmdSet = 4;
                }
                else
                {
                    telegram.protocol = Protocol.DCP2;
                    telegram.DCPCmdSet = 0x1c;
                }
                telegram.lastReplyPrecondition = invalid;
                telegram.replySize = 15;
                telegram.UserData = new object[] { false };
                telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                if (telegram.replySize == -1)
                {
                    throw new Exception("Not supported command.");
                }
                telegram.data.copy(buffer);
                telegram.portHandler = ioph;
                telegram.mainWin = mainWin;
                list.Add(new TelegramContainerItem(telegram));
                continue;
            Label_064D:
                if (strArray[i].Trim().ToUpper().StartsWith("RAM"))
                {
                    string str;
                    if (!getDataFromFwLoadCommand(strArray[i].Trim(), out str))
                    {
                        _log.Error("Cannot create RAM Load telegram from command string");
                    }
                    else
                    {
                        string str2;
                        StreamReader reader = File.OpenText(str);
                        byte[] buf = new byte[0x800];
                        int index = 0;
                        while (((str2 = reader.ReadLine()) != null) && (index < buf.Length))
                        {
                            if (byte.TryParse(str2, NumberStyles.HexNumber, (IFormatProvider) null, out buf[index]))
                            {
                                index++;
                            }
                        }
                        if (index == 0)
                        {
                            _log.Error("Could not read any RAM data from the RAM Load file");
                        }
                        else
                        {
                            bufferArray4 = new byte[0x11][];
                            buffer8 = new byte[4];
                            buffer8[0] = 0x10;
                            buffer8[3] = 1;
                            bufferArray4[0] = buffer8;
                            bufferArray4[1] = new byte[] { 0x10, 3, 0, 7, 80 };
                            bufferArray4[2] = new byte[] { 0x10, 4, 0, 7, 80, 0 };
                            bufferArray4[3] = new byte[] { 0x10, 4, 0, 7, 80, 0 };
                            bufferArray4[4] = new byte[] { 0x10, 3, 0, 7, 80 };
                            bufferArray4[5] = new byte[] { 0x10, 4, 0, 0x6d, 80, 1 };
                            bufferArray4[6] = new byte[] { 0x10, 4, 0, 1, 80, 0xff };
                            bufferArray4[7] = new byte[] { 0x10, 4, 0, 0xac, 80, 0x1f };
                            bufferArray4[8] = new byte[] { 0x10, 7, 0, 0x94, 0x54, 0x53 };
                            bufferArray4[9] = new byte[] { 0x10, 7, 0, 0x95, 0x54, 0x30 };
                            bufferArray4[10] = new byte[] { 0x10, 0x45, 0, 0x88 };
                            buffer8 = new byte[3];
                            buffer8[0] = 0x10;
                            buffer8[1] = 0x85;
                            bufferArray4[11] = buffer8;
                            buffer8 = new byte[3];
                            buffer8[0] = 0x10;
                            buffer8[1] = 0xc5;
                            bufferArray4[12] = buffer8;
                            bufferArray4[13] = new byte[] { 0x10, 3, 0, 7, 80 };
                            bufferArray4[14] = new byte[] { 0x10, 4, 0, 7, 80, 9 };
                            bufferArray4[15] = new byte[] { 0x10, 4, 0, 7, 80, 9 };
                            bufferArray4[0x10] = new byte[] { 0x10, 3, 0, 7, 80 };
                            byte[][] bufferArray3 = bufferArray4;
                            int num6 = 0;
                            for (int m = 0; m < bufferArray3.Length; m++)
                            {
                                telegram = new Telegram(bufferArray3[m].Length) {
                                    uniqId = GlobalServices.uniqTelegramId(),
                                    parentUniqId = -1,
                                    type = TelegramType.Command
                                };
                                if (ioph is IOPH_DCP)
                                {
                                    telegram.protocol = Protocol.DCP;
                                    telegram.DCPCmdSet = 4;
                                }
                                else
                                {
                                    telegram.protocol = Protocol.DCP2;
                                    telegram.DCPCmdSet = 0x1c;
                                }
                                telegram.lastReplyPrecondition = LastReplyPrecondition.Indication;
                                telegram.replySize = 15;
                                telegram.UserData = new object[] { false };
                                if (m == 0)
                                {
                                    telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                                    telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                                }
                                if (telegram.replySize == -1)
                                {
                                    throw new Exception("Not supported command.");
                                }
                                telegram.data.copy(bufferArray3[m]);
                                if ((m == 11) && (num6 < 0x10))
                                {
                                    telegram.data.appendFromStartIdx(buf, num6 * 0x79, 0x79);
                                    num6++;
                                    m--;
                                }
                                else if (m == 12)
                                {
                                    telegram.data.appendFromStartIdx(buf, buf.Length - 0x70, 0x70);
                                }
                                else if (m == 11)
                                {
                                    continue;
                                }
                                telegram.portHandler = ioph;
                                telegram.mainWin = mainWin;
                                list.Add(new TelegramContainerItem(telegram));
                            }
                        }
                    }
                }
                else if (strArray[i].Trim().ToUpper().StartsWith("PATCH"))
                {
                    string str3;
                    if (!getDataFromFwLoadCommand(strArray[i].Trim(), out str3))
                    {
                        _log.Error("Cannot create PATCH Load telegram from command string");
                    }
                    else
                    {
                        string str4;
                        StreamReader reader2 = File.OpenText(str3);
                        List<byte[]> list2 = new List<byte[]>();
                        while ((str4 = reader2.ReadLine()) != null)
                        {
                            byte[] item = new byte[8];
                            if (!str4.Trim().StartsWith("#"))
                            {
                                string[] strArray2 = str4.Split(new char[] { ',' });
                                for (int n = 0; (n < strArray2.Length) && (n < item.Length); n++)
                                {
                                    string s = strArray2[n];
                                    if (strArray2[n].StartsWith("0x"))
                                    {
                                        s = s.Substring(2);
                                    }
                                    if (!byte.TryParse(s, NumberStyles.HexNumber, (IFormatProvider) null, out item[n]))
                                    {
                                        _log.Error("Invalid data in PATCH Load file");
                                    }
                                }
                                list2.Add(item);
                            }
                        }
                        if (list2.Count == 0)
                        {
                            _log.Error("Could not read any PATCH data from the RAM Load file");
                        }
                        else
                        {
                            buffer8 = new byte[3];
                            buffer8[0] = 0x10;
                            byte[] buffer4 = buffer8;
                            byte[] buffer5 = new byte[] { 0x10, 0, 0, 0x44, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
                            for (int num9 = 0; num9 < (list2.Count * 2); num9++)
                            {
                                telegram = new Telegram(10) {
                                    uniqId = GlobalServices.uniqTelegramId(),
                                    parentUniqId = -1,
                                    type = TelegramType.Command
                                };
                                if (ioph is IOPH_DCP)
                                {
                                    telegram.protocol = Protocol.DCP;
                                    telegram.DCPCmdSet = 4;
                                }
                                else
                                {
                                    telegram.protocol = Protocol.DCP2;
                                    telegram.DCPCmdSet = 0x1c;
                                }
                                telegram.lastReplyPrecondition = LastReplyPrecondition.Indication;
                                telegram.replySize = 15;
                                if (num9 == 0)
                                {
                                    telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                                    telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                                }
                                if (telegram.replySize == -1)
                                {
                                    throw new Exception("Not supported command.");
                                }
                                if ((num9 % 2) == 0)
                                {
                                    telegram.data.copy(buffer4);
                                    telegram.data.appendFromStartIdx(list2[num9 / 2], 0, list2[num9 / 2].Length);
                                }
                                else
                                {
                                    telegram.data.copy(buffer5);
                                }
                                telegram.portHandler = ioph;
                                telegram.mainWin = mainWin;
                                list.Add(new TelegramContainerItem(telegram));
                            }
                        }
                    }
                }
                else if (strArray[i].Trim().ToUpper().StartsWith("TCL"))
                {
                    int num10;
                    string str6;
                    if (!getDataFromTclCommand(strArray[i].Trim(), out num10, out str6))
                    {
                        _log.Error("Cannot create TCL telegram from command string");
                    }
                    else
                    {
                        telegram = new Telegram(str6.Length) {
                            TimeOut = num10 * 0x3e8,
                            uniqId = GlobalServices.uniqTelegramId(),
                            parentUniqId = -1,
                            type = TelegramType.ExecuteTclScript
                        };
                        if (ioph is IOPH_DCP)
                        {
                            telegram.protocol = Protocol.DCP;
                            telegram.DCPCmdSet = 4;
                        }
                        else
                        {
                            telegram.protocol = Protocol.DCP2;
                            telegram.DCPCmdSet = 0x1c;
                        }
                        telegram.replySize = 15;
                        telegram.UserData = new object[] { false };
                        telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                        telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                        if (telegram.replySize == -1)
                        {
                            throw new Exception("Not supported command.");
                        }
                        telegram.data.copy(str6);
                        telegram.userData = 3;
                        telegram.portHandler = ioph;
                        telegram.mainWin = mainWin;
                        list.Add(new TelegramContainerItem(telegram));
                    }
                }
                else
                {
                    int numberOfReplyData = 0;
                    List<byte> list3 = new List<byte>();
                    string[] strArray3 = strArray[i].Trim().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    bool flag2 = false;
                    bool isPeekPoke = false;
                    byte num12 = 0;
                    bool flag4 = false;
                    bool flag5 = false;
                    for (int num13 = 0; num13 < strArray3.Length; num13++)
                    {
                        if ((strArray3[num13].Trim().ToUpper() == "DW") || (strArray3[num13].Trim().ToUpper() == "DR"))
                        {
                            flag2 = true;
                            isPeekPoke = false;
                            flag4 = true;
                            if (strArray3[num13].Trim() == "DW")
                            {
                                num12 = 4;
                            }
                            else
                            {
                                num12 = 3;
                                flag5 = true;
                            }
                        }
                        else
                        {
                            if ((strArray3[num13].Trim().ToUpper() == "'PEEK'") || (strArray3[num13].Trim().ToUpper() == "'POKE'"))
                            {
                                isPeekPoke = true;
                            }
                            byte[] array = null;
                            if (strArray3[num13].Trim().StartsWith("'"))
                            {
                                if (!isPeekPoke || (num13 == 0))
                                {
                                    array = chipApiDescriptor.getByteRepresentationByAPIName(strArray3[num13].Trim(new char[] { '\'' }));
                                }
                                if (array == null)
                                {
                                    array = SPI_tools.getByteRepresentationByRegisterName(strArray3[num13].Trim(new char[] { '\'' }), isPeekPoke, deviceRegSet);
                                }
                                if (array == null)
                                {
                                    errorMessage = "Line number: " + i.ToString() + "\nInvalid command: " + strArray[i].Trim();
                                    return null;
                                }
                                if ((num13 == 0) && (chipApiDescriptor.getCommandById(array[0]).NumberOfReplyData > 1))
                                {
                                    flag = true;
                                    numberOfReplyData = chipApiDescriptor.getCommandById(array[0]).NumberOfReplyData;
                                }
                                if (flag2)
                                {
                                    Array.Reverse(array);
                                    flag2 = false;
                                }
                                if (((list3.Count == 1) && ((list3[0] == chipApiDescriptor.SetPropertyCommandId) || (list3[0] == chipApiDescriptor.GetPropertyCommandId))) && (array.Length == 2))
                                {
                                    List<byte> list4 = new List<byte>(array);
                                    list4.Insert(1, 1);
                                    array = list4.ToArray();
                                }
                                if ((flag4 && (array.Length == 2)) && (array[1] == 0x54))
                                {
                                    num12 = (byte) (num12 + 3);
                                }
                                if ((isPeekPoke && (array.Length == 2)) && (array[0] == 0x54))
                                {
                                    array[0] = 0;
                                }
                                foreach (byte num14 in array)
                                {
                                    list3.Add(num14);
                                }
                            }
                            else
                            {
                                byte num15;
                                if ((strArray3[num13].Trim().Length <= 2) && byte.TryParse(strArray3[num13].Trim(), NumberStyles.HexNumber, (IFormatProvider) null, out num15))
                                {
                                    if ((num13 == 0) && (chipApiDescriptor.getCommandById(num15).NumberOfReplyData > 1))
                                    {
                                        flag = true;
                                        numberOfReplyData = chipApiDescriptor.getCommandById(num15).NumberOfReplyData;
                                    }
                                    list3.Add(num15);
                                }
                                else
                                {
                                    errorMessage = "Line number: " + i.ToString() + "\nInvalid command: " + strArray[i].Trim();
                                    return null;
                                }
                            }
                        }
                    }
                    if (list3.Count != 0)
                    {
                        if (list3.Count == 1)
                        {
                            list3.Add(0);
                        }
                        telegram = new Telegram(list3.Count + 3) {
                            uniqId = GlobalServices.uniqTelegramId(),
                            parentUniqId = -1,
                            type = TelegramType.Command,
                            lastReplyPrecondition = LastReplyPrecondition.Indication,
                        };
                        if (ioph is IOPH_DCP)
                        {
                            telegram.protocol = Protocol.DCP;
                            telegram.DCPCmdSet = 4;
                        }
                        else
                        {
                            telegram.protocol = Protocol.DCP2;
                            telegram.DCPCmdSet = 0x1c;
                        }
                        buffer8 = new byte[3];
                        buffer8[0] = 0x10;
                        buffer8[1] = num12;
                        telegram.data.copy(buffer8);
                        telegram.data.append(list3.ToArray(), list3.Count);
                        telegram.SenderInfo = new object[] { strArray[i].Trim(new char[] { '\r' }).Trim() };
                        telegram.UserDataExt.addUserData("CmdName", strArray[i].Trim(new char[] { '\r' }).Trim());
                        telegram.portHandler = ioph;
                        telegram.mainWin = mainWin;
                        list.Add(new TelegramContainerItem(telegram));
                        if (flag)
                        {
                            telegram = new Telegram(13) {
                                uniqId = GlobalServices.uniqTelegramId(),
                                parentUniqId = -1,
                                type = TelegramType.Command,
                                lastReplyPrecondition = LastReplyPrecondition.Indication
                            };
                            if (ioph is IOPH_DCP)
                            {
                                telegram.protocol = Protocol.DCP;
                                telegram.DCPCmdSet = 4;
                            }
                            else
                            {
                                telegram.protocol = Protocol.DCP2;
                                telegram.DCPCmdSet = 0x1c;
                            }
                            buffer8 = new byte[4];
                            buffer8[0] = 0x10;
                            buffer8[3] = 0x44;
                            telegram.data.copy(buffer8);
                            byte[] buffer7 = new byte[numberOfReplyData];
                            for (int num16 = 0; num16 < buffer7.Length; num16++)
                            {
                                buffer7[num16] = 0xff;
                            }
                            telegram.data.append(buffer7, buffer7.Length);
                            telegram.UserDataExt.addUserData("normalLogReply", true);
                            telegram.portHandler = ioph;
                            telegram.mainWin = mainWin;
                            list.Add(new TelegramContainerItem(telegram));
                        }
                        else if (((list[list.Count - 1].telegram.data.NumItems != 5) || (list[list.Count - 1].telegram.data.Buf[3] != 0x34)) && ctsPoll)
                        {
                            if (!flag4)
                            {
                                telegram = new Telegram(13) {
                                    uniqId = GlobalServices.uniqTelegramId(),
                                    parentUniqId = -1,
                                    type = TelegramType.Command,
                                    lastReplyPrecondition = LastReplyPrecondition.Indication
                                };
                                if (ioph is IOPH_DCP)
                                {
                                    telegram.protocol = Protocol.DCP;
                                    telegram.DCPCmdSet = 4;
                                }
                                else
                                {
                                    telegram.protocol = Protocol.DCP2;
                                    telegram.DCPCmdSet = 0x1c;
                                }
                                telegram.data.copy(new byte[] { 0x10, 0, 0, 0x44, 0xff });
                                telegram.UserDataExt.addUserData("normalLogReply", true);
                                telegram.portHandler = ioph;
                                telegram.mainWin = mainWin;
                                list.Add(new TelegramContainerItem(telegram));
                            }
                            else if (flag5)
                            {
                                list[list.Count - 1].telegram.UserDataExt.addUserData("debugLogReply", true);
                            }
                        }
                    }
                }
            }
            if (list.Count == 0)
            {
                errorMessage = "Did not recognized any executable commands!";
                return null;
            }
            return list.ToArray();
        }
Exemplo n.º 8
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     this._adtRec = devices[0];
     if ((this._adtRec.DeviceInfo.DeviceType != null) && (this._adtRec.DeviceInfo.DeviceType.TypeID == DeviceTypeID.SRW002))
     {
         this._ioph = new IOPH_DCP(this._adtRec, this);
         this._teleProcessor = new NewWDS.Applications.App_Common.TelegramProcessor.TelegramSeriesLocalProcessor(this, this._ioph);
     }
     else
     {
         this._ioph = new IOPH_DATA(this._adtRec, this);
     }
     if ((this._adtRec.PortAddress.Nickname != null) && (this._adtRec.PortAddress.Nickname != string.Empty))
     {
         this.tsrMainToolStrip.Nickname = this._adtRec.PortAddress.Nickname;
     }
     else
     {
         this.tsrMainToolStrip.Nickname = "Device [" + this._adtRec.UniqId + "]";
     }
     this.sbDeviceType.Text = " Device: " + this._adtRec.DeviceInfo.ShowChipName + " " + this._adtRec.PortAddress.objectInfo();
     this.sbChipRevPane.Text = "Chip Revision: " + this._adtRec.DeviceInfo.ShowChipRevision;
     return new IIOPortHandler[] { this._ioph };
 }
Exemplo n.º 9
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     this._adtRec = devices[0];
     this._ioph = new IOPH_DATA(this._adtRec, this);
     this.sbDeviceType.Text = " Device: " + this._adtRec.DeviceInfo.ShowChipName + " " + this._adtRec.PortAddress.objectInfo();
     this.sbChipRevPane.Text = "Chip Revision: " + this._adtRec.DeviceInfo.ShowChipRevision;
     return new IIOPortHandler[] { this._ioph };
 }
Exemplo n.º 10
0
Arquivo: Telegram.cs Projeto: x893/WDS
 public int copy(Telegram another)
 {
     this.data.copy(another.data);
     this.uniqId = another.uniqId;
     this.parentUniqId = another.parentUniqId;
     this.type = another.type;
     this.lastReplyPrecondition = another.lastReplyPrecondition;
     this.numOfLastReplyPackets = another.numOfLastReplyPackets;
     this._TimeOut = another.TimeOut;
     this._userData = another._userData;
     this._userDataExt.copy(another.UserDataExt);
     this.CallbackEvent = another.CallbackEvent;
     this.protocol = another.protocol;
     this.replySize = another.replySize;
     this.mainWin = another.mainWin;
     this.portHandler = another.portHandler;
     this.appFuncId = another.appFuncId;
     this.userData = another.userData;
     this._hasHeader = another.HasHeader;
     this.DCPCmdSet = another.DCPCmdSet;
     this.DCPMsgType = another.DCPMsgType;
     return 0;
 }
Exemplo n.º 11
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     this._adtRec = devices[0];
     if ((this._adtRec.PortAddress.Nickname != null) && (this._adtRec.PortAddress.Nickname != string.Empty))
     {
         this.tsrMainToolStrip.Nickname = this._adtRec.PortAddress.Nickname;
     }
     else
     {
         this.tsrMainToolStrip.Nickname = "Device [" + this._adtRec.UniqId + "]";
     }
     if ((this._adtRec.DeviceInfo.DeviceType != null) && (this._adtRec.DeviceInfo.DeviceType.TypeID == DeviceTypeID.SRW002))
     {
         this._ioph = new IOPH_DCP(this._adtRec, this);
         this._teleProcessor = new TelegramSeriesLocalProcessor(this);
     }
     else
     {
         this._ioph = new IOPH_DATA(this._adtRec, this);
         try
         {
             this.tbcCommandTypeSelector.TabPages.Remove(this.tbpTclScriptCall);
         }
         catch
         {
             _log.Error("Removing tbpTclScriptCall tab failed!");
         }
     }
     return new IIOPortHandler[] { this._ioph };
 }
Exemplo n.º 12
0
 public IIOPortHandler[] createPortHandlers(ADTRecord[] devices)
 {
     _adtRec = devices[0];
     _ioph = new IOPH_DATA(_adtRec, this);
     if (_adtRec.PortAddress.Nickname != null)
     {
         bool flag1 = _adtRec.PortAddress.Nickname != string.Empty;
     }
     sbDeviceType.Text = " Device: " + _adtRec.DeviceInfo.ShowChipName + " " + _adtRec.PortAddress.objectInfo();
     sbChipRevPane.Text = "Chip Revision: " + _adtRec.DeviceInfo.ShowChipRevision;
     return new IIOPortHandler[] { _ioph };
 }
Exemplo n.º 13
0
 public TelegramSeriesLocalProcessor(IAppMainWindow mainWin, IIOPortHandler ioph)
 {
     this._mainWin = mainWin;
     this._ioph = (IOPH_DCP) ioph;
 }
Exemplo n.º 14
0
 public void portHandlerClosed(IIOPortHandler portHandler)
 {
     if (portHandler == null)
         WDSApplicationManager.instance().closeResourcesReady(_win);
     else
     {
         _portHandlerClosedStates[portHandler] = true;
         using (Dictionary<IIOPortHandler, bool>.ValueCollection.Enumerator enumerator = _portHandlerClosedStates.Values.GetEnumerator())
             while (enumerator.MoveNext())
                 if (!enumerator.Current)
                     return;
         WDSApplicationManager.instance().closeResourcesReady(_win);
     }
 }