コード例 #1
0
        /// <summary>
        /// Получен пакет от клиентс
        /// </summary>
        /// <param name="packet">Полученный пакет</param>
        public void server_OnPacket(string packet)
        {
            try
            {
                AsyPacket _packet = AsyPacket.Parse(packet);
                if (_packet != null)
                {
                    if (_packet.Data.Length == 7)
                    {
                        Parameter.SetCurrentValue(commutator.Speed_1, _packet.Data[0]);
                        Parameter.SetCurrentValue(commutator.Speed_2, _packet.Data[1]);

                        Parameter.SetCurrentValue(commutator.Speed_rotor, _packet.Data[2]);
                        Parameter.SetCurrentValue(commutator.Torque_rotor, _packet.Data[3]);

                        Parameter.SetCurrentValue(commutator.Wedges_state, _packet.Data[4]);

                        Parameter.SetCurrentValue(commutator.Diameter_1, _packet.Data[5]);
                        Parameter.SetCurrentValue(commutator.Diameter_2, _packet.Data[6]);
                    }
                    else
                    if (_packet.Data.Length >= 8)
                    {
                        Parameter.SetCurrentValue(commutator.Speed_1, _packet.Data[0]);
                        Parameter.SetCurrentValue(commutator.Speed_2, _packet.Data[1]);

                        Parameter.SetCurrentValue(commutator.Speed_rotor, _packet.Data[2]);
                        Parameter.SetCurrentValue(commutator.Torque_rotor, _packet.Data[3]);

                        Parameter.SetCurrentValue(commutator.Wedges_state, _packet.Data[4]);

                        Parameter.SetCurrentValue(commutator.Diameter_1, _packet.Data[5]);
                        Parameter.SetCurrentValue(commutator.Diameter_2, _packet.Data[6]);

                        Parameter.SetCurrentValue(commutator.Force, _packet.Data[7]);
                    }

                    code_button = CodeButtonAsy.Default;
                    switch (_packet.CodeButton)
                    {
                    case 0x00:

                        code_button = CodeButtonAsy.Default;
                        Parameter.SetCurrentValue(_app.Commutator.CodeButton, 0x00);

                        break;

                    case 0x1:

                        code_button = CodeButtonAsy.Load;
                        Parameter.SetCurrentValue(_app.Commutator.CodeButton, 0x1);
                        break;

                    case 0x2:

                        code_button = CodeButtonAsy.Consumption;
                        Parameter.SetCurrentValue(_app.Commutator.CodeButton, 0x02);
                        break;

                    case 0x4:

                        code_button = CodeButtonAsy.Talblok;
                        Parameter.SetCurrentValue(_app.Commutator.CodeButton, 0x04);
                        break;

                    case 0x8:

                        code_button = CodeButtonAsy.Flow;
                        Parameter.SetCurrentValue(_app.Commutator.CodeButton, 0x08);
                        break;

                    case 0x10:

                        code_button = CodeButtonAsy.Volume;
                        Parameter.SetCurrentValue(_app.Commutator.CodeButton, 0x10);
                        break;

                    default:
                        break;
                    }

                    AnswerAsy(_packet);
                    UpdateDevManData();

                    if (OnTec != null)
                    {
                        OnTec(this, EventArgs.Empty);
                    }
                }
            }
            catch { }
        }
コード例 #2
0
ファイル: Commutator.Wcf.cs プロジェクト: slawer/asy
 public static void setCurrent(Parameter parameter, Single value)
 {
     Parameter.SetCurrentValue(parameter, value);
 }