// 学習データに、データを追加する
        private void addLearnData(int Type, int WorkID, double Val, ref LearnDataStruct[] LearnData)
        {
            if (LearnData == null) LearnData = new LearnDataStruct[0];

            MemAllocStruct memstruct = memalloc.GetEntry(SystemConstants.WORKID_TYPE_WORKDATA, WorkID);

            // 追加のデータを作成する
            LearnDataStruct newDataStruct = new LearnDataStruct();
            newDataStruct.Type = Type;
            newDataStruct.SearchType = memstruct.learn_key_code;
            newDataStruct.ID = WorkID;
            newDataStruct.value = Val.ToString();

            // 新しい配列を1つ追加する
            int n = LearnData.Length;
            Array.Resize(ref LearnData, n + 1);
            LearnData[n] = newDataStruct;
        }
Beispiel #2
0
        /// <summary>
        /// 学習データをまるごと加工値メモリに設定する
        /// </summary>
        /// <param name="LearnData"></param>
        /// <returns></returns>
        public int SetArray(LearnDataStruct[] LearnData)
        {
            List<int> workID = new List<int>();
            int[] groupID = null;
            int[] temp_workID = null;
            MemAllocStruct memAllocStruct = null;
            int result = SystemConstants.MCPF_SUCCESS;

            // 加工メモリをクリアする
            map.Clear();

            // 学習データ配列がnullの場合、長さ0の配列を作る
            if (LearnData == null) LearnData = new LearnDataStruct[0];

            // 受け取った学習データをすべて加工値メモリに書く
            for (int i = 0; i < LearnData.Length; i++)
                Set(LearnData[i].Type, LearnData[i].ID, LearnData[i].value);

            /* メモリ割当データの一覧を取得する */
            // 加工値のgroup code の一覧を取得
            try
            {
                memAllocData.GetMemoryDataGroupList(SystemConstants.WORKID_TYPE_WORKDATA, SystemConstants.WORKGROUP_ROOT, ref groupID);
            }
            catch (MemoryAllocationDataException)
            {
                return SystemConstants.ERR_WORKID_RANGE;
            }

            // 一覧取得したgroup codeからwork IDの一覧を取得
            for (int i = 0; i < groupID.Length; i++)
            {
                try
                {
                    memAllocData.GetMemoryDataGroupList(SystemConstants.WORKID_TYPE_WORKDATA, groupID[i], ref temp_workID);
                }
                catch (MemoryAllocationDataException)
                {
                    return SystemConstants.ERR_WORKID_RANGE;
                }

                // WorkIDに取得したworkID一覧を追加する
                for (int j = 0; j < temp_workID.Length; j++) workID.Add(temp_workID[j]);
            }

            // メモリ割当データにあって、加工メモリに不足しているデータを補う
            for (int i = 0; i < workID.Count; i++)
            {
                // workID のメモリ割当データを取得する
                try
                {
                    memAllocStruct = memAllocData.GetEntry(SystemConstants.WORKID_TYPE_WORKDATA, workID[i]);
                }
                catch (MemberAccessException)
                {
                    continue;
                }

                // 加工値メモリに存在しない場合は、デフォルト値で補う
                KeyStruct key = new KeyStruct(SystemConstants.WORKMEM_TYPE_WORKDATA, workID[i]);
                if (!map.ContainsKey(key))
                {
                    // 加工値メモリに不足IDを、メモリ割当データの初期値で追加
                    Set(SystemConstants.WORKMEM_TYPE_WORKDATA, workID[i], memAllocStruct.DefaultValue.ToString());

                    // 学習データ割当の値が欠損していた場合は、ERROR_LEARN_PARTS_BREAKを返す。
                    if (LearnDataStorage.IsLearnSearchKeyCode(memAllocStruct.learn_key_code))
                        result = SystemConstants.ERR_LEARN_PARTS_BREAK;
                }
            }

            // 全てのボタンIDを取得
            int[] btnWorkID = new int[0];
            buttonControl.GetAllBtnWorkID(ref btnWorkID);

            // ボタンworkIDの数だけループする
            for (int i = 0; i < btnWorkID.Length; i++)
            {
                // ボタンIDを取得
                ButtonActionStruct btnStore = buttonControl.Get(btnWorkID[i]);
                KeyStruct key = new KeyStruct(SystemConstants.WORKMEM_TYPE_WORKBTN, btnWorkID[i]);

                // 加工値メモリが存在しない場合は、デフォルト値で補う
                if (!map.ContainsKey(key))
                {
                    Set(SystemConstants.WORKMEM_TYPE_WORKBTN, btnWorkID[i], btnStore.DefaultMode.ToString());
                }
            }

            return result;
        }
Beispiel #3
0
        /// <summary>
        /// 加工値メモリから取得したデータをLearnDataに入れて返す
        /// </summary>
        /// <param name="LearnData"></param>
        /// <returns></returns>
        public int GetArray(ref LearnDataStruct[] LearnData)
        {
            int i = 0;
            MemAllocStruct memAllocStruct = null;

            // LearnDataがnullの場合、構造体を割当てる
            if (LearnData == null) LearnData = new LearnDataStruct[0];

            foreach (WorkDataStruct learndata in map.Values)
            {
                if (learndata.Type == SystemConstants.WORKMEM_TYPE_WORKDATA)
                {
                    // WorkIDのメモリ割当データを取得する
                    try
                    {
                        memAllocStruct = memAllocData.GetEntry(SystemConstants.WORKID_TYPE_WORKDATA, learndata.WorkID);
                    }
                    catch (MemoryAllocationDataException)
                    {
                        memAllocStruct = new MemAllocStruct();
                        memAllocStruct.learn_key_code = SystemConstants.DB_GROUP_SEARCH_TYPE_NONE;
                    }

                    // 学習データ対象の場合
                    if (LearnDataStorage.IsLearnSearchKeyCode(memAllocStruct.learn_key_code))
                    {
                        // 配列を一つ増やす
                        Array.Resize(ref LearnData, LearnData.Length + 1);

                        // LearnDataに加工値メモリの値を設定
                        LearnData[i].Type = learndata.Type;
                        LearnData[i].SearchType = memAllocStruct.learn_key_code;
                        LearnData[i].ID = learndata.WorkID;
                        LearnData[i].value = learndata.Value;
                        i++;
                    }
                }
                else if (learndata.Type == SystemConstants.WORKMEM_TYPE_WORKBTN)
                {
                    // ボタンIDの学習データ保存対象を取得
                    ButtonActionStruct btnLearnStore = new ButtonActionStruct();

                    try
                    {
                        btnLearnStore = buttonControl.Get(learndata.WorkID);
                    }
                    catch
                    {
                        btnLearnStore.SearchType = SystemConstants.DB_GROUP_SEARCH_TYPE_BTN;
                    }

                    if(btnLearnStore.SearchType != SystemConstants.DB_GROUP_SEARCH_TYPE_BTN)
                    {
                        // 配列の要素を1つ増やす
                        Array.Resize(ref LearnData, LearnData.Length + 1);

                        // LearnDataにデータを追加
                        LearnData[i].Type = learndata.Type;
                        LearnData[i].SearchType = btnLearnStore.SearchType;
                        LearnData[i].ID = learndata.WorkID;
                        LearnData[i].value = learndata.Value;
                        i++;
                    }

            /*
                    // 動作処理ボタンの場合
                    if (LearnDataStorage.IsLearnedModeBtn(learndata.WorkID))
                    {
                        // 配列の要素を1つ増やす
                        Array.Resize(ref LearnData, LearnData.Length + 1);

                        // LearnDataにデータを追加
                        LearnData[i].Type = learndata.Type;
                        LearnData[i].SearchType = SystemConstants.DB_GROUP_SEARCH_TYPE_BTN;
                        LearnData[i].ID = learndata.WorkID;
                        LearnData[i].value = learndata.Value;
                        i++;
                    }
             */
                }
            }

            return SystemConstants.DCPF_SUCCESS;
        }
Beispiel #4
0
        /// <summary>
        /// ��������
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void syncroprogressfrm_Shown(object sender, EventArgs e)
        {
            try
            {
                //�t�H�[�}�b�g�f�[�^�擾
                Program.DataController.MemorySynchro(SystemConstants.ADDR_FORMAT_CHECK, SystemConstants.FORMAT_CHECK_COUNT);
                waitForQueue(false);

                // �t�H�[�}�b�g�`�F�b�N
                formatType = Program.DataController.FomatCheck();

                // bankno
                int bankno = 0;

                // �w�K�f�[�^���ڃL�[��擾
                int workmode = SystemConstants.WORKMODE_BANK;
                string[] itemkeys = new string[10];
                if (Program.DataController.LearnItemKeysRead(ref itemkeys) == SystemConstants.DCPF_SUCCESS)
                {
                    workmode = SystemConstants.WORKMODE_LEARN;
                }

                if (workmode == SystemConstants.WORKMODE_LEARN)
                {
                    LearnDataStruct[] learndataStruct = new LearnDataStruct[0];
                    Program.DataController.LearnDataRead(itemkeys, ref learndataStruct);
                    bankDataQueue = learndataStruct.Length;
                    workDataQueue = learndataStruct.Length;
                }
                else
                {
                    Program.DataController.BankNoRead(ref bankno);
                    BankDataStruct[] bankdataStruct = new BankDataStruct[0];
                    Program.DataController.BankDataRead(bankno, ref bankdataStruct);
                    bankDataQueue = bankdataStruct.Length;
                    workDataQueue = bankdataStruct.Length;
                }

                //�t�H�[�}�b�g�ς݂̏ꍇ
                if (formatType == SystemConstants.FORMAT_DONE)
                {
                    // ���M����l�̐�����߂�
                    correctDataQueue = Program.DataController.CorrectDataRead(false);
                    timingDataQueue = Program.DataController.TimingDataRead(false);
                    statusDataQueue = Program.DataController.MachineStatusRead(false);
                    workDataQueue = Program.DataController.WorkDataRead(false);
                    allQueue = correctDataQueue + timingDataQueue + statusDataQueue + workDataQueue + bankDataQueue;

                    // �␳�l�̎�M
                    Program.DataController.CorrectDataRead();
                    waitForQueue(true, Phase.CorrectReading);

                    // �^�C�~���O�l�̎�M
                    Program.DataController.TimingDataRead();
                    waitForQueue(true, Phase.TimingReading);

                    // �X�e�[�^�X�l�̎�M
                    Program.DataController.MachineStatusRead();
                    waitForQueue(true, Phase.StatusReading);

                    // ���H�l�̓���
                    Program.DataController.WorkDataRead();
                    waitForQueue(true, Phase.WorkdataReading);

                    if (workmode == SystemConstants.WORKMODE_LEARN)
                    {
                        // �w�K�f�[�^���M
                        mainfrm.LearnDataLoad(itemkeys);
                        waitForQueue(true, Phase.BankWriting);
                    }
                    else
                    {
                        // �o���N�f�[�^�̑��M
                        mainfrm.BankDataLoad(bankno);
                        waitForQueue(true, Phase.BankWriting);
                    }

                }
                // �t�H�[�}�b�g�ς݂łȂ��ꍇ
                else
                {
                    // ���M����l�̐�����߂�
                    correctDataQueue = Program.DataController.CorrectDataSend(false);
                    timingDataQueue = Program.DataController.TimingDataSend(false);
                    statusDataQueue = Program.DataController.MachineStatusRead(false);
                    workDataQueue = Program.DataController.WorkDataRead(false);
                    allQueue = correctDataQueue + timingDataQueue + statusDataQueue + workDataQueue + bankDataQueue;

                    // �A�v���P�[�V�����̑��s�m�F
                    if (!Utility.ShowConfirmMsg(SystemConstants.SYSTEM_MSG007))
                    {
                        DialogResult = DialogResult.No;
                        return;
                    }

                    // �␳�l�𑗂�
                    try
                    {
                        Program.DataController.CorrectDataSend();
                        waitForQueue(true, Phase.CorrectWriting);

                        Program.DataController.TimingDataSend();
                        waitForQueue(true, Phase.TimingWriting);
                    }
                    catch
                    {
                        Result = SystemConstants.ERR_CORRECT_FILE_ERROR;
                        DialogResult = System.Windows.Forms.DialogResult.No;
                        return;
                    }

                    // �X�e�[�^�X�l�̎�M
                    Program.DataController.MachineStatusRead();
                    waitForQueue(true, Phase.StatusReading);

                    // ���H�l�̓���
                    Program.DataController.WorkDataRead();
                    waitForQueue(true, Phase.WorkdataReading);

                    if (workmode == SystemConstants.WORKMODE_LEARN)
                    {
                        // �w�K�f�[�^���M
                        mainfrm.LearnDataLoad(itemkeys);
                        waitForQueue(true, Phase.BankWriting);
                    }
                    else
                    {
                        // �o���N�f�[�^�̑��M
                        mainfrm.BankDataLoad(bankno);
                        waitForQueue(true, Phase.BankWriting);
                    }

                    // �t�H�[�}�b�g������������݂܂��B
                    Program.DataController.FormatWrite();
                }

                if (workmode == SystemConstants.WORKMODE_LEARN)
                {
                    // �w�K�f�[�^��ۑ�����B
                    mainfrm.LearnDataSave(itemkeys);
                }
                else
                {
                    // �o���N�f�[�^��ۑ�����B
                    mainfrm.BankDataSave(bankno);
                }
                // �␳�l��ۑ�����
                Program.DataController.CorrectDataSave();
            }
            catch (TimeoutException)
            {
                /* �^�C���A�E�g�����������ꍇ�́A�����փW�����v */
                DialogResult = DialogResult.No;
                Result = SystemConstants.ERR_SYNC_TIMEOUT;
                return;
            }

            //�v���O���X�o�[�t�H�[����‚���B
            DialogResult = DialogResult.OK;
        }
Beispiel #5
0
        /// <summary>
        /// LearnData[] の値を学習データ保存クラスの WriteLearnDataを使用して、学習データに保存
        /// </summary>
        /// <param name="ItemKeys"></param>
        /// <param name="LearnData"></param>
        /// <returns></returns>
        public int LearnDataWrite(string[] ItemKeys, LearnDataStruct[] LearnData)
        {
            int result = learnDataStorage.WriteLearnData(ItemKeys, LearnData);

            // 正常の場合は、DCPF_SUCCESSを返す
            if (result == SystemConstants.LSPF_SUCCESS)
                return SystemConstants.DCPF_SUCCESS;
            else
                return result;
        }
Beispiel #6
0
        /// <summary>
        /// 学習データを保存する
        /// </summary>
        /// <param name="ItemKeys"></param>
        /// <returns></returns>
        public int LearnDataSave(string[] ItemKeys)
        {
            int result = 0;

            LearnDataStruct[] learnData = new LearnDataStruct[0];

            // 加工値メモリから、LearnDataを取得する
            result = workDataMemory.GetArray(ref learnData);
            if (result != SystemConstants.DCPF_SUCCESS)
            {
                return result;
            }

            // メモリ割当データの現在地をLearnDataWriteを使用して、学習データに保存
            result = LearnDataWrite(ItemKeys, learnData);

            return result;
        }
Beispiel #7
0
        /// <summary>
        /// LearnData[] の値を学習データ保存クラスのGetLearnDataを使用して返す
        /// </summary>
        /// <param name="ItemKeys"></param>
        /// <param name="LearnData"></param>
        /// <returns></returns>
        public int LearnDataRead(string[] ItemKeys, ref LearnDataStruct[] LearnData)
        {
            int result = learnDataStorage.GetLearnData(ItemKeys, ref LearnData);

            if ((result != SystemConstants.LSPF_SUCCESS) && (result != SystemConstants.ERR_LSPF_NO_LEARN_DATA))
            {
                return result;
            }

            // 切断長の補完(学習データがない場合入力したデータへ初期値を置き換え)
            if(!learnDataStorage.IsIncludeWireLength(LearnData))
            {
                double wireLen = learnDataStorage.ConvKeytoWireLength(ItemKeys);
                addLearnData(SystemConstants.WORKMEM_TYPE_WORKDATA, SystemConstants.WIRE_LENGTH1, wireLen, ref LearnData);
            }

            // ストリップ1の補完を行う
            if (!learnDataStorage.IsIncludeStripLength(SystemConstants.DB_GROUP_WORKSIDE1, LearnData))
            {
                if (learnDataStorage.IsStripWork(SystemConstants.DB_GROUP_WORKSIDE1, ItemKeys))
                {
                    double stripLen1 = learnDataStorage.ConvKeytoStrip(SystemConstants.DB_GROUP_WORKSIDE1, ItemKeys);
                    addLearnData(SystemConstants.WORKMEM_TYPE_WORKDATA, SystemConstants.STRIP_LENGTH1, stripLen1, ref LearnData);
                }
            }

            // ストリップ2の補完を行う
            if (!learnDataStorage.IsIncludeStripLength(SystemConstants.DB_GROUP_WORKSIDE2, LearnData))
            {
                if (learnDataStorage.IsStripWork(SystemConstants.DB_GROUP_WORKSIDE2, ItemKeys))
                {
                    double stripLen2 = learnDataStorage.ConvKeytoStrip(SystemConstants.DB_GROUP_WORKSIDE2, ItemKeys);
                    addLearnData(SystemConstants.WORKMEM_TYPE_WORKDATA, SystemConstants.STRIP_LENGTH2, stripLen2, ref LearnData);
                }
            }

            // 補完処理を行う
            WorkDataMemory memory = new WorkDataMemory();
            memory.Initialize(memalloc, buttonControl);
            result = memory.SetArray(LearnData);

            LearnData = new LearnDataStruct[0];
            memory.GetArray(ref LearnData);

            return result;
        }