Esempio n. 1
0
 void runScan()
 {
     while (appRunning)
     {
         string a = ComPort.ReadLine();
     }
     main.Abort();
 }
Esempio n. 2
0
        public Port(ref ComPort _drvcport)
        {
            InitializeComponent();

            // Initialize communication port
            _port = _drvcport;
            InitializePortConfiguration(_port.PortConfig);
        }
        public void CreateTest_001()
        {
            ComPortViewModel VM   = ComPortViewModel.Create("Name", "Device");
            ComPort          Port = new ComPort("Name", "Device");

            Assert.IsTrue(VM.ComPort.Equals(Port));
            Assert.AreEqual(VM.PortName, "Name");
        }
Esempio n. 4
0
 public void Close()
 {
     if (ComPortIsOpen == true)
     {
         ComPort.Close();
         ComPortIsOpen = false;
     }
 }
Esempio n. 5
0
 private void setControl()
 {
     cpt            = ebC.eB20DB.cptDB.selectByPk1("1");
     cboBaud.Text   = cpt.baud_rate;
     cboParity.Text = cpt.parity;
     cboStop.Text   = cpt.stop_bit;
     cboData.Text   = cpt.data_bit;
 }
Esempio n. 6
0
        /// <summary>
        /// Load datasources and saved options
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void optionsForm_Load(object sender, EventArgs e)
        {
            //Set combobox data sources
            comPortComboBox.DataSource = ComPort.RetrieveComPortList();

            //Retrieve saved options
            comPortComboBox.SelectedItem     = Settings.Default.ComPort;
            connectOnStartupCheckBox.Checked = Settings.Default.ConnectOnStartup;
        }
 public DMPS3TwoWaySerialDriver(ComPort ComPort) : base(ComPort)
 {
     if (ComPort.Supports422 || ComPort.Supports485 || !ComPort.SupportsRTSCTS)
     {
         throw new NotSupportedException(string.Format("{0} ComPort is not a DMPS3 Two Way Serial Driver", ComPort.DeviceName));
     }
     Start();
     LocalStart();
 }
Esempio n. 8
0
 public bool Close()
 {
     try
     {
         ComPort.Close();
     }
     catch { }
     return(true);
 }
Esempio n. 9
0
        public ACS(bool _IsLittleEndian)
        {
            IsLittleEndian = _IsLittleEndian;
#if ACS_VIRTUAL
            comPort = new ComPortBase(ParAll.ST.Defect.ComPortASC, pr);
#else
            comPort = ComPort.Create(ParAll.ST.Defect.ComPortASC, pr);
#endif
        }
Esempio n. 10
0
 public RS232OnlyTwoWaySerialDriver(ComPort ComPort) : base(ComPort)
 {
     if (ComPort.Supports422 || ComPort.Supports485)
     {
         throw new NotSupportedException("ComPort is not an RS232 only Two Way Serial Driver");
     }
     Start();
     LocalStart();
 }
Esempio n. 11
0
        void ISerialDriver.GetPins(int serialPortNum, out uint rxPin, out uint txPin, out uint ctsPin, out uint rtsPin)
        {
            ComPort comPort = GetComPort(serialPortNum);

            rxPin  = (uint)comPort.RxPin;
            txPin  = (uint)comPort.TxPin;
            ctsPin = (uint)comPort.CtsPin;
            rtsPin = (uint)comPort.RtsPin;
        }
Esempio n. 12
0
        public void RefeshSerialPort()
        {
            ComPort.Clear();

            foreach (string searchPort in SerialPort.GetPortNames())
            {
                ComPort.Add(searchPort);
            }
        }
Esempio n. 13
0
 public void PortClose()
 {
     if (ComPortIsOpen == true)
     {
         ComPort.Close();
         ComPortIsOpen = false;
         EnableComButton();
     }
 }
Esempio n. 14
0
        /// <summary>
        /// Constructor for COM
        /// </summary>
        public SamsungMDC(string key, string name, ComPort port, ComPort.ComPortSpec spec, string id)
            : base(key, name)
        {
            Communication = new ComPortController(key + "-com", port, spec);
            //Communication.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Communication_TextReceived);

            ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor
            Init();
        }
Esempio n. 15
0
 public WorkWithArduinoForm()
 {
     InitializeComponent();
     Init();
     _dbClass = new DbClass();
     _dbClass.Connect("valentin", "12345678", "mydatabase");
     _comPort = new ComPort(comboBox1.Text, 9600);
     //_comPort.timer_inint(timer1_Elapsed);
 }
        public ComPortController(string key, IComPorts ComDevice, uint comPortNum, ComPort.ComPortSpec spec)
            : base(key)
        {
            Port = ComDevice.ComPorts[comPortNum];
            Spec = spec;

            Debug.Console(2, "Creating com port '{0}'", key);
            Debug.Console(2, "Com port spec:\r{0}", JsonConvert.SerializeObject(spec));
        }
        /// <summary>
        /// Constructor of the Control System Class. Make sure the constructor always exists.
        /// If it doesn't exit, the code will not run on your 3-Series processor.
        /// </summary>
        public ControlSystem() : base()
        {
            // subscribe to control system events
            CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(CrestronEnvironment_SystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
            CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);

            // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
            // define the max number of threads which we will use in the system.
            // the right number depends on your project; do not make this number unnecessarily large
            Thread.MaxNumberOfUserThreads = 20;


            if (this.SupportsComPort)
            {
                MyCOMPort = this.ComPorts[1];
                MyCOMPort.SerialDataReceived += new ComPortDataReceivedEvent(myComPort_SerialDataReceived);

                if (MyCOMPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("COM Port couldn't be registered. Cause: {0}", MyCOMPort.DeviceRegistrationFailureReason);
                }

                if (MyCOMPort.Registered)
                {
                    MyCOMPort.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate9600,
                                             ComPort.eComDataBits.ComspecDataBits8,
                                             ComPort.eComParityType.ComspecParityNone,
                                             ComPort.eComStopBits.ComspecStopBits1,
                                             ComPort.eComProtocolType.ComspecProtocolRS232,
                                             ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                             ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                             false);
                }
            }

            // ensure this processor has ethernet then setup the EISC
            if (this.SupportsEthernet)
            {
                myEISC = new EthernetIntersystemCommunications(eISCIPID, eISCIP, this);
                if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error(">>> The EISC was not registered: {0}", myEISC.RegistrationFailureReason);
                }
                else
                {
                    // Device has been registered. Now register for the event handlers
                    myEISC.OnlineStatusChange += new OnlineStatusChangeEventHandler(myEISC_OnlineStatusChange);
                    myEISC.SigChange          += new SigEventHandler(myEISC_SigChange);
                    ErrorLog.Notice(">>> The EISC has been registered successfully");
                }
            }
            else
            {
                ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run");
            }
        }
Esempio n. 18
0
 private void DataReceive(object obj, SerialDataReceivedEventArgs e)
 {
     InputData = ComPort.ReadExisting();
     if (InputData != String.Empty)
     {
         // textbox1 = InputData; // Ko dùng đc như thế này vì khác threads .
         SetText(InputData); // Chính vì vậy phải sử dụng ủy quyền tại đây. Gọi delegate đã khai báo trước đó.
     }
 }
Esempio n. 19
0
 private void port_DataReceived_1(object sender, SerialDataReceivedEventArgs e)
 {
     InputData = ComPort.ReadExisting();
     if (InputData != String.Empty)
     {
         SetTextCallback invoke = new SetTextCallback(SetText);
         this.BeginInvoke(invoke, new object[] { InputData });
     }
 }
 public TwoWaySerialDriver(ComPort ComPort) : base(ComPort)
 {
     if (!ComPort.Supports422)
     {
         throw new NotSupportedException(string.Format("{0} ComPort is not a Two Way Serial Driver", ComPort.DeviceName));
     }
     Start();
     LocalStart();
 }
Esempio n. 21
0
        public bool Init()
        {
            try
            {
                ComPort.Open();
            }
            catch (Exception ex) { CustomMessageBox.Show(Strings.ErrorConnecting + ex.Message, Strings.ERROR); return(false); }

            return(true);
        }
Esempio n. 22
0
 private static void ExpansionComportOnSerialDataReceived(ComPort receivingComPort_, ComPortSerialDataEventArgs args_)
 {
     switch (receivingComPort_.ID)
     {
     case 1:
         "Outgoing >>> EiscSerialData [{0}]: {1}".PrintLine(SerialJoins.ComPort7, args_.SerialData);
         ControlSystem.MasterProcessorLink.StringInput[SerialJoins.ComPort7].StringValue = args_.SerialData;
         break;
     }
 }
Esempio n. 23
0
 public void Disconnect()
 {
     mut.WaitOne();
     if (ser != null)
     {
         ser.Close();
         ser = null;
     }
     mut.ReleaseMutex();
 }
Esempio n. 24
0
 void com_SerialDataReceived(ComPort ReceivingComPort, ComPortSerialDataEventArgs args)
 {
     if (this.NetDataReceived != null)
     {
         this.NetDataReceived(this, new NetPortSerialDataEventArgs()
         {
             SerialData = args.SerialData, SerialEncoding = args.SerialEncoding
         });
     }
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            List <ComPort> ports = GetSerialPorts();
            //if we want to find one device
            ComPort com = ports.FindLast(c => c.vid.Equals("0483") && c.pid.Equals("5740"));
            //or if we want to extract all devices with specified values:
            List <ComPort> coms = ports.FindAll(c => c.vid.Equals("0483") && c.pid.Equals("5740"));

            Console.ReadLine();
        }
Esempio n. 26
0
        public static void Send(this ComPort port, byte[] bytes, int count)
        {
            string str = string.Empty;

            for (int i = 0; i < count; i++)
            {
                str = str + (char)bytes[i];
            }
            port.Send(str);
        }
Esempio n. 27
0
        private void ReadData(ComPort port)
        {
            int count = port.BytesToRead;

            byte[] buf = new byte[count];
            port.Read(buf, 0, count);
            var msg = (port.PortName + ":" + Encoding.UTF8.GetString(buf) + "\r\n");

            GetMsg(msg);
        }
Esempio n. 28
0
    void AddPort(string portName)
    {
        ComPort comPort = comPorts.GetPort(portName);

        if (comPort != null && !m_scope.ContainsVariable(portName))
        {
            Debug.Log(portName + " added to scope");
            m_scope.SetVariable(portName, comPort);
        }
    }
 public void ComPortTest_002()
 {
     this.ComPortTest = new ComPort("Name", "Device");
     Assert.AreEqual(this.ComPortTest.Name, "Name");
     Assert.AreEqual(this.ComPortTest.Device, "Device");
     Assert.AreEqual(this.ComPortTest.Baudrate, Baudrate.Baudrate9600);
     Assert.AreEqual(this.ComPortTest.Parity, Parity.None);
     Assert.AreEqual(this.ComPortTest.StopBits, StopBits.One);
     Assert.AreEqual(this.ComPortTest.DataBit, 8);
 }
Esempio n. 30
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (ComPort != null)
     {
         //readingThread.Abort();
         //readingThread.Join();
         ComPort.Close();
         ComPort.Dispose();
     }
 }
Esempio n. 31
0
 private void Clink(object sender, MouseButtonEventArgs e)
 {
     string[] ArryPort = ComPort.GetALLCOM();
     comboBox.Items.Clear();
     for (int i = 0; i < ArryPort.Length; i++)
     {
         comboBox.Items.Add(ArryPort[i]);
     }
     comboBox.SelectedIndex = 1;
 }
		/// <summary>
		/// Constructor of the Control System Class. Make sure the constructor always exists.
		/// If it doesn't exit, the code will not run on your 3-Series processor.
		/// </summary>
		public ControlSystem() : base()
		{
			// subscribe to control system events
			CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler);
			CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
			CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
			
			// Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should
			// define the max number of threads which we will use in the system.
			// the right number depends on your project; do not make this number unnecessarily large
			Thread.MaxNumberOfUserThreads = 20;


            if (this.SupportsComPort)
            {
                MyCOMPort = this.ComPorts[1];
                MyCOMPort.SerialDataReceived += new ComPortDataReceivedEvent(myComPort_SerialDataReceived);

                if (MyCOMPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("COM Port couldn't be registered. Cause: {0}", MyCOMPort.DeviceRegistrationFailureReason);

                if (MyCOMPort.Registered)
                    MyCOMPort.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate9600,
                                             ComPort.eComDataBits.ComspecDataBits8,
                                             ComPort.eComParityType.ComspecParityNone,
                                             ComPort.eComStopBits.ComspecStopBits1,
                                             ComPort.eComProtocolType.ComspecProtocolRS232,
                                             ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                             ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                         false);
            }

			// ensure this processor has ethernet then setup the EISC
			if (this.SupportsEthernet)
			{
				myEISC = new EthernetIntersystemCommunications(eISCIPID, eISCIP, this);
				if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
				{
					ErrorLog.Error(">>> The EISC was not registered: {0}", myEISC.RegistrationFailureReason);
				}
				else
				{
					// Device has been registered. Now register for the event handlers
					myEISC.OnlineStatusChange += new OnlineStatusChangeEventHandler(myEISC_OnlineStatusChange);
					myEISC.SigChange += new SigEventHandler(myEISC_SigChange);
					ErrorLog.Notice(">>> The EISC has been registered successfully");
				}
			}
			else
			{
				ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run");
			}


		}
Esempio n. 33
0
        private void SetUserPass(ComPort port, string opwd, string npwd, byte uid)
        {
            lastFuncName = "SetUserPwd";
            CMD = 101;

            //Creating data
            DataForSend = Encoding.GetEncoding(1251).GetBytes(uid + "," + opwd + "," + npwd);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 34
0
        private char SetTaxNum(ComPort port, string tnum, char ttype)
        {
            lastFuncName = "SetTaxNum";
            CMD = 98;

            //Creating data
            DataForSend = Encoding.GetEncoding(1251).GetBytes(tnum + ',' + ttype);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();

            char _fok = '\0';
            string _fdata = Encoding.GetEncoding(1251).GetString(OutputData);
            if (_fdata.Length != 0)
                _fok = _fdata[0];

            return _fok;
        }
Esempio n. 35
0
        private object[] SetTaxRate(ComPort port, string pwd, byte dpoint, bool[] userates, double[] rates)
        {
            lastFuncName = "SetTaxRate";
            CMD = 83;

            //Creating data
            string _data = pwd + ',' + dpoint.ToString() + ',';
            foreach (bool a in userates)
                _data += a ? '1' : '0';
            foreach (double r in rates)
                _data += ',' + r.ToString(NumberFormat);

            DataForSend = Encoding.GetEncoding(1251).GetBytes(_data);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();

            // Perform processing recived data
            string _taxdata = Encoding.GetEncoding(1251).GetString(OutputData);
            object[] _taxInfo = new object[9];
            if (_taxdata.Length != 0)
            {
                string[] _trItems = _taxdata.Split(new char[] { ',' });
                _taxInfo[0] = byte.Parse(_trItems[0]);
                _taxInfo[1] = _trItems[1][0] == '1' ? true : false;
                _taxInfo[2] = _trItems[1][1] == '1' ? true : false; ;
                _taxInfo[3] = _trItems[1][2] == '1' ? true : false; ;
                _taxInfo[4] = _trItems[1][3] == '1' ? true : false; ;

                _taxInfo[5] = double.Parse(_trItems[2], NumberFormat);
                _taxInfo[6] = double.Parse(_trItems[3], NumberFormat);
                _taxInfo[7] = double.Parse(_trItems[4], NumberFormat);
                _taxInfo[8] = double.Parse(_trItems[5], NumberFormat);
            }

            return _taxInfo;
        }
Esempio n. 36
0
        private double[] SetGetMoney(ComPort port, double amount)
        {
            lastFuncName = "SetGetMoney";
            CMD = 70;

            string _amount = amount.ToString(NumberFormat);
            if (amount > 0)
                _amount = "+" + _amount;
            DataForSend = Encoding.GetEncoding(1251).GetBytes(_amount);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();

            //
            string _rdata = Encoding.GetEncoding(1251).GetString(OutputData);
            double[] cashInfo = new double[3];
            if (_rdata.Length != 0)
            {
                string[] _explStr = _rdata.Split(new char[] { ',' });
                if (_explStr[0] != "F")
                {
                    cashInfo[0] = double.Parse(_explStr[0]) / 100;
                    cashInfo[1] = double.Parse(_explStr[1]) / 100;
                    cashInfo[2] = double.Parse(_explStr[2]) / 100;
                }
            }

            return cashInfo;
        }
Esempio n. 37
0
        private void SetSaleMode(ComPort port, byte mode)
        {
            lastFuncName = "SetSaleMode";
            CMD = 84;

            //Creating data
            DataForSend = Encoding.GetEncoding(1251).GetBytes(mode.ToString());

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 38
0
        // Main Access Point
        internal override object CallFunction(string name, string description, ComPort port, object[] param)
        {
            object value = new object();
            OutputData = new byte[0];
            ReadedBytes = 0;

            if (description == string.Empty)
                description = ((Tree)FP_Panel).GetDescription(name);

            switch (name)
            {
                #region Initialization
                case "SetPrintParams":
                    {
                        break;
                    }
                case "SetDateTime":
                    {
                        SetDateTime sdt = new SetDateTime(Protocol_Name, description);
                        if (sdt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetDateTime(port, sdt.NewDateTime);
                        sdt.Dispose();
                        break;
                    }
                case "Fiscalize":
                    {
                        string[] _errMsgs = new string[9] {
                                "������� ���������� ������ ���������",
                                "�� �������� ��������� �����",
                                "������������ ���������� ����� ��� ���� ���������",
                                "³������� ���",
                                "�� ������� ���� �� ���� (������ Z-���)",
                                "�� ����� �������� ������",
                                "���������� ����� ���������� � ����",
                                "���� ������ (����������) ������",
                                "������� �� ������������"};
                        break;
                    }
                case "SetTaxRate":
                    {
                        SetTaxRate str = new SetTaxRate(Protocol_Name, description);
                        if (str.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] taxData = SetTaxRate(port, str.Password, str.DecimalPoint, str.UseRates, str.Rates);
                            string _infotext = string.Empty;

                            if (Methods.IsEmpty(taxData))
                            {
                                _infotext = string.Format("{0}\r\n\r\n{1} - {2}\r\n{3}: {4:0.00} [{5}]\r\n{6}: {7:0.00} [{8}]\r\n{9}: {10:0.00} [{11}]\r\n{12}: {13:0.00} [{14}]",
                                    "�������� ������",
                                    "ʳ������ ����� ���� ����", (byte)taxData[0],
                                    "����� �", (double)taxData[5], (bool)taxData[1] ? "���������" : "�� ���������",
                                    "����� �", (double)taxData[6], (bool)taxData[2] ? "���������" : "�� ���������",
                                    "����� �", (double)taxData[7], (bool)taxData[3] ? "���������" : "�� ���������",
                                    "����� �", (double)taxData[8], (bool)taxData[4] ? "���������" : "�� ���������");

                                value = taxData;
                            }
                            else
                                _infotext = "���� �����";

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        str.Dispose();
                        break;
                    }
                case "SetSaleMode":
                    {
                        SetSaleMode ssm = new SetSaleMode(Protocol_Name, description);
                        if (ssm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetSaleMode(port, ssm.SaleMode);
                        ssm.Dispose();
                        break;
                    }
                case "SetSerialNum":
                    {
                        SetSerialNum ssm = new SetSerialNum(Protocol_Name, description);
                        if (ssm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            char r = SetSerialNum(port, ssm.CountryCode, ssm.SerialNumber);
                            string _infotext = string.Empty;

                            if (r == 'P')
                                _infotext = "������� �������� ������";
                            if (r == 'F')
                                _infotext = "��������������� �������� ������\r\n���������� ����� ��� �����������\r\n�� ����������� ����";
                            if (r == '\0')
                                _infotext = "���� ������ �� ��������";

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        ssm.Dispose();
                        break;
                    }
                case "SetFixNum":
                    {
                        SetFixNum sfn = new SetFixNum(Protocol_Name, description);
                        if (sfn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            char r = SetFixNum(port, sfn.FiscalNumber);
                            string _infotext = string.Empty;

                            if (r == 'P')
                                _infotext = "������� �������� ������";
                            if (r == 'F')
                                _infotext = "���������� ����� �� �����������\r\n�� ����������� ����\r\n³������� ��� ��� ��������� �������� Z-���";
                            if (r == '\0')
                                _infotext = "���� ������ �� ��������";

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        sfn.Dispose();
                        break;
                    }
                case "SetTaxNum":
                    {
                        SetTaxNum stn = new SetTaxNum(Protocol_Name, description);
                        if (stn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            char r = SetTaxNum(port, stn.TaxNumber, stn.TaxType);
                            string _infotext = string.Empty;

                            if (r == 'P')
                                _infotext = "������� �������� ������";
                            if (r == 'F')
                                _infotext = "������� ��������� �������";
                            if (r == '\0')
                                _infotext = "���� ������ �� ��������";

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        stn.Dispose();
                        break;
                    }
                case "SetUserPass":
                    {
                        SetUserPass sup = new SetUserPass(Protocol_Name, description);
                        if (sup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetUserPass(port, sup.OldPassword, sup.NewPassword, sup.UserNo);
                        sup.Dispose();
                        break;
                    }
                case "SetUserName":
                    {
                        SetUserName sun = new SetUserName(Protocol_Name, description);
                        if (sun.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetUserName(port, sun.Password, sun.UserNo, sun.UserName);
                        sun.Dispose();
                        break;
                    }
                case "ResetUserData":
                    {
                        ResetUserData sun = new ResetUserData(Protocol_Name, description);
                        if (sun.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ResetUserData(port, sun.Password, sun.UserNo);
                        sun.Dispose();
                        break;
                    }
                case "SetGetArticle":
                    {
                        SetGetArticle sga = new SetGetArticle(Protocol_Name, description);
                        if (sga.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] artInfo = SetGetArticle(port, sga.Option, sga.Param);

                            string[] _errorMsgs = new string[2]{
                                "������� �������� ������",
                                "������� ��������� �������"};
                            string _infotext = string.Empty;
                            string _infoFormat = string.Empty;
                            if (!Methods.IsEmpty(artInfo) && artInfo[0].ToString() != "F")
                                switch (sga.Option)
                                {
                                    case 'I':
                                        {
                                            _infotext = string.Format("{0}\r\n\r\n{1}: {2:0.00}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}",
                                                "�������� ����������",
                                                "������������ ����� ����� ������", artInfo[0],
                                                "������ ������", artInfo[1],
                                                "���������������", artInfo[2]);
                                            break;
                                        }
                                    case 'D':
                                    case 'C':
                                    case 'P':
                                        {
                                            _infotext = _errorMsgs[0];
                                            break;
                                        }
                                    case 'F':
                                    case 'N':
                                    case 'R':
                                        {
                                            _infoFormat = "{0}\r\n\r\n{1}: {2}\r\n{3} - {4}\r\n{5}: {6}\r\n{7}: {8:0.00}\r\n";
                                            _infoFormat += "{9}: {10}\r\n{11}: {12:0.00}\r\n{13}: {14}\r\n{15}: {16:0.00}\r\n{17}: {18}";
                                            _infotext = string.Format(_infoFormat,
                                                "���������� ��� �����",
                                                "����� ������", artInfo[1],
                                                "��������� �����", artInfo[2],
                                                "�����", artInfo[3],
                                                "ֳ��", double.Parse(artInfo[4].ToString(), NumberFormat),
                                                "ʳ������ �������", double.Parse(artInfo[5].ToString(), NumberFormat),
                                                "���� �������", double.Parse(artInfo[6].ToString(), NumberFormat),
                                                "ʳ������ � ����� ����", double.Parse(artInfo[7].ToString(), NumberFormat),
                                                "���� � ����� ����", double.Parse(artInfo[8].ToString(), NumberFormat),
                                                "�����", artInfo[9]);
                                            break;
                                        }
                                }
                            else
                                _infotext = _errorMsgs[1];

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        sga.Dispose();
                        break;
                    }
                case "LoadLogo":
                    {
                        LoadLogo ll = new LoadLogo(Protocol_Name, description);
                        if (ll.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            LoadLogo(port, ll.Password, ll.Logo);
                        ll.Dispose();
                        break;
                    }
                case "SetAdminPass":
                    {
                        SetAdminPass sap = new SetAdminPass(Protocol_Name, description);
                        if (sap.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetAdminPass(port, sap.OldPassword, sap.NewPassword);
                        sap.Dispose();
                        break;
                    }
                case "ResetUserPass":
                    {
                        ResetUserPass sup = new ResetUserPass(Protocol_Name, description);
                        if (sup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ResetUserPass(port, sup.Password, sup.UserNo);
                        sup.Dispose();
                        break;
                    }
                #endregion
                #region Other
                case "SetGetMoney":
                    {
                        SetGetMoney sgm = new SetGetMoney(Protocol_Name, description);
                        if (sgm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            double[] money = SetGetMoney(port, sgm.Money);
                            string _infotext = string.Format("{0}\r\n\r\n{1}: {2:0.00}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}",
                                "Գ������� �������",
                                "�������� ���� ������ �� ����", money[0],
                                "�������� ���� ��������� �� ����", money[1],
                                "���� � ���", money[2]);
                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = money.Clone();
                        }
                        sgm.Dispose();
                        break;
                    }
                case "PrintDiagInfo":
                    {
                        PrintDiagInfo(port);
                        break;
                    }
                case "Beep":
                    {
                        Beep(port);
                        break;
                    }
                case "OpenBox":
                    {
                        OpenBox ob = new OpenBox(Protocol_Name, description);
                        if (ob.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            OpenBox(port, ob.Impulse);

                        value = new object[1] { ob.Impulse };
                        break;
                    }
                #endregion
                #region Display
                case "DisplText":
                    {
                        DisplText dt = new DisplText(Protocol_Name, description);
                        if (dt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            DisplText(port, dt.TextLine);
                        dt.Dispose();
                        break;
                    }
                case "DisplBotLine":
                    {
                        DisplBotLine dbl = new DisplBotLine(Protocol_Name, description);
                        if (dbl.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            DisplBotLine(port, dbl.BottomLine);
                        dbl.Dispose();
                        break;
                    }
                case "DisplTopLine":
                    {
                        DisplTopLine dtl = new DisplTopLine(Protocol_Name, description);
                        if (dtl.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            DisplTopLine(port, dtl.TopLine);
                        dtl.Dispose();
                        break;
                    }
                case "ClrDispl":
                    {
                        ClrDispl(port);
                        break;
                    }
                case "DisplayDateTime":
                    {
                        DisplayDateTime(port);
                        break;
                    }
                #endregion
                #region DayReport
                case "ReportXZ":
                    {
                        ReportXZ rxz = new ReportXZ(Protocol_Name, description);
                        if (rxz.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] xzInfo = ReportXZ(port, rxz.Password, rxz.ReportType, new bool[] { rxz.ClearUserSumm, rxz.ClearArtsSumm });
                            string _infotext = string.Empty;
                            if (!Methods.IsEmpty(xzInfo))
                            {
                                string _infoFormat = "{0}\r\n\r\n{1} - {2}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}\r\n";
                                _infoFormat += "{7}: {8}\r\n{9}: {10}\r\n{11}: {12}";
                                _infotext = string.Format(_infoFormat,
                                    "���������� ��������� " + (rxz.ReportType == 0 ? "Z" : "X") + "-����",
                                    "����� ����", (uint)xzInfo[0],
                                    "���� �� ���� �", (double)xzInfo[1],
                                    "���� �� ���� �", (double)xzInfo[2],
                                    "���� �� ���� �", (double)xzInfo[3],
                                    "���� �� ���� �", (double)xzInfo[4],
                                    "���� �� ���� �", (double)xzInfo[5]);
                            }

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = xzInfo.Clone();
                        }
                        rxz.Dispose();
                        break;
                    }
                #endregion
                #region Reports
                case "ReportByTax":
                    {
                        ReportByTax rbt = new ReportByTax(Protocol_Name, description);
                        if (rbt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByTax(port, rbt.Password, rbt.StartDate, rbt.EndDate);
                        rbt.Dispose();
                        break;
                    }
                case "ReportByNoFull":
                    {
                        ReportByNoFull rbnf = new ReportByNoFull(Protocol_Name, description);
                        if (rbnf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByNoFull(port, rbnf.Password, rbnf.StartNo, rbnf.EndNo);
                        rbnf.Dispose();
                        break;
                    }
                case "ReportByDateFull":
                    {
                        ReportByDateFull rbdf = new ReportByDateFull(Protocol_Name, description);
                        if (rbdf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByDateFull(port, rbdf.Password, rbdf.StartDate, rbdf.EndDate);
                        rbdf.Dispose();
                        break;
                    }
                case "ReportByDateShort":
                    {
                        ReportByDateShort rbds = new ReportByDateShort(Protocol_Name, description);
                        if (rbds.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByDateShort(port, rbds.Password, rbds.StartDate, rbds.EndDate);
                        rbds.Dispose();
                        break;
                    }
                case "ReportByNoShort":
                    {
                        ReportByNoShort rbns = new ReportByNoShort(Protocol_Name, description);
                        if (rbns.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByNoShort(port, rbns.Password, rbns.StartNo, rbns.EndNo);
                        rbns.Dispose();
                        break;
                    }
                case "ReportByUsers":
                    {
                        ReportByUsers rbu = new ReportByUsers(Protocol_Name, description);
                        if (rbu.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByUsers(port, rbu.Password);
                        rbu.Dispose();
                        break;
                    }
                case "ReportByArts":
                    {
                        ReportByArts rba = new ReportByArts(Protocol_Name, description);
                        if (rba.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            ReportByArts(port, rba.Password, rba.ReportMode);
                        rba.Dispose();
                        break;
                    }
                #endregion
                #region Selling
                case "PrintCopy":
                    {
                        PrintCopy pc = new PrintCopy(Protocol_Name, description);
                        if (pc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            PrintCopy(port, pc.Copies);
                        pc.Dispose();
                        break;
                    }
                case "ResetOrder":
                    {
                        string _infotext = string.Format("{0}", "��������� ������� ����������");
                        System.Windows.Forms.DialogResult _res = System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
                        if (_res == System.Windows.Forms.DialogResult.Yes)
                            ResetOrder(port);
                        break;
                    }
                case "PrintFText":
                    {
                        PrintFText pft = new PrintFText(Protocol_Name, description);
                        if (pft.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            PrintFText(port, pft.FixText);
                        pft.Dispose();
                        break;
                    }
                case "PrintNText":
                    {
                        PrintNText pnt = new PrintNText(Protocol_Name, description);
                        if (pnt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            PrintNText(port, pnt.NonFixText);
                        pnt.Dispose();
                        break;
                    }
                case "OpenNOrder":
                    {
                        ushort[] oinfo = OpenNOrder(port);
                        if (oinfo[3] != 0)
                        {
                            string[] _errMsgs = new string[4]{
                                "�� ������������� �������� ���'���",
                                "³������� ��������� ���",
                                "��� �������� ����������� ���",
                                "�� ����������� ���� � ���"};
                            System.Windows.Forms.DialogResult _res = System.Windows.Forms.MessageBox.Show(_errMsgs[oinfo[3] - 1], Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning);
                        }

                        value = oinfo.Clone();
                        break;
                    }
                case "CloseNOrder":
                    {
                        ushort[] oinfo = CloseNOrder(port);
                        value = oinfo.Clone();
                        break;
                    }
                case "CloseFOrder":
                    {
                        CloseFOrder(port);
                        break;
                    }
                case "OpenFOrder":
                    {
                        //OpenFOrder(port);
                        break;
                    }
                #endregion
                #region Printer commands
                case "CutChq":
                    {
                        CutChq(port);
                        break;
                    }
                case "LineFeed":
                    {
                        LineFeed lf = new LineFeed(Protocol_Name, description);
                        if (lf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            LineFeed(port, lf.Lines);
                        lf.Dispose();
                        break;
                    }
                #endregion
                #region Get Info
                case "GetDateTime":
                    {
                        DateTime dtime = GetDateTime(port);
                        string _infotext = string.Format("{0}: {1}", "������� ���� ��������", dtime.ToString("dd-MM-yyyy HH:mm:ss"));
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = dtime;
                        break;
                    }
                case "GetLastZReport":
                    {
                        GetLastZReport glzr = new GetLastZReport(Protocol_Name, description);
                        if (glzr.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] zrep = GetLastZReport(port, glzr.ReportMode);
                            string _infotext = string.Empty;
                            if (!Methods.IsEmpty(zrep))
                            {
                                string _infoFormat = "{0}\r\n\r\n{1} - {2}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}\r\n";
                                _infoFormat += "{7}: {8}\r\n{9}: {10}\r\n{11}: {12}";
                                _infotext = string.Format(_infoFormat,
                                    "���������� ���������� Z-����",
                                    "����� ����", (uint)zrep[0],
                                    "���� �� ���� �", (double)zrep[1],
                                    "���� �� ���� �", (double)zrep[2],
                                    "���� �� ���� �", (double)zrep[3],
                                    "���� �� ���� �", (double)zrep[4],
                                    "���� �� ���� �", (double)zrep[5]);
                            }
                            else
                                _infotext = "���� �����";

                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = zrep.Clone();
                        }
                        glzr.Dispose();
                        break;
                    }
                case "GetSummsByDay":
                    {
                        GetSummsByDay gsbd = new GetSummsByDay(Protocol_Name, description);
                        if (gsbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            double[] summ = GetSummsByDay(port, gsbd.ReportMode);
                            string _infoFormat = "{0}\r\n\r\n{1}: {2:0.00}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}\r\n";
                            _infoFormat += "{7}: {8:0.00}\r\n{9}: {10:0.00}";
                            string _infotext = string.Format(_infoFormat,
                                "���������� ��� �� ����",
                                "���� �� ���� �", (double)summ[0],
                                "���� �� ���� �", (double)summ[1],
                                "���� �� ���� �", (double)summ[2],
                                "���� �� ���� �", (double)summ[3],
                                "���� �� ���� �", (double)summ[4]);
                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = summ.Clone();
                        }
                        gsbd.Dispose();
                        break;
                    }
                case "GetSumCorByDay":
                    {
                        object[] scorr = GetSumCorByDay(port);
                        string _infoFormat = "{0}\r\n\r\n{1}: {2:0.00}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}\r\n";
                        _infoFormat += "{7}: {8}\r\n{9}: {10}\r\n{11}: {12}";
                        string _infotext = string.Format(_infoFormat,
                            "���� �������� �� ����",
                            "���� ��� �������", (double)scorr[0],
                            "���� �� ������� ���������", (double)scorr[1],
                            "���� ������ �� �������", (double)scorr[2],
                            "��������� ����", (ushort)scorr[3],
                            "Գ������ ����", (ushort)scorr[4],
                            "���� ����������", (ushort)scorr[5]);
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = scorr.Clone();
                        break;
                    }
                case "GetFreeMem":
                    {
                        uint fmem = GetFreeMem(port);
                        string _infotext = string.Format("{0} {1} {2}", "����� ����� ���'��:", fmem, "������");
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = fmem;
                        break;
                    }
                case "GetState":
                    {
                        byte[] _state = GetState(port);
                        string _infotext = string.Empty;
                        for (int i = 0; i < _state.Length; i++)
                        {
                            if (((string[])CustomData["Status"])[_state[i]].Length == 0)
                                continue;
                            _infotext += ((string[])CustomData["Status"])[_state[i]] + "\r\n";
                            if (i != 0 && _state[i] == 0)
                                break;
                        }
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = _infotext.Split(new string[1] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Clone();
                        break;
                    }
                case "GetFixTransState":
                    {
                        GetFixTransState gfts = new GetFixTransState(Protocol_Name, description);
                        if (gfts.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] transinfo = GetFixTransState(port, gfts.TransParam);
                            string _infoFormat = "{0}\r\n\r\n{1} {2}\r\n{3}: {4}\r\n{5}: {6:0.00}{7}{8}";
                            string _infotext = string.Format(_infoFormat,
                                "���� �������� ����������",
                                "���", ((byte)transinfo[0] == 1) ? "��������" : "�� ��������",
                                "˳������� ��������� ����", transinfo[1],
                                "���� �� ����", (double)transinfo[2],
                                (transinfo[3] == null) ? "" : ("\r\n������ �� ����: " + string.Format("{0:0.00}", (double)transinfo[3])),
                                (transinfo[4] == null) ? "" : ("\r\n������� ������ �������� " + ((byte)transinfo[4] == 1 ? "������" : "�� ������")));
                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = transinfo.Clone();
                        }

                        break;
                    }
                case "GetDiagInfo":
                    {
                        string[] dinfo = GetDiagInfo(port);
                        string _infoFormat = "{0}\r\n\r\n{1} - {2}\r\n{3}: {4}\r\n{5}: {6}\r\n{7}: {8}";
                        _infoFormat += "\r\n{9} - {10}\r\n{11}: {12}\r\n{13}: {14}";
                        string _infotext = string.Format(_infoFormat,
                            "ij���������� ����������",
                            "����� ��", dinfo[0],
                            "���� ���", DateTime.Parse(dinfo[1] + " " + dinfo[2].Insert(2, ":")).ToString("dd/MM/yyyy HH:mm"),
                            "���������� ����", dinfo[3],
                            "���������� Sw", dinfo[4],
                            "��� �����", dinfo[5],
                            "������� �����", dinfo[6],
                            "Գ�������� �����", dinfo[7]);
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = dinfo.Clone();
                        break;
                    }
                case "GetTaxRates":
                    {
                        double[] taxs = GetTaxRates(port);
                        string _infotext = string.Format("{0}\r\n\r\n{1}: {2:0.00}%\r\n{3}: {4:0.00}%\r\n{5}: {6:0.00}%\r\n{7}: {8:0.00}%",
                            "�������� ������",
                            "�", taxs[0], "�", taxs[1], "�", taxs[2], "�", taxs[3]);
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = taxs.Clone();
                        break;
                    }
                case "GetTaxID":
                    {
                        string[] taxid = GetTaxID(port);
                        string _infotext = string.Format("{0}\r\n\r\n{1} {2}",
                            "���������� ��������������� �����", taxid[0], (taxid[1] == "0") ? "��" : "��");
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = taxid.Clone();
                        break;
                    }
                case "GetChqInfo":
                    {
                        object[] cinfo = GetChqInfo(port);
                        string _infoFormat = "{0}\r\n\r\n{1} - {2}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}\r\n";
                        _infoFormat += "{7}: {8:0.00}\r\n{9}: {10:0.00}\r\n{11}: {12:0.00}\r\n{13} - {14}";
                        string _infotext = string.Format(_infoFormat,
                            "���������� ��������� ���������� ����",
                            "�������� ����������", ((byte)cinfo[0] == 1) ? "ͳ" : "���",
                            "���� �� ���� �", (double)cinfo[1],
                            "���� �� ���� �", (double)cinfo[2],
                            "���� �� ���� �", (double)cinfo[3],
                            "���� �� ���� �", (double)cinfo[4],
                            "���� �� ���� *", (double)cinfo[5],
                            "���������� ���", ((byte)cinfo[6] == 1) ? "���" : "ͳ");
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = cinfo.Clone();
                        break;
                    }
                case "GetPaymentInfo":
                    {
                        object[] pinfo = GetPaymentInfo(port);
                        string _infoFormat = "{0}\r\n\r\n{1}: {2:0.00}\r\n{3}: {4:0.00}\r\n{5}: {6:0.00}\r\n";
                        _infoFormat += "{7}: {8:0.00}\r\n{9} - {10}\r\n{11} - {12}\r\n{13} - {14}";
                        string _infotext = string.Format(_infoFormat,
                            "���������� �� ����� ����������",
                            "������", (double)pinfo[0],
                            "������", (double)pinfo[1],
                            "������� ������", (double)pinfo[2],
                            "���", (double)pinfo[3],
                            "����� ��������� Z-����", (uint)pinfo[4],
                            "����� ���������� Z-����", (uint)pinfo[5],
                            "���������� �������� ����", (uint)pinfo[6]);
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = pinfo.Clone();
                        break;
                    }
                case "GetUserInfo":
                    {
                        GetUserInfo gui = new GetUserInfo(Protocol_Name, description);
                        if (gui.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] uinfo = GetUserInfo(port, gui.UserNo);
                            string _infoFormat = "{0}\r\n\r\n{1} - {2}\r\n{3}: [{4}]; {5:0.00}\r\n{6}: [{7}]; {8:0.00}\r\n";
                            _infoFormat += "{9}: [{10}]; {11:0.00}\r\n{12}: [{13}]; {14:0.00}\r\n{15}: [{16}]; {17:0.00}\r\n{18}: {19}";
                            string _infotext = string.Format(_infoFormat,
                                "���������� ��� ������",
                                "���������� ����", (uint)uinfo[0],
                                "ʳ������ � ���� �������", (uint)uinfo[1], (double)uinfo[2],
                                "ʳ������ � ���� ������", (uint)uinfo[3], (double)uinfo[4],
                                "ʳ������ � ���� ���������", (uint)uinfo[5], (double)uinfo[6],
                                "ʳ������ � ���� ���� ���������", (uint)uinfo[7], (double)uinfo[8],
                                "����", (uint)uinfo[9], (double)uinfo[10],
                                "������������", uinfo[11].ToString());
                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = uinfo.Clone();
                        }
                        gui.Dispose();

                        break;
                    }
                case "GetLastFChqNo":
                    {
                        uint cno = GetLastFChqNo(port);
                        string _infotext = string.Format("{0} {1}", "����� ���������� ���������� ����:", cno);
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = cno;
                        break;
                    }
                case "GetFixMem":
                    {
                        GetFixMem gfm = new GetFixMem(Protocol_Name, description);
                        if (gfm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            object[] fmem = GetFixMem(port, gfm.FixNo, gfm.ReturnType, gfm.SecondaryParam);
                            string _infoFormat = "{0}\r\n\r\n{1} {2}\r\n{3}: {4}\r\n{5}: {6}\r\n{7}: {8}\r\n{9} {10}";
                            string _infotext = string.Format(_infoFormat,
                                "���������� �������� ���'��",
                                "���", fmem[0],
                                "˳������� ��������� ����", fmem[1],
                                "���� �� ����", fmem[3],
                                "������ �� ����", fmem[4],
                                "������� ������ ��������", fmem[5]);
                            System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);

                            value = fmem.Clone();
                        }
                        break;
                    }
                case "GetRemTime":
                    {
                        object[] remtime = GetRemTime(port);
                        string _infotext = string.Format("{0}", "�������� ���� �� ���������� ����");
                        System.Windows.Forms.MessageBox.Show(_infotext, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        value = remtime.Clone();
                        break;
                    }
                #endregion

                #region Program access methods
                case "FP_SendCustomer":
                    {
                        FP_SendCustomer(port, param);
                        break;
                    }
                case "FP_SetCashier":
                    {
                        FP_SetCashier(port, param);
                        break;
                    }
                case "FP_LastZRepNo":
                    {
                        FP_LastZRepNo(port, param);
                        break;
                    }
                case "FP_LastChqNo":
                    {
                        value = FP_LastChqNo(port, param);
                        break;
                    }
                case "FP_OpenBox":
                    {
                        FP_OpenBox(port);
                        break;
                    }

                #endregion
                #region
                /*
                #region Functions of registration
                case "SendStatus":
                    {
                        object[] FPinfo = SendStatus(port);

                        if (FPinfo != null && FPinfo.Length != 0)
                        {
                            FP_Info fi = new FP_Info(FPinfo, Protocol_Name);
                            fi.ShowDialog();
                            fi.Dispose();
                        }

                        break;
                    }
                case "GetDate":
                    {
                        System.Windows.Forms.MessageBox.Show(GetDate(port).ToLongDateString(),Protocol_Name);
                        break;
                    }
                case "SetDate":
                    {
                        if (param == null || param.Length == 0)
                        {
                            SetDate sd = new SetDate(Protocol_Name, description);
                            if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                SetDate(port, sd.date);
                            sd.Dispose();
                        }
                        else
                            SetDate(port, (DateTime)param[0]);

                        break;
                    }
                case "GetTime":
                    {
                        System.Windows.Forms.MessageBox.Show(GetTime(port).ToLongTimeString(),
                            Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);
                        break;
                    }
                case "SetTime":
                    {
                        if (param == null || param.Length == 0)
                        {
                            SetTime st = new SetTime(Protocol_Name, description);
                            if (st.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                SetTime(port, st.time);
                            st.Dispose();
                        }
                        else
                            SetTime(port, (DateTime)param[0]);

                        break;
                    }
                case "SetCod":
                    {
                        if (param == null || param.Length == 0)
                        {
                            SetCod sc = new SetCod(Protocol_Name, description);
                            if (sc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                SetCod(port, sc.oldPass, sc.nom, sc.newPass);
                            sc.Dispose();
                        }
                        else
                            SetCod(port, (uint)param[0], (byte)param[1], (uint)param[2]);

                        break;
                    }
                case "SetCashier":
                    {
                        if (param == null || param.Length == 0)
                        {
                            SetCashier sc = new SetCashier(Protocol_Name, description);
                            if (sc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                SetCashier(port, sc.nom, sc.pass, sc.id);
                            sc.Dispose();
                        }
                        else
                            SetCashier(port, Convert.ToByte(param[0]), (uint)param[1], param[2].ToString());

                        break;
                    }
                case "PayMoney":
                    {
                        if (Errors[name])
                            ResetOrder(port);

                        uint articleNewID = LoadArtID(port);

                        if (articleNewID + 50 == uint.MaxValue)
                        {
                            System.Windows.Forms.MessageBox.Show("�������� ������� Z-��� ��� ���������� �������",
                                Protocol_Name, System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                            return null;
                        }

                        if (param == null || param.Length == 0)
                        {
                            PayMoney s = new PayMoney(Protocol_Name, description);
                            if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                object[] article = null;
                                for (byte i = 0; i < s.articles.Length; i++)
                                {
                                    article = (object[])s.articles[i];
                                    articleNewID++;
                                    PayMoney(port, (double)article[0], (byte)article[1], s.dontPrintOne,
                                        (double)article[2], article[3].ToString()[0],
                                        article[4].ToString(), articleNewID);
                                }
                            }
                            s.Dispose();
                        }
                        else
                        {
                            System.Data.DataTable dTable = (System.Data.DataTable)param[0];
                            object[] article = new object[5];
                            byte ppt = Convert.ToByte(param[1]);
                            bool useTotDisc = (bool)param[2];

                            for (int i = 0; i < dTable.Rows.Count; i++)
                            {
                                article[0] = Methods.GetDouble(dTable.Rows[i]["TOT"]);
                                article[1] = ppt;
                                article[2] = Methods.GetDouble(dTable.Rows[i]["PRICE"]);
                                article[3] = dTable.Rows[i]["VG"];
                                article[4] = dTable.Rows[i]["NAME"].ToString().Replace('�', 'i').Replace('�', 'I');
                                articleNewID++;
                                PayMoney(port, (double)article[0], (byte)article[1], true,
                                    (double)article[2], article[3].ToString()[0],
                                    article[4].ToString(), articleNewID);
                                if (!useTotDisc && (bool)dTable.Rows[i]["USEDDISC"] && (double)dTable.Rows[i]["DISC"] != 0)
                                    Discount(port, (byte)0, (double)dTable.Rows[i]["DISC"], ppt, "");
                            }
                        }
                        SaveArtID(articleNewID);
                        break;
                    }
                case "Comment":
                    {
                        if (param == null || param.Length == 0)
                        {
                            Comment cmm = new Comment(Protocol_Name, description);
                            if (cmm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                Comment(port, cmm.commentLine, cmm.retCheque);
                            cmm.Dispose();
                        }
                        else
                            Comment(port, param[0].ToString(), (bool)param[1]);

                        break;
                    }
                case "CplPrint":
                    {
                        CplPrint(port);
                        byte[] mem = GetMemory(port, "2A", 0, 1);
                        //BIT 6 - OnLine state
                        string _status = string.Format("{0} {1}", "���� � ������������ �����", (mem[0] & 0x08) != 0 ? "����������" : "�� ����������");
                        System.Windows.Forms.MessageBox.Show(_status, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);
                        break;
                    }
                case "LineFeed":
                    {
                        LineFeed(port);
                        break;
                    }
                case "ResetOrder":
                    {
                        ResetOrder(port);
                        break;
                    }
                case "Avans":
                    {
                        if (param == null || param.Length == 0)
                        {
                            Avans a = new Avans(Protocol_Name, description);
                            if (a.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                Avans(port, a.copecks);
                            a.Dispose();
                        }
                        else
                            Avans(port, Convert.ToUInt32(param[0]));

                        break;
                    }
                case "Sale":
                    {
                        if (Errors[name])
                            ResetOrder(port);

                        uint articleNewID = LoadArtID(port);

                        if (articleNewID + 50 == uint.MaxValue)
                        {
                            System.Windows.Forms.MessageBox.Show("�������� ������� Z-��� ��� ���������� �������",
                                Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Warning);
                            return null;
                        }

                        if (param == null || param.Length == 0)
                        {
                            Sale s = new Sale(Protocol_Name, description);
                            if (s.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                object[] article = null;
                                for (byte i = 0; i < s.articles.Length; i++)
                                {
                                    article = (object[])s.articles[i];
                                    articleNewID++;
                                    Sale(port, (double)article[0],
                                        (byte)article[1], s.dontPrintOne,
                                        (double)article[2], article[3].ToString()[0],
                                        article[4].ToString(), articleNewID, (byte)article[6]);
                                }
                            }
                            s.Dispose();
                        }
                        else
                        {
                            System.Data.DataTable dTable = (System.Data.DataTable)param[0];
                            object[] article = new object[5];
                            byte dose_ppt = Convert.ToByte(param[1]);
                            byte money_ppt = Convert.ToByte(param[3]);
                            bool useTotDisc = (bool)param[2];

                            System.IO.StreamWriter sWr = null;

                            for (int i = 0; i < dTable.Rows.Count; i++)
                            {
                                article[0] = Methods.GetDouble(dTable.Rows[i]["TOT"]);
                                article[2] = Methods.GetDouble(dTable.Rows[i]["PRICE"]);
                                article[3] = dTable.Rows[i]["VG"];
                                article[4] = dTable.Rows[i]["NAME"].ToString().Replace('�', 'i').Replace('�', 'I');
                                articleNewID++;

                                sWr = System.IO.File.AppendText("a.txt");
                                sWr.WriteLine(articleNewID);
                                sWr.Close();
                                sWr.Dispose();
                                Sale(port, (double)article[0], dose_ppt, false, (double)article[2],
                                    article[3].ToString()[0], article[4].ToString(), articleNewID, money_ppt);
                                if (!useTotDisc && (bool)dTable.Rows[i]["USEDDISC"] && (double)dTable.Rows[i]["DISC"] != 0)
                                    Discount(port, (byte)0, (double)dTable.Rows[i]["DISC"], money_ppt, "");
                            }
                            sWr = System.IO.File.AppendText("a.txt");
                            sWr.WriteLine("-----");
                            sWr.Close();
                            sWr.Dispose();
                        }

                        SaveArtID(articleNewID);
                        break;
                    }
                case "Payment":
                    {

                        if (param == null || param.Length == 0)
                        {
                            Payment p = new Payment(Protocol_Name, description);
                            if (p.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                object[] ans = Payment(port, (byte)p.payInfo[0], (bool)p.payInfo[1],
                                    (double)p.payInfo[2], (bool)p.payInfo[3], p.payInfo[4].ToString());
                                try
                                {
                                    string info = string.Empty;
                                    if (ans[0].ToString() == "1")
                                        info += "����� : ";
                                    else
                                        info += "������� : ";

                                    info += string.Format("{0:F2}", ans[1]);
                                    System.Windows.Forms.MessageBox.Show(info, Protocol_Name,
                                        System.Windows.Forms.MessageBoxButtons.OK,
                                        System.Windows.Forms.MessageBoxIcon.Information);
                                }
                                catch { }
                            }
                            p.Dispose();
                        }
                        else
                            Payment(port, (byte)param[0], (bool)param[1], (double)param[2],
                                (bool)param[3], param[4].ToString());

                        break;
                    }
                case "SetString":
                    {
                        if (param == null || param.Length == 0)
                        {
                            SetString ss = new SetString(Protocol_Name, description);
                            if (ss.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                SetString(port, ss.lines);
                            ss.Dispose();
                        }
                        else
                            SetString(port, (string[])param);

                        break;
                    }
                case "Give":
                    {
                        if (param == null || param.Length == 0)
                        {
                            Give g = new Give(Protocol_Name, description);
                            if (g.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                Give(port, g.copecks);
                            g.Dispose();
                        }
                        else
                            Give(port, (uint)param[0]);

                        break;
                    }
                case "SendCustomer":
                    {
                        if (param == null || param.Length == 0)
                        {
                            SendCustomer sc = new SendCustomer(Protocol_Name, description);
                            if (sc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                SendCustomer(port, sc.lines, sc.show);
                            sc.Dispose();
                        }
                        else
                            SendCustomer(port, (string[])param[0], (bool[])param[1]);

                        break;
                    }
                case "GetMemory":
                    {
                        if (param == null || param.Length == 0)
                        {
                            GetMemory gm = new GetMemory(Protocol_Name, description);
                            if (gm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                byte[] mem = GetMemory(port, gm.block, gm.page, gm.size);
                                string memInfoLine = "DEC :";
                                for (int i = 0; i < mem.Length; i++)
                                {
                                    if (i % 10 == 0)
                                        memInfoLine += "\r\n";
                                    memInfoLine += mem[i].ToString() + " ";
                                }
                                memInfoLine += "\r\n\r\nHEX :";
                                for (int i = 0; i < mem.Length; i++)
                                {
                                    if (i % 10 == 0)
                                        memInfoLine += "\r\n";
                                    memInfoLine += String.Format("{0:X2}", mem[i]) + " ";
                                }
                                System.Windows.Forms.MessageBox.Show(memInfoLine, Protocol_Name,
                                    System.Windows.Forms.MessageBoxButtons.OK,
                                    System.Windows.Forms.MessageBoxIcon.Information);
                            }
                            gm.Dispose();
                        }
                        else
                        {
                            byte[] mem = GetMemory(port, param[0].ToString(), Convert.ToByte(param[1]), Convert.ToByte(param[2]));
                            value = new object[1];
                            value[0] = Methods.GetNumberFromBCD(mem);
                        }

                        break;
                    }
                case "OpenBox":
                    {
                        OpenBox(port);
                        break;
                    }
                case "PrintCopy":
                    {
                        PrintCopy(port);
                        break;
                    }
                case "PrintVer":
                    {
                        PrintVer(port);
                        break;
                    }
                case "GetBox":
                    {
                        uint copecks = GetBox(port);
                        string _status = string.Format("� ���� : {0}", (double)(copecks / 100) + (double)(copecks % 100) / 100);
                        System.Windows.Forms.MessageBox.Show(_status, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);
                        break;
                    }
                case "Discount":
                    {
                        if (param == null || param.Length == 0)
                        {
                            Discount d = new Discount(Protocol_Name, description);
                            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                Discount(port, (byte)d.discInfo[0], (double)d.discInfo[1], Convert.ToByte(d.discInfo[2]), d.discInfo[3].ToString());
                            d.Dispose();
                        }
                        else
                            Discount(port, (byte)param[0], (double)param[1], Convert.ToByte(param[2]), param[3].ToString());

                        break;
                    }
                case "CplOnline":
                    {
                        CplOnline(port);
                        byte[] mem = GetMemory(port, "2A", 0, 1);
                        //BIT 6 - OnLine state
                        string _status = string.Format("{0} {1}", "����� OnLine", (mem[0] & 0x40) != 0 ? "��������" : "��������");
                        System.Windows.Forms.MessageBox.Show(_status, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);
                        break;
                    }
                case "CplInd":
                    {
                        CplInd(port);
                        byte[] mem = GetMemory(port, "29", 0, 1);
                        //BIT 7 - Indicator state
                        string _status = string.Format("{0} {1}", "������ ���� �� ���������", (mem[0] & 0x80) != 0 ? "�� �������" : "�������");
                        System.Windows.Forms.MessageBox.Show(_status, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);
                        break;
                    }
                case "ChangeRate":
                    {
                        if (param == null || param.Length == 0)
                        {
                            ChangeRate cr = new ChangeRate(Protocol_Name, description);
                            if (cr.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                ChangeRate(port, cr.rate);
                            cr.Dispose();
                        }
                        else
                            ChangeRate(port, (byte)param[0]);

                        break;
                    }
                case "LineSP":
                    {
                        if (param == null || param.Length == 0)
                        {
                            LineSP lsp = new LineSP(Protocol_Name, description);
                            if (lsp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                LineSP(port, lsp.lsp);
                            lsp.Dispose();
                        }
                        else
                            LineSP(port, (byte)param[0]);

                        break;
                    }
                case "TransPrint":
                    {
                        if (param == null || param.Length == 0)
                        {
                            TransPrint tp = new TransPrint(Protocol_Name, description);
                            if (tp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                TransPrint(port, tp.text, tp.endPrint);
                            tp.Dispose();
                        }
                        else
                            TransPrint(port, param[0].ToString(), (bool)param[0]);

                        break;
                    }
                case "GetArticle":
                    {
                        object[] artInfo = new object[0];
                        string info = string.Empty;
                        if (param == null)
                        {
                            GetArticle ga = new GetArticle(Protocol_Name, description);
                            if (ga.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                artInfo = GetArticle(port, ga.articleID);
                            ga.Dispose();
                        }
                        else
                            artInfo = GetArticle(port, (uint)param[0]);

                        if (artInfo.Length != 0)
                        {
                            info += "����� ������" + " : ";
                            info += artInfo[0].ToString() + "\r\n";
                            info += "ʳ������" + " : ";
                            info += artInfo[1].ToString() + "\r\n";
                            info += "ֳ��" + " : ";
                            info += artInfo[2].ToString() + "\r\n";
                            info += "��������� �����" + " : ";
                            info += artInfo[3].ToString() + "\r\n";
                            info += "���� ����" + " : ";
                            info += artInfo[4].ToString() + "\r\n";
                            info += "\r\n\r\n";
                            info += "�������� ��������" + "\r\n";
                            info += "ʳ������" + " : ";
                            info += artInfo[5].ToString() + "\r\n";
                            info += "���� ����" + " : ";
                            info += artInfo[6].ToString() + "\r\n";
                        }
                        else
                            info = "���������� ��� �� ����� �������";

                        System.Windows.Forms.MessageBox.Show(info, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);

                        break;
                    }
                case "GetDayReport":
                    {
                        value = GetDayReport(port);
                        if (param == null && value != null && value.Length != 0)
                        {
                            string dayRepInfoLine = string.Empty;
                            int i = 0;
                            string[] payTypes = new string[] { "������", "������", "���", "������" };

                            double[] sales_group = (double[])((object[])value[1])[0];
                            double[] sales_forms = (double[])((object[])value[1])[1];

                            double[] pays_group = (double[])((object[])value[6])[0];
                            double[] pays_forms = (double[])((object[])value[6])[1];

                            dayRepInfoLine += "˳������� ���� ������ : " + value[0];
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "˳������� ������ �� ���������� ������ � ������ ������";
                            dayRepInfoLine += "\r\n";
                            for (i = 0; i < sales_group.Length; i++)
                                dayRepInfoLine += string.Format("{0} : {1:F2}\r\n", (char)(((int)'�') + i), sales_group[i]);
                            dayRepInfoLine += "--------------\r\n";
                            for (i = 0; i < sales_forms.Length; i++)
                                dayRepInfoLine += string.Format("{0} : {1:F2}\r\n", payTypes[i], sales_forms[i]);
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "����� ������� �� �������� : " + value[2];
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "����� ������ �� �������� : " + value[3];
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "����� ���� ���������� �������� : " + value[4];
                            dayRepInfoLine += "\r\n\r\n";
                            dayRepInfoLine += "˳������� ���� ������ : " + value[5];
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "˳������� ������ �� ���������� ������ � ������ ������";
                            dayRepInfoLine += "\r\n";
                            for (i = 0; i < pays_group.Length; i++)
                                dayRepInfoLine += string.Format("{0} : {1:F2}\r\n", (char)(((int)'�') + i), pays_group[i]);
                            dayRepInfoLine += "--------------\r\n";
                            for (i = 0; i < pays_forms.Length; i++)
                                dayRepInfoLine += string.Format("{0} : {1:F2}\r\n", payTypes[i], pays_forms[i]);
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "����� ������� �� �������� : " + value[7];
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "����� ������ �� �������� : " + value[8];
                            dayRepInfoLine += "\r\n";
                            dayRepInfoLine += "����� ���� �������� ������ : " + value[9];

                            System.Windows.Forms.MessageBox.Show(dayRepInfoLine, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        break;
                    }
                case "GetCheckSums":
                    {
                        value = GetCheckSums(port);
                        if (value != null && value.Length != 0)
                        {
                            string checkSumsInfoLine = string.Empty;
                            int i = 0;
                            checkSumsInfoLine += "˳������� ���� �� ���������� ������";
                            checkSumsInfoLine += "\r\n";
                            double[] tax = (double[])value[0];
                            for (i = 0; i < tax.Length; i++)
                                checkSumsInfoLine += string.Format("{0} : {1:F2}\r\n", (char)(((int)'�') + i), tax[i]);
                            checkSumsInfoLine += "\r\n";
                            double[] sum = (double[])value[1];
                            checkSumsInfoLine += "˳������� ��� ����� �� ������ �����";
                            checkSumsInfoLine += "\r\n";
                            string[] payTypes = new string[] { "������", "������", "���", "������" };
                            for (i = 0; i < sum.Length; i++)
                                checkSumsInfoLine += string.Format("{0} : {1:F2}\r\n", payTypes[i], sum[i]);

                            System.Windows.Forms.MessageBox.Show(checkSumsInfoLine, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        break;
                    }
                case "GetTaxRates":
                    {
                        object[] taxData = GetTaxRates(port);
                        if (taxData != null && taxData.Length != 0)
                        {
                            string taxInfoLine = string.Empty;
                            taxInfoLine += "�-��� ���������� ������ : " + taxData[0];
                            taxInfoLine += "\r\n";
                            taxInfoLine += "���� ������������ : " + ((DateTime)taxData[1]).ToLongDateString();
                            taxInfoLine += "\r\n\r\n";
                            taxInfoLine += "������ ���";
                            taxInfoLine += "\r\n";
                            double[] tax = (double[])taxData[2];
                            for (int i = 0; i < tax.Length; i++)
                                taxInfoLine += string.Format("{0} : {1:F2}%\r\n", (char)(((int)'�') + i), tax[i]);
                            taxInfoLine += "\r\n";
                            taxInfoLine += "�-��� ���������� ������� �������� ��� : " + taxData[3];
                            taxInfoLine += "\r\n";
                            taxInfoLine += "��� ��� : " + ((taxData[4].ToString() == "0") ? "��������" : "�������");
                            if ((bool)taxData[5])
                            {
                                taxInfoLine += "\r\n\r\n";
                                taxInfoLine += "������ �����";
                                taxInfoLine += "\r\n";
                                tax = (double[])taxData[6];
                                for (int i = 0; i < tax.Length; i++)
                                    taxInfoLine += string.Format("{0} : {1:F2}%\r\n", (char)(((int)'�') + i), tax[i]);
                            }
                            System.Windows.Forms.MessageBox.Show(taxInfoLine, Protocol_Name,
                                System.Windows.Forms.MessageBoxButtons.OK,
                                System.Windows.Forms.MessageBoxIcon.Information);
                        }
                        break;
                    }
                case "CplCutter":
                    {
                        CplCutter(port);
                        byte[] mem = GetMemory(port, "301A", 16, 1);
                        //BIT 3 - Cutter state
                        string _status = string.Format("{0} {1}", "�������", (mem[0] & 0x08) == 0 ? "��������" : "�� ��������");
                        System.Windows.Forms.MessageBox.Show(_status, Protocol_Name,
                            System.Windows.Forms.MessageBoxButtons.OK,
                            System.Windows.Forms.MessageBoxIcon.Information);
                        break;
                    }
                #endregion
                #region Function of programming
                case "Fiscalization":
                    {
                        Fiscalazation f = new Fiscalazation(Protocol_Name, description);
                        if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            Fiscalization(port, f.pass, f.fn);
                        f.Dispose();

                        break;
                    }
                case "SetHeadLine":
                    {
                        SetHeadLine shl = new SetHeadLine(Protocol_Name, description);
                        if (shl.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetHeadLine(port, shl.pass, shl.line1, shl.line2, shl.line3, shl.line4);
                        shl.Dispose();

                        break;
                    }
                case "SetTaxRate":
                    {
                        SetTaxRate str = new SetTaxRate(Protocol_Name, description);
                        if (str.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            SetTaxRate(port, str.pass, str.taxCount, str.tax, str.status, str.taxGCount, str.gtax);
                        str.Dispose();

                        break;
                    }
                case "ProgArt":
                    {
                        if (param == null || param.Length == 0)
                        {
                            ProgArt pa = new ProgArt(Protocol_Name, description);
                            if (pa.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            {
                                object[] article = null;
                                for (byte i = 0; i < pa.articles.Length; i++)
                                {
                                    article = (object[])pa.articles[i];

                                    ProgArt(port, pa.pass, (byte)article[0],
                                        (double)article[1], article[2].ToString()[0],
                                        article[3].ToString(), (uint)article[4]);
                                }
                            }
                            pa.Dispose();
                        }
                        else
                        {
                            System.Data.DataTable dTable = (System.Data.DataTable)param[0];
                            object[] article = new object[5];
                            byte ppt = Convert.ToByte(param[1]);
                            uint articleNewID = LoadArtID(port);

                            System.IO.StreamWriter sWr = null;

                            for (int i = 0; i < dTable.Rows.Count; i++)
                            {
                                article[0] = ppt;
                                article[1] = Methods.GetDouble(dTable.Rows[i]["PRICE"]);
                                article[2] = dTable.Rows[i]["VG"];
                                article[3] = dTable.Rows[i]["NAME"].ToString().Replace('�', 'i').Replace('�', 'I');
                                articleNewID++;

                                ProgArt(port, (ushort)0, (byte)article[0], (double)article[1],
                                    article[3].ToString()[0], article[4].ToString(), articleNewID);
                            }
                        }

                        break;
                    }
                case "LoadBMP":
                    {
                        LoadBMP lbmp = new LoadBMP(Protocol_Name, description);
                        if (lbmp.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            LoadBMP(port, (ushort)lbmp.imageInfo[0], true, lbmp.imageInfo[1].ToString());
                        lbmp.Dispose();

                        break;
                    }
                #endregion
                #region Function of reports
                case "ArtReport":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        ArtReport(port, pass);
                        break;
                    }
                case "ArtXReport":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        ArtXReport(port, pass);
                        break;
                    }
                case "DayReport":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        DayReport(port, pass);
                        break;
                    }
                case "DayClrReport":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        DayClrReport(port, pass);

                        System.IO.StreamWriter sWr = System.IO.File.AppendText("a.txt");
                        sWr.WriteLine("---------\r\n## Z-rep ##\r\n---------");
                        sWr.Close();
                        sWr.Dispose();

                        break;
                    }
                case "PeriodicReport":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        PeriodicReport pr = new PeriodicReport(Protocol_Name, description);
                        if (pr.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            PeriodicReport(port, pass, pr.startDate, pr.endDate);
                        pr.Dispose();

                        break;
                    }
                case "PeriodicReportShort":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        PeriodicReportShort prs = new PeriodicReportShort(Protocol_Name, description);
                        if (prs.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            PeriodicReportShort(port, pass, prs.startDate, prs.endDate);
                        prs.Dispose();

                        break;
                    }
                case "PeriodicReport2":
                    {
                        byte[] mem = GetMemory(port, "3003", 16, 2 * 10);
                        uint pass = (uint)Methods.GetNumber(new byte[] { mem[18], mem[19] });
                        PeriodicReport2 pr2 = new PeriodicReport2(Protocol_Name, description);
                        if (pr2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            PeriodicReport2(port, pass, pr2.startNo, pr2.endNo);
                        pr2.Dispose();

                        break;
                    }
                #endregion
            */
                #endregion
            }
            return value;
        }
Esempio n. 39
0
 /// <summary>
 /// Method to handle com port received events from the Dm Rmc. 
 /// </summary>
 /// <param name="ReceivingComPort">Reference to the com port raising this event.</param>
 /// <param name="args">Information about the event being raised.</param>
 void DmRmc_SerialDataReceived(ComPort ReceivingComPort, ComPortSerialDataEventArgs args)
 {
     CrestronConsole.PrintLine("Received from Dm Rmc com port: {0}", args.SerialData);
 }
Esempio n. 40
0
 private void SaleArtIndicate(ComPort port, char sign, uint artno, uint tot, double nprice, double disc, bool discmode)
 {
 }
Esempio n. 41
0
        private void LineFeed(ComPort port, byte lines)
        {
            lastFuncName = "LineFeed";
            CMD = 44;

            DataForSend = Encoding.GetEncoding(1251).GetBytes(lines.ToString());

            //Making data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 42
0
        private object[] ReportXZ(ComPort port, string pwd, byte type, bool[] clearModes)
        {
            lastFuncName = "ReportXZ";
            CMD = 69;

            // Creating data
            string _data = pwd + ',' + type;
            if (clearModes[0])
                _data += 'N';
            if (clearModes[1])
                _data += 'A';

            DataForSend = Encoding.GetEncoding(1251).GetBytes(_data);

            // Creating data
            InputData = CreateInputData(CMD, DataForSend);

            // Sending and reciving data
            SendGetData(port, 20, true);

            // Next code for command
            GetNextCmdCode();

            // Perform processing recived data
            string _xzinfo = Encoding.GetEncoding(1251).GetString(OutputData);
            object[] _xzData = new object[6];
            if (_xzinfo.Length != 0)
            {
                string[] _zxItems = _xzinfo.Split(new char[1] { ',' });
                _xzData[0] = uint.Parse(_zxItems[0]);
                _xzData[1] = double.Parse(_zxItems[1], NumberFormat) / 100;
                _xzData[2] = double.Parse(_zxItems[2], NumberFormat) / 100;
                _xzData[3] = double.Parse(_zxItems[3], NumberFormat) / 100;
                _xzData[4] = double.Parse(_zxItems[4], NumberFormat) / 100;
                _xzData[5] = double.Parse(_zxItems[5], NumberFormat) / 100;
            }

            return _xzData;
        }
Esempio n. 43
0
        private void ResetOrder(ComPort port)
        {
            lastFuncName = "ResetOrder";
            CMD = 57;

            //Making data
            InputData = CreateInputData(CMD, new byte[0]);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 44
0
        private void ReportByUsers(ComPort port, string pwd)
        {
            lastFuncName = "ReportUsers";
            CMD = 105;

            //Creating data
            DataForSend = Encoding.GetEncoding(1251).GetBytes(pwd);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 45
0
        private void ReportByTax(ComPort port, string pwd, DateTime startDate, DateTime endDate)
        {
            lastFuncName = "ReportByTax";
            CMD = 50;

            string _data = pwd + ',';
            _data += startDate.ToString("ddMMyy") + ',';
            _data += endDate.ToString("ddMMyy");
            DataForSend = Encoding.GetEncoding(1251).GetBytes(_data);

            //Making data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 46
0
        private void PrintDiagInfo(ComPort port)
        {
            lastFuncName = "PrintDiagInfo";
            CMD = 71;

            //Preparing data
            InputData = CreateInputData(CMD, new byte[0]);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 47
0
 private double[] SubTotal(ComPort port, bool print, bool indicate, double disc, bool discmode)
 {
     return new double[0];
 }
Esempio n. 48
0
        private void LoadLogo(ComPort port, string pwd, byte[][] logo)
        {
            lastFuncName = "LoadLogo";
            CMD = 115;

            byte _wCorr = 0;
            if (logo[0].Length < 54)
                _wCorr += (byte)(54 - logo[0].Length);
            byte[] _predata = new byte[0];
            for (int _r = 0; _r < logo.Length; _r++)
            {
                //Creating data
                _predata = Encoding.GetEncoding(1251).GetBytes(pwd + ',' + _r + ',');

                DataForSend = new byte[_predata.Length + logo[_r].Length + _wCorr];
                Array.Copy(_predata, 0, DataForSend, 0, _predata.Length);
                Array.Copy(logo[_r], 0, DataForSend, _predata.Length, logo[_r].Length);

                //Preparing data
                InputData = CreateInputData(CMD, DataForSend);

                //Sending and reciving data
                SendGetData(port, 20, true);

                //Next code for command
                GetNextCmdCode();
            }
        }
Esempio n. 49
0
 private object[] Total(ComPort port, string text, char pmode, double money)
 {
     return new object[0];
 }
Esempio n. 50
0
 private ushort[] OpenFOrder(ComPort port, byte uid, string pwd, byte cdno, bool extended)
 {
     return new ushort[0];
 }
Esempio n. 51
0
        private object[] GetUserInfo(ComPort port, byte uid)
        {
            lastFuncName = "GetUserInfo";
            CMD = 112;

            DataForSend = Encoding.GetEncoding(1251).GetBytes(uid.ToString());

            //Making data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();

            // Perform processing recived data
            object[] _user = new object[12];
            string _userInfo = Encoding.GetEncoding(1251).GetString(OutputData);
            if (_userInfo.Length != 0)
            {//0, 0;0.00, 0;0.00, 0;0.00, 0;0.00, 0;0.00, gfdgfdgfd
                string[] _userItems = _userInfo.Split(new char[2] { ',', ';' });
                _user[0] = uint.Parse(_userItems[0]);
                _user[1] = uint.Parse(_userItems[1]);
                _user[2] = double.Parse(_userItems[2], NumberFormat);
                _user[3] = uint.Parse(_userItems[3]);
                _user[4] = double.Parse(_userItems[4], NumberFormat);
                _user[5] = uint.Parse(_userItems[5]);
                _user[6] = double.Parse(_userItems[6], NumberFormat);
                _user[7] = uint.Parse(_userItems[7]);
                _user[8] = double.Parse(_userItems[8], NumberFormat);
                _user[9] = uint.Parse(_userItems[9]);
                _user[10] = double.Parse(_userItems[10], NumberFormat);
                _user[11] = _userItems[11];
            }

            return _user;
        }
Esempio n. 52
0
        private void PrintNText(ComPort port, string ntext)
        {
            lastFuncName = "PrintNText";
            CMD = 42;

            //Creating data
            ntext = ntext.Replace('�', 'i').Replace('�', 'I');
            DataForSend = Encoding.GetEncoding(1251).GetBytes(ntext);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 53
0
        private bool SendGetData(ComPort port, int totRead, bool close)
        {
            string exceptionMsg = "";

            if (!port.IsOpen)
                try
                {
                    port.Open();
                }
                catch { }

            if (port.IsOpen && port.Write(InputData))
            {
                //WinAPI.OutputDebugString("W");

                int t = totRead;
                byte[] buffer = new byte[512];
                OutputData = new byte[0];
                do
                {
                    Array.Clear(buffer, 0, buffer.Length);
                    //WinAPI.OutputDebugString("R");
                    if (port.Read(ref buffer, out ReadedBytes))
                    {
                        Array.Resize<byte>(ref OutputData, (int)(OutputData.Length + ReadedBytes));
                        Array.Copy(buffer, 0, OutputData, OutputData.Length - ReadedBytes, ReadedBytes);
                        try
                        {
                            //WinAPI.OutputDebugString("D");
                            switch (DecodeAnswer())
                            {
                                case "busy":
                                    {
                                        //WinAPI.OutputDebugString("S");
                                        Thread.Sleep(200);
                                        break;
                                    }
                                case "true":
                                    {
                                        //WinAPI.OutputDebugString("T");
                                        ErrorFlags[lastFuncName] = false;
                                        return true;
                                    }
                                case "false":
                                    {
                                        //WinAPI.OutputDebugString("F");
                                        t--;
                                        Thread.Sleep(50);
                                        break;
                                    }
                                case "failed":
                                    {
                                        throw new Exception("������� ��������� ������� \"" + lastFuncName + "\"");
                                    }
                            }
                        }
                        catch (Exception ex)
                        {
                            exceptionMsg = "\r\n" + ex.Message;
                            break;
                        }
                    }
                    else
                        break;

                } while (t > 0);
                //WinAPI.OutputDebugString("E");
            }

            if (close)
                port.Close();

            ErrorFlags[lastFuncName] = true;
            throw new Exception("������� ������� � ���������� ��������" + " " + Protocol_Name + exceptionMsg);
        }
Esempio n. 54
0
        private ushort[] OpenNOrder(ComPort port)
        {
            lastFuncName = "OpenNOrder";
            CMD = 38;

            //Making data
            InputData = CreateInputData(CMD, new byte[0]);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();

            // Perform processing recived data
            string _noinfo = Encoding.GetEncoding(1251).GetString(OutputData);
            ushort[] _noinf = new ushort[4];
            if (_noinfo.Length != 0)
            {
                string[] _noItems = _noinfo.Split(new char[1] { ',' });
                _noinf[0] = ushort.Parse(_noItems[0]);
                _noinf[1] = ushort.Parse(_noItems[1]);
                _noinf[2] = ushort.Parse(_noItems[2]);
                if (_noItems.Length == 4)
                    _noinf[3] = ushort.Parse(_noItems[3]);
            }
            return _noinf;
        }
Esempio n. 55
0
        private void SetDateTime(ComPort port, DateTime dt)
        {
            lastFuncName = "SetDateTime";
            CMD = 61;

            //Creating data
            DataForSend = Encoding.GetEncoding(1251).GetBytes(dt.ToString("dd-MM-yy HH:mm:ss"));

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 56
0
        private string[] SetGetArticle(ComPort port, char option, object[] param)
        {
            lastFuncName = "SetGetArticle";
            CMD = 107;

            //Creating data
            string _data = option.ToString();
            if (!Methods.IsEmpty(param))
                for (int i = 0; i < param.Length; i++)
                    _data += param[i].ToString();

            DataForSend = Encoding.GetEncoding(1251).GetBytes(_data);

            //Preparing data
            InputData = CreateInputData(CMD, DataForSend);

            //Sending and reciving data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();

            //Perform processing recived data
            string _art = Encoding.GetEncoding(1251).GetString(OutputData);
            string[] artInfo = new string[0];

            if (_art.Length != 0)
                artInfo = _art.Split(new char[1] { ',' });

            return artInfo;
        }
Esempio n. 57
0
        private void ReportByArts(ComPort port, string pwd, string mode)
        {
            lastFuncName = "ReportArts";
            CMD = 111;

            DataForSend = Encoding.GetEncoding(1251).GetBytes(pwd + ',' + mode);

            //Making data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 58
0
        private void OpenBox(ComPort port, byte impulse)
        {
            lastFuncName = "OpenBox";
            CMD = 106;

            if (impulse != 0)
                DataForSend = Encoding.GetEncoding(1251).GetBytes(impulse.ToString());
            else
                DataForSend = new byte[0];

            //Making data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 59
0
        private void PrintCopy(ComPort port, byte copies)
        {
            lastFuncName = "PrintCopy";
            CMD = 109;

            //Creating data
            if (copies > 1)
            {
                DataForSend = new byte[1];
                DataForSend[0] = (byte)(copies + 0x30);
            }
            else
                DataForSend = new byte[0];
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }
Esempio n. 60
0
        private void ReportByNoShort(ComPort port, string pwd, uint startZNo, uint endZNo)
        {
            lastFuncName = "ReportByNoShort";
            CMD = 95;

            string _data = pwd + ',';
            _data += string.Format("{0:0000}", startZNo) + ',';
            _data += string.Format("{0:0000}", endZNo);
            DataForSend = Encoding.GetEncoding(1251).GetBytes(_data);

            //Making data
            InputData = CreateInputData(CMD, DataForSend);

            //sending and getting data
            SendGetData(port, 20, true);

            //Next code for command
            GetNextCmdCode();
        }