public void TestSettingProperty_Input_SettingAsExpected()
        {
            ///Arrange
            CommonMarkingConditionsModule.Model.CommonMarkingConditions obj = new CommonMarkingConditionsModule.Model.CommonMarkingConditions();
            string input = "K1,0,0,0,0,0,0,0,000.50,0000.0,0000,0000.0,0000.000,0000.000,00,00001,0000.0,0000.0,00000,00000,2,1\r";
            string actual;
            //string expect = "0,0,0,0,0,0,000.50,0000.0,0,0,0000.000,0000.000,00,00001,0000.0,0000.0,00000,00000,2,1\r";
            string expect = "0,0,0,0,0,0,000.50,0000.0,0000,0000.0,0000.000,0000.000,00,00001,0000.0,0000.0,00000,00000,2,1\r";

            ///Act
            obj.SettingFromLMController = input;
            actual = obj.SettingToLMController;

            ///Assert
            string[] actualArray = actual.Split('\r', ',', ' ').Where(x => x != "").ToArray();
            string[] expectArray = expect.Split('\r', ',', ' ').Where(x => x != "").ToArray();

            List <double> actualList = new List <double>();

            foreach (var element in actualArray)
            {
                actualList.Add(Convert.ToDouble(element));
            }
            List <double> expectList = new List <double>();

            foreach (var element in expectArray)
            {
                expectList.Add(Convert.ToDouble(element));
            }

            Assert.AreEqual(expectList, actualList);
        }
Beispiel #2
0
        public void Download(CommonMarkingConditionsModule.Model.CommonMarkingConditions cmcs)
        {
            try
            {
                sp.Close();
                sp.Open();
                string command = cmcs.HeaderToRequestCommonMarkingConditionsFromLM + "," + cmcs.ProgramNo + cmcs.Delimiter;
                sp.WriteLine(command);  //(K1,xxxx\r)
                Task.Delay(250).Wait();

                string responseFromPort = sp.ReadExisting();
                //Thread.Sleep(250);

                string[] responses = responseFromPort.Split(delimiterString, System.StringSplitOptions.RemoveEmptyEntries);

                if (responses[1] == NoError) //no error
                {
                    cmcs.SettingFromLMController = responseFromPort;
                }
                else
                {
                    Model.ErrorCode _errorCode = new Model.ErrorCode();
                    _errorCode.NoErrorExists(responseFromPort);
                }
            }
            catch (System.IO.IOException ex) { throw new System.IO.IOException(ex.Message); }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                sp.Close();
            }
        }
Beispiel #3
0
        public void Upload(CommonMarkingConditionsModule.Model.CommonMarkingConditions cmcs)
        {
            try
            {
                sp.Close();
                sp.Open();
                sp.WriteLine(cmcs.HeaderToSetCommonMarkingConditionsInLM + "," + cmcs.ProgramNo + "," + cmcs.SettingToLMController + cmcs.Delimiter);  //(K0,parameters...\r)
                Task.Delay(200).Wait();

                string ReturnedCommonMarkingConditions = sp.ReadExisting();

                string[] CommonMarkingConditions = ReturnedCommonMarkingConditions.Split(delimiterString, System.StringSplitOptions.RemoveEmptyEntries);

                if (CommonMarkingConditions[1] == NoError) //no error
                {
                    System.Windows.MessageBox.Show("Upload is finished!");
                }
                else
                {
                    //For iteration and incremental 2
                    Model.ErrorCode _errorCode = new Model.ErrorCode();
                    _errorCode.CommunicationErrorMsg(ReturnedCommonMarkingConditions);
                    string error = CommonMarkingConditions[2] + _errorCode.CommunicationErrorMsg(ReturnedCommonMarkingConditions);
                    //ErrorLog function............
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
            finally
            { sp.Close(); }
        }
        private void OpenSettingFromXML_Click(object sender, RoutedEventArgs e)
        {
            SerializationAndDeserialzation SAD = new SerializationAndDeserialzation();

            SAD = SAD.Deserialize();
            this._blockConditionsList     = SAD.blockConditionsList;
            this._commonMarkingConditions = SAD.commonMarkingConditions;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            sp = new SerialPort("COM9", 38400, Parity.None, 8, StopBits.One);
            try
            {
                //sp.Open();
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }

            _operationWithSerialport = new Model.OperationWithSerialport(sp, LB1);
            _commonMarkingConditions = new CommonMarkingConditionsModule.Model.CommonMarkingConditions();
            _blockConditions         = new BlockConditionsWindow.Model.BlockConditions();
            // _blockConditionsList = new List<BlockConditionsWindow.Model.BlockConditions>();
        }