Exemple #1
0
        public void ChangeDevice(GateProperty gatep, DeviceConfig devconf, Guid devc_id, DeviceProperty devp)
        {
            if (gatep != null)
            {
                gatep_ = gatep;
            }

            if (devconf != null)
            {
                devconf_ = devconf;
            }

            /* いずれかの状態が変化したらデバイスを再構築 */
            if ((devi_ == null) ||
                (devc_id != devi_.Class.ID) ||
                (!ClassUtil.Compare(devi_.Config, devconf)) ||
                (!ClassUtil.Compare(devi_.Property, devp))
                )
            {
                SetupDevice(DeviceManager.Instance.CreateDeviceObject(devconf, devc_id, devp));
            }

            ApplyGateProperty();

            /* 接続コマンドを再構築 */
            connect_command_ = HexTextEncoder.ToByteArray(gatep_.ConnectCommand);
        }
        private void UpdateEditStatus(DataGridViewCell cell)
        {
            var error_text = "";
            var cmd_target = TBox_CommonTarget.Text;

            /* エラー判定 */
            switch ((ColumnId)cell.OwningColumn.Tag)
            {
            case ColumnId.SendData:
            {
                if (cell.Value is string value_str)
                {
                    if (value_str.Length > 0)
                    {
                        if (HexTextEncoder.ToByteArray(value_str) != null)
                        {
                            cell.Style.BackColor = COLOR_COMMAND_FORMAT_OK;
                        }
                        else
                        {
                            cell.Style.BackColor = COLOR_COMMAND_FORMAT_NG;
                            error_text           = "Command incorrect";
                        }
                    }
                }
            }
            break;

            default:
                break;
            }

            /* エラーテキストを設定 */
            cell.ErrorText = error_text;
        }
Exemple #3
0
        private void UpdateLFCodeView()
        {
            /* 改行パターン取得 */
            lf_code_ = HexTextEncoder.ToByteArray(TBox_LFCode.Text);

            /* 背景色設定 */
            if (TBox_LFCode.Text.Length == 0)
            {
                TBox_LFCode.BackColor = Color.White;
            }
            else
            {
                TBox_LFCode.BackColor = (lf_code_ != null) ? (Color.SkyBlue) : (Color.Pink);
            }
        }
Exemple #4
0
        private void UpdateConnectCommand()
        {
            var exp = TBox_ConnectCommand.Text;

            if (exp.Length > 0)
            {
                TBox_ConnectCommand.BackColor = (HexTextEncoder.ToByteArray(exp) != null)
                                              ? (Ratatoskr.Resource.AppColors.Ok)
                                              : (Ratatoskr.Resource.AppColors.Ng);
            }
            else
            {
                TBox_ConnectCommand.BackColor = Color.White;
            }
        }
        private void UpdateView()
        {
            var text = TBox_Value.Text;

            TBox_Value.ForeColor = (text == Property.DataContentsMatchProperty.Pattern.Value)
                                 ? (Color.Black)
                                 : (Color.Gray);

            if (text.Length > 0)
            {
                TBox_Value.BackColor = (HexTextEncoder.ToByteArray(TBox_Value.Text) != null)
                                     ? (Ratatoskr.Resource.AppColors.Ok)
                                     : (Ratatoskr.Resource.AppColors.Ng);
            }
            else
            {
                TBox_Value.BackColor = Color.White;
            }
        }
Exemple #6
0
        private void LoadConfigPart_Data(XmlElement xml_node)
        {
            if (xml_node == null)
            {
                return;
            }

            var newobj = new PacketObjectConfig();

            /* === パラメータ読み込み === */
            /* protocol-name */
            newobj.ProtocolName = GetAttribute(xml_node, "protocol-name", "");

            /* bit-data */
            newobj.BitData = HexTextEncoder.ToByteArray(GetAttribute(xml_node, "bit-data", ""));

            /* bit-size */
            newobj.BitSize = uint.Parse(GetAttribute(xml_node, "bit-size", ""));

            /* === 設定リストへ追加 === */
            Value.Add(newobj);
        }
Exemple #7
0
        private void UpdateExpListView()
        {
            send_data_exp_ = CBox_ExpList.Text;

            if (send_data_exp_.Length > 0)
            {
#if BINARY_CODE_PARSER
                send_data_bin_ = BinaryTextCompiler.Build(send_data_exp_);
#else
                send_data_bin_ = HexTextEncoder.ToByteArray(send_data_exp_);
#endif

                CBox_ExpList.BackColor = (send_data_bin_ != null)
                                       ? (Ratatoskr.Resource.AppColors.Ok)
                                       : (Ratatoskr.Resource.AppColors.Ng);
            }
            else
            {
                send_data_bin_ = null;

                CBox_ExpList.BackColor = Color.White;
            }
        }
        private void UpdateView()
        {
            /* 表示中の変換式をコンパイル */
            target_codes_exp_new_ = TBox_Target.Text;
            target_codes_obj_new_ = HexTextEncoder.ToByteArrayMap(target_codes_exp_new_);

            replace_code_exp_new_ = TBox_Replace.Text;
            replace_code_obj_new_ = HexTextEncoder.ToByteArray(replace_code_exp_new_);

            /* 表示更新 */
            if (target_codes_exp_new_.Length > 0)
            {
                TBox_Target.BackColor = (target_codes_obj_new_ != null)
                                      ? (Ratatoskr.Resource.AppColors.Ok)
                                      : (Ratatoskr.Resource.AppColors.Ng);
            }
            else
            {
                TBox_Target.BackColor = Color.White;
            }

            if (replace_code_exp_new_.Length > 0)
            {
                TBox_Replace.BackColor = (replace_code_obj_new_ != null)
                                       ? (Ratatoskr.Resource.AppColors.Ok)
                                       : (Ratatoskr.Resource.AppColors.Ng);
            }
            else
            {
                TBox_Replace.BackColor = Color.White;
            }

            /* 変更状態確認 */
            TBox_Target.ForeColor  = (target_codes_exp_busy_ != target_codes_exp_new_) ? (Color.Gray) : (Color.Black);
            TBox_Replace.ForeColor = (replace_code_exp_busy_ != replace_code_exp_new_) ? (Color.Gray) : (Color.Black);
        }
Exemple #9
0
 public Term_Binary(string text)
 {
     value_ = HexTextEncoder.ToByteArray(text);
 }
Exemple #10
0
        private PacketObject ReadContentsRecord(FileFormatOptionImpl option, string[] items)
        {
            try {
                /* 要素解析 */
                var item = (string)null;

                var class_n = "Csv";
                var fac     = PacketFacility.Device;
                var alias   = "";
                var prio    = PacketPriority.Standard;
                var attr    = PacketAttribute.Data;
                var mt      = DateTime.UtcNow;
                var info    = "";
                var dir     = PacketDirection.Recv;
                var src     = "";
                var dst     = "";
                var mark    = (byte)0;
                var message = (string)null;
                var data_s  = "";
                var data    = (byte[])null;

                foreach (var(order_value, order_index) in option.ItemOrder.Select((v, i) => (v, i)))
                {
                    item = items[order_index].TrimEnd();

                    switch (order_value)
                    {
                    case PacketElementID.Class:
                    {
                        class_n = item;
                    }
                    break;

                    case PacketElementID.Facility:
                    {
                        fac = (PacketFacility)Enum.Parse(typeof(PacketFacility), item);
                    }
                    break;

                    case PacketElementID.Alias:
                    {
                        alias = item;
                    }
                    break;

                    case PacketElementID.Priority:
                    {
                        prio = (PacketPriority)Enum.Parse(typeof(PacketPriority), item);
                    }
                    break;

                    case PacketElementID.Attribute:
                    {
                        attr = (PacketAttribute)Enum.Parse(typeof(PacketAttribute), item);
                    }
                    break;

                    case PacketElementID.DateTime_UTC_Display:
                    {
                        mt = DateTime.ParseExact(item, PacketObject.DATETIME_FORMAT_UTC_DISPLAY, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal);
                    }
                    break;

                    case PacketElementID.DateTime_Local_Display:
                    {
                        mt = DateTime.ParseExact(item, PacketObject.DATETIME_FORMAT_LOCAL_DISPLAY, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal);
                    }
                    break;

                    case PacketElementID.Information:
                    {
                        info = item;
                    }
                    break;

                    case PacketElementID.Direction:
                    {
                        dir = (PacketDirection)Enum.Parse(typeof(PacketDirection), item);
                    }
                    break;

                    case PacketElementID.Source:
                    {
                        src = item;
                    }
                    break;

                    case PacketElementID.Destination:
                    {
                        dst = item;
                    }
                    break;

                    case PacketElementID.Mark:
                    {
                        mark = byte.Parse(item);
                    }
                    break;

                    case PacketElementID.Message:
                    {
                        message = item;
                    }
                    break;

                    case PacketElementID.Data_HexString:
                    {
                        data_s = item;
                    }
                    break;
                    }
                }

                /* パケット生成 */
                switch (attr)
                {
                case PacketAttribute.Message:
                {
                    if (message == null)
                    {
                        message = data_s;
                    }
                }
                break;

                case PacketAttribute.Data:
                {
                    data = HexTextEncoder.ToByteArray(data_s);
                }
                break;

                default:
                    break;
                }

                return(new PacketObject(class_n, fac, alias, prio, attr, mt, info, dir, src, dst, mark, message, data));
            } catch {
                return(null);
            }
        }