image001

 

UID:20200349

Name:KIM TAE HOON

“I keep the promises between ProfLee and I”

매트랩 코드

 

classdef testMES < matlab.apps.AppBase

% Properties that correspond to app components

properties (Access = public)

UIFigure                    matlab.ui.Figure

TaehoonsMESProgramV01Label  matlab.ui.control.Label

InformationPanel            matlab.ui.container.Panel

info1                       matlab.ui.control.EditField

MES0Panel                   matlab.ui.container.Panel

ResultPanel                 matlab.ui.container.Panel

WIP_s                       matlab.ui.control.EditField

WIP_q3Label_3               matlab.ui.control.Label

CycleTime_s                 matlab.ui.control.EditField

CycleTime_qLabel_5          matlab.ui.control.Label

WIP_q                       matlab.ui.control.EditField

WIP_q3Label_2               matlab.ui.control.Label

WIP_q3                      matlab.ui.control.EditField

WIP_q3Label                 matlab.ui.control.Label

WIP_q2                      matlab.ui.control.EditField

WIP_q2Label                 matlab.ui.control.Label

WIP_q1                      matlab.ui.control.EditField

WIP_q1Label                 matlab.ui.control.Label

CycleTime_q3                matlab.ui.control.EditField

CycleTime_qLabel_4          matlab.ui.control.Label

CycleTime_q1                matlab.ui.control.EditField

CycleTime_qLabel_3          matlab.ui.control.Label

CycleTime_q2                matlab.ui.control.EditField

CycleTime_qLabel_2          matlab.ui.control.Label

CycleTime_q                 matlab.ui.control.EditField

CycleTime_qLabel            matlab.ui.control.Label

WIPEdit                     matlab.ui.control.EditField

WIPEditFieldLabel           matlab.ui.control.Label

CycleTime                   matlab.ui.control.EditField

CycleTimeEditFieldLabel     matlab.ui.control.Label

TH                          matlab.ui.control.EditField

THEditFieldLabel            matlab.ui.control.Label

ArrivalInformationPanel     matlab.ui.container.Panel

CT_s3                       matlab.ui.control.EditField

Lamda1Label_13              matlab.ui.control.Label

CT_s2                       matlab.ui.control.EditField

Lamda1Label_12              matlab.ui.control.Label

CT_s1                       matlab.ui.control.EditField

Lamda1Label_11              matlab.ui.control.Label

Lamda                       matlab.ui.control.EditField

Lamda1Label_10              matlab.ui.control.Label

Cov_s_3                     matlab.ui.control.EditField

Lamda1Label_9               matlab.ui.control.Label

Cov_s_2                     matlab.ui.control.EditField

Lamda1Label_8               matlab.ui.control.Label

Cov_s_1                     matlab.ui.control.EditField

Lamda1Label_7               matlab.ui.control.Label

Cov_a_3                     matlab.ui.control.EditField

Lamda1Label_6               matlab.ui.control.Label

Cov_a_2                     matlab.ui.control.EditField

Lamda1Label_5               matlab.ui.control.Label

Cov_a_1                     matlab.ui.control.EditField

Lamda1Label_3               matlab.ui.control.Label

ControlPanel                matlab.ui.container.Panel

Button                      matlab.ui.control.Button

ArrivalSwitch               matlab.ui.control.Switch

ArrivalSwitchLabel          matlab.ui.control.Label

serverButton                matlab.ui.control.Button

Lamp                        matlab.ui.control.Lamp

MESSwitch                   matlab.ui.control.ToggleSwitch

MESSwitchLabel              matlab.ui.control.Label

SeverInformationPanel       matlab.ui.container.Panel

table1                      matlab.ui.control.Table

end

 

properties (Access = public)

Property % Description

Property2 % Description

end

 

% Callbacks that handle component events

methods (Access = private)

% Code that executes after component creation

function startupFcn(app)

app.info1.Value='프로그램이 시작됩니다.';

end

% Value changed function: MESSwitch

function MESSwitchValueChanged(app, event)

value = app.MESSwitch.Value;

app.info1.Value='누가 토글 누름?';

app.Lamp.Color=[0,1,0];

end

% Button pushed function: serverButton

function serverButtonPushed(app, event)

app.table1.Data=xlsread("Mesdb.xlsx");

end

% Value changed function: ArrivalSwitch

function ArrivalSwitchValueChanged(app, event)

value = app.ArrivalSwitch.Value;

 

app.Cov_a_1.Value='1.9';

app.Lamda.Value='5';

app.Cov_s_1.Value='1.3';

app.Cov_s_2.Value='1.4';

app.Cov_s_3.Value='1.8';

cov_s1=1.3;

cov_s2=1.4;

cov_s3=1.8;

 

l1=str2num(app.Lamda.Value);

temp=app.table1.Data

c=temp(1,:);

u=temp(2,:);

u_=[];

u_=[l1/(c(1)*u(1)) l1/(c(2)*u(2))  l1/(c(3)*u(3)) ];

 

ca_2=((1-(u_(1))^2)*cov_s1)+((u_(1))^2*(cov_s1+temp(1,1)^(1/2)-1)/(temp(1,1)^(1/2)))

ca_3=((1-(u_(2))^2)*cov_s2)+((u_(2))^2*(cov_s2+temp(1,2)^(1/2)-1)/(temp(1,2)^(1/2)))

app.Cov_a_2.Value=num2str(ca_2);

app.Cov_a_3.Value=num2str(ca_3);

 

E_s=[];

for kk=1:3

E_s=[E_s 1/temp(2,kk)]

end

app.CT_s1.Value=num2str(E_s(1))

app.CT_s2.Value=num2str(E_s(2))

app.CT_s3.Value=num2str(E_s(3))

 

 

end

% Button pushed function: Button

function ButtonPushed(app, event)

app.TH.Value=app.Lamda.Value;

 

l1=str2double(app.Lamda.Value);%읽는건 문자, 쓰는건 숫자니까 숫자로 바꿈

temp=app.table1.Data;%data 숫자,value 문자, 이건 숫자를 받은

sol=l1/(temp(1,1)*temp(2,1));

app.CycleTime.Value= num2str(sol)%sol 숫자이기 때문에 보여지는건 문자로 바꿔야

u=temp(2,:);

c=temp(1,:);

u_=[l1/(c(1)*u(1)) l1/(c(2)*u(2))  l1/(c(3)*u(3)) ];

E_s=[];

for kk=1:3

E_s=[E_s 1/temp(2,kk)]

end

cov_s1=str2num(app.Cov_s_1.Value)

cov_s2=str2num(app.Cov_s_2.Value)

cov_s3=str2num(app.Cov_s_3.Value)

cov_a1=str2num(app.Cov_a_1.Value)

cov_a2=str2num(app.Cov_a_2.Value)

cov_a3=str2num(app.Cov_a_3.Value)

CT_q1=((u_(1)/(1-(u_(1))))*E_s(1)*((cov_s1+cov_a1)/2)*(u_(1)^((2*c(1)+2)^(1/2)-2))/c(1));

CT_q2=((u_(2)/(1-(u_(2))))*E_s(2)*((cov_s2+cov_a2)/2)*(u_(2)^((2*c(2)+2)^(1/2)-2))/c(2));

CT_q3=((u_(3)/(1-(u_(3))))*E_s(3)*((cov_s3+cov_a3)/2)*(u_(3)^((2*c(3)+2)^(1/2)-2))/c(3));

app.CycleTime_q1.Value=num2str(CT_q1);

app.CycleTime_q2.Value=num2str(CT_q2);

app.CycleTime_q3.Value=num2str(CT_q3);

app.CycleTime_q.Value=num2str(CT_q1+CT_q2+CT_q3);

app.CycleTime.Value=num2str(CT_q1+E_s(1)+CT_q2+E_s(2)+CT_q3+E_s(3));

app.CycleTime_s.Value=num2str(sum(E_s))

CT=CT_q1+E_s(1)+CT_q2+E_s(2)+CT_q3+E_s(3);

wip_q1=CT_q1*l1;

wip_q2=CT_q2*l1;

wip_q3=CT_q3*l1;

app.WIP_q1.Value=num2str(wip_q1)

app.WIP_q2.Value=num2str(wip_q2)

app.WIP_q3.Value=num2str(wip_q3)

WIP_qq=wip_q1+wip_q2+wip_q3;

app.WIP_q.Value=num2str(WIP_qq)

WIP=CT*l1;

app.WIPEdit.Value=num2str(WIP);

app.WIP_s.Value=num2str(WIP-WIP_qq);

end

% Cell edit callback: table1

function table1CellEdit(app, event)

indices = event.Indices;

newData = event.NewData;

 

end

end

% Component initialization

methods (Access = private)

% Create UIFigure and components

function createComponents(app)

% Create UIFigure and hide until all components are created

app.UIFigure = uifigure('Visible', 'off');

app.UIFigure.Position = [100 100 930 646];

app.UIFigure.Name = 'MATLAB App';

% Create MES0Panel

app.MES0Panel = uipanel(app.UIFigure);

app.MES0Panel.Title = 'MES0';

app.MES0Panel.Position = [1 139 915 460];

% Create SeverInformationPanel

app.SeverInformationPanel = uipanel(app.MES0Panel);

app.SeverInformationPanel.Title = 'Sever Information';

app.SeverInformationPanel.Position = [647 257 190 170];

% Create table1

app.table1 = uitable(app.SeverInformationPanel);

app.table1.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'};

app.table1.RowName = {};

app.table1.ColumnEditable = true;

app.table1.CellEditCallback = createCallbackFcn(app, @table1CellEdit, true);

app.table1.Position = [1 -3 259 150];

% Create ControlPanel

app.ControlPanel = uipanel(app.MES0Panel);

app.ControlPanel.Title = 'Control';

app.ControlPanel.Position = [17 129 168 302];

% Create MESSwitchLabel

app.MESSwitchLabel = uilabel(app.ControlPanel);

app.MESSwitchLabel.HorizontalAlignment = 'center';

app.MESSwitchLabel.Position = [14 81 40 22];

app.MESSwitchLabel.Text = 'MES';

% Create MESSwitch

app.MESSwitch = uiswitch(app.ControlPanel, 'toggle');

app.MESSwitch.ValueChangedFcn = createCallbackFcn(app, @MESSwitchValueChanged, true);

app.MESSwitch.Position = [15 139 39 88];

% Create Lamp

app.Lamp = uilamp(app.ControlPanel);

app.Lamp.Position = [29 257 10 21];

app.Lamp.Color = [1 0 0];

% Create serverButton

app.serverButton = uibutton(app.ControlPanel, 'push');

app.serverButton.ButtonPushedFcn = createCallbackFcn(app, @serverButtonPushed, true);

app.serverButton.Position = [65 246 49 23];

app.serverButton.Text = 'server';

% Create ArrivalSwitchLabel

app.ArrivalSwitchLabel = uilabel(app.ControlPanel);

app.ArrivalSwitchLabel.HorizontalAlignment = 'center';

app.ArrivalSwitchLabel.Position = [86 137 40 22];

app.ArrivalSwitchLabel.Text = 'Arrival';

% Create ArrivalSwitch

app.ArrivalSwitch = uiswitch(app.ControlPanel, 'slider');

app.ArrivalSwitch.ValueChangedFcn = createCallbackFcn(app, @ArrivalSwitchValueChanged, true);

app.ArrivalSwitch.Position = [82 174 45 20];

% Create Button

app.Button = uibutton(app.ControlPanel, 'push');

app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonPushed, true);

app.Button.Position = [30 21 108 30];

app.Button.Text = '계산';

% Create ArrivalInformationPanel

app.ArrivalInformationPanel = uipanel(app.MES0Panel);

app.ArrivalInformationPanel.Title = 'Arrival Information';

app.ArrivalInformationPanel.Position = [203 240 439 187];

% Create Lamda1Label_3

app.Lamda1Label_3 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_3.HorizontalAlignment = 'right';

app.Lamda1Label_3.Position = [17 105 59 22];

app.Lamda1Label_3.Text = 'COV_a(1)';

% Create Cov_a_1

app.Cov_a_1 = uieditfield(app.ArrivalInformationPanel, 'text');

app.Cov_a_1.Position = [91 105 56 21];

% Create Lamda1Label_5

app.Lamda1Label_5 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_5.HorizontalAlignment = 'right';

app.Lamda1Label_5.Position = [159 106 59 22];

app.Lamda1Label_5.Text = 'COV_a(2)';

% Create Cov_a_2

app.Cov_a_2 = uieditfield(app.ArrivalInformationPanel, 'text');

app.Cov_a_2.Position = [233 106 56 21];

% Create Lamda1Label_6

app.Lamda1Label_6 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_6.HorizontalAlignment = 'right';

app.Lamda1Label_6.Position = [303 104 59 22];

app.Lamda1Label_6.Text = 'COV_a(3)';

% Create Cov_a_3

app.Cov_a_3 = uieditfield(app.ArrivalInformationPanel, 'text');

app.Cov_a_3.Position = [377 104 56 21];

% Create Lamda1Label_7

app.Lamda1Label_7 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_7.HorizontalAlignment = 'right';

app.Lamda1Label_7.Position = [19 72 58 22];

app.Lamda1Label_7.Text = 'COV_s(1)';

% Create Cov_s_1

app.Cov_s_1 = uieditfield(app.ArrivalInformationPanel, 'text');

app.Cov_s_1.Position = [92 72 56 21];

% Create Lamda1Label_8

app.Lamda1Label_8 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_8.HorizontalAlignment = 'right';

app.Lamda1Label_8.Position = [160 72 58 22];

app.Lamda1Label_8.Text = 'COV_s(2)';

% Create Cov_s_2

app.Cov_s_2 = uieditfield(app.ArrivalInformationPanel, 'text');

app.Cov_s_2.Position = [233 72 56 21];

% Create Lamda1Label_9

app.Lamda1Label_9 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_9.HorizontalAlignment = 'right';

app.Lamda1Label_9.Position = [304 73 58 22];

app.Lamda1Label_9.Text = 'COV_s(3)';

% Create Cov_s_3

app.Cov_s_3 = uieditfield(app.ArrivalInformationPanel, 'text');

app.Cov_s_3.Position = [377 73 56 21];

% Create Lamda1Label_10

app.Lamda1Label_10 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_10.HorizontalAlignment = 'right';

app.Lamda1Label_10.Position = [170 135 42 22];

app.Lamda1Label_10.Text = 'Lamda';

% Create Lamda

app.Lamda = uieditfield(app.ArrivalInformationPanel, 'text');

app.Lamda.Position = [227 135 56 21];

% Create Lamda1Label_11

app.Lamda1Label_11 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_11.HorizontalAlignment = 'right';

app.Lamda1Label_11.Position = [20 42 48 22];

app.Lamda1Label_11.Text = 'CT_s(1)';

% Create CT_s1

app.CT_s1 = uieditfield(app.ArrivalInformationPanel, 'text');

app.CT_s1.Position = [83 42 56 21];

% Create Lamda1Label_12

app.Lamda1Label_12 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_12.HorizontalAlignment = 'right';

app.Lamda1Label_12.Position = [162 41 48 22];

app.Lamda1Label_12.Text = 'CT_s(2)';

% Create CT_s2

app.CT_s2 = uieditfield(app.ArrivalInformationPanel, 'text');

app.CT_s2.Position = [225 41 56 21];

% Create Lamda1Label_13

app.Lamda1Label_13 = uilabel(app.ArrivalInformationPanel);

app.Lamda1Label_13.HorizontalAlignment = 'right';

app.Lamda1Label_13.Position = [307 40 48 22];

app.Lamda1Label_13.Text = 'CT_s(3)';

% Create CT_s3

app.CT_s3 = uieditfield(app.ArrivalInformationPanel, 'text');

app.CT_s3.Position = [370 40 56 21];

% Create ResultPanel

app.ResultPanel = uipanel(app.MES0Panel);

app.ResultPanel.Title = 'Result';

app.ResultPanel.Position = [204 23 633 209];

% Create THEditFieldLabel

app.THEditFieldLabel = uilabel(app.ResultPanel);

app.THEditFieldLabel.HorizontalAlignment = 'right';

app.THEditFieldLabel.Position = [-16 83 55 22];

app.THEditFieldLabel.Text = 'TH';

% Create TH

app.TH = uieditfield(app.ResultPanel, 'text');

app.TH.Position = [54 83 99 22];

% Create CycleTimeEditFieldLabel

app.CycleTimeEditFieldLabel = uilabel(app.ResultPanel);

app.CycleTimeEditFieldLabel.HorizontalAlignment = 'right';

app.CycleTimeEditFieldLabel.Position = [11 150 65 22];

app.CycleTimeEditFieldLabel.Text = 'Cycle Time';

% Create CycleTime

app.CycleTime = uieditfield(app.ResultPanel, 'text');

app.CycleTime.Position = [91 150 92 20];

% Create WIPEditFieldLabel

app.WIPEditFieldLabel = uilabel(app.ResultPanel);

app.WIPEditFieldLabel.HorizontalAlignment = 'right';

app.WIPEditFieldLabel.Position = [17 116 28 22];

app.WIPEditFieldLabel.Text = 'WIP';

% Create WIPEdit

app.WIPEdit = uieditfield(app.ResultPanel, 'text');

app.WIPEdit.Position = [60 115 83 24];

% Create CycleTime_qLabel

app.CycleTime_qLabel = uilabel(app.ResultPanel);

app.CycleTime_qLabel.HorizontalAlignment = 'right';

app.CycleTime_qLabel.Position = [208 49 78 22];

app.CycleTime_qLabel.Text = 'Cycle Time_q';

% Create CycleTime_q

app.CycleTime_q = uieditfield(app.ResultPanel, 'text');

app.CycleTime_q.Position = [301 49 92 20];

% Create CycleTime_qLabel_2

app.CycleTime_qLabel_2 = uilabel(app.ResultPanel);

app.CycleTime_qLabel_2.HorizontalAlignment = 'right';

app.CycleTime_qLabel_2.Position = [202 117 92 22];

app.CycleTime_qLabel_2.Text = 'Cycle Time_q(2)';

% Create CycleTime_q2

app.CycleTime_q2 = uieditfield(app.ResultPanel, 'text');

app.CycleTime_q2.Position = [309 117 92 20];

% Create CycleTime_qLabel_3

app.CycleTime_qLabel_3 = uilabel(app.ResultPanel);

app.CycleTime_qLabel_3.HorizontalAlignment = 'right';

app.CycleTime_qLabel_3.Position = [201 151 92 22];

app.CycleTime_qLabel_3.Text = 'Cycle Time_q(1)';

% Create CycleTime_q1

app.CycleTime_q1 = uieditfield(app.ResultPanel, 'text');

app.CycleTime_q1.Position = [308 151 92 20];

% Create CycleTime_qLabel_4

app.CycleTime_qLabel_4 = uilabel(app.ResultPanel);

app.CycleTime_qLabel_4.HorizontalAlignment = 'right';

app.CycleTime_qLabel_4.Position = [203 84 92 22];

app.CycleTime_qLabel_4.Text = 'Cycle Time_q(3)';

% Create CycleTime_q3

app.CycleTime_q3 = uieditfield(app.ResultPanel, 'text');

app.CycleTime_q3.Position = [310 84 92 20];

% Create WIP_q1Label

app.WIP_q1Label = uilabel(app.ResultPanel);

app.WIP_q1Label.HorizontalAlignment = 'right';

app.WIP_q1Label.Position = [440 151 56 22];

app.WIP_q1Label.Text = 'WIP_q(1)';

% Create WIP_q1

app.WIP_q1 = uieditfield(app.ResultPanel, 'text');

app.WIP_q1.Position = [511 150 83 24];

% Create WIP_q2Label

app.WIP_q2Label = uilabel(app.ResultPanel);

app.WIP_q2Label.HorizontalAlignment = 'right';

app.WIP_q2Label.Position = [441 117 56 22];

app.WIP_q2Label.Text = 'WIP_q(2)';

% Create WIP_q2

app.WIP_q2 = uieditfield(app.ResultPanel, 'text');

app.WIP_q2.Position = [512 116 83 24];

% Create WIP_q3Label

app.WIP_q3Label = uilabel(app.ResultPanel);

app.WIP_q3Label.HorizontalAlignment = 'right';

app.WIP_q3Label.Position = [442 84 56 22];

app.WIP_q3Label.Text = 'WIP_q(3)';

% Create WIP_q3

app.WIP_q3 = uieditfield(app.ResultPanel, 'text');

app.WIP_q3.Position = [513 83 83 24];

% Create WIP_q3Label_2

app.WIP_q3Label_2 = uilabel(app.ResultPanel);

app.WIP_q3Label_2.HorizontalAlignment = 'right';

app.WIP_q3Label_2.Position = [459 48 41 22];

app.WIP_q3Label_2.Text = 'WIP_q';

% Create WIP_q

app.WIP_q = uieditfield(app.ResultPanel, 'text');

app.WIP_q.Position = [515 47 83 24];

% Create CycleTime_qLabel_5

app.CycleTime_qLabel_5 = uilabel(app.ResultPanel);

app.CycleTime_qLabel_5.HorizontalAlignment = 'right';

app.CycleTime_qLabel_5.Position = [208 18 77 22];

app.CycleTime_qLabel_5.Text = 'Cycle Time_s';

% Create CycleTime_s

app.CycleTime_s = uieditfield(app.ResultPanel, 'text');

app.CycleTime_s.Position = [300 18 92 20];

% Create WIP_q3Label_3

app.WIP_q3Label_3 = uilabel(app.ResultPanel);

app.WIP_q3Label_3.HorizontalAlignment = 'right';

app.WIP_q3Label_3.Position = [460 17 40 22];

app.WIP_q3Label_3.Text = 'WIP_s';

% Create WIP_s

app.WIP_s = uieditfield(app.ResultPanel, 'text');

app.WIP_s.Position = [515 16 83 24];

% Create InformationPanel

app.InformationPanel = uipanel(app.UIFigure);

app.InformationPanel.Title = 'Information';

app.InformationPanel.Position = [2 38 640 81];

% Create info1

app.info1 = uieditfield(app.InformationPanel, 'text');

app.info1.HorizontalAlignment = 'center';

app.info1.FontWeight = 'bold';

app.info1.Position = [17 18 606 24];

% Create TaehoonsMESProgramV01Label

app.TaehoonsMESProgramV01Label = uilabel(app.UIFigure);

app.TaehoonsMESProgramV01Label.FontSize = 15;

app.TaehoonsMESProgramV01Label.Position = [350 588 235 59];

app.TaehoonsMESProgramV01Label.Text = 'Taehoon''s MES Program V.0.1';

% Show the figure after all components are created

app.UIFigure.Visible = 'on';

end

end

% App creation and deletion

methods (Access = public)

% Construct app

function app = testMES

% Create UIFigure and components

createComponents(app)

% Register the app with App Designer

registerApp(app, app.UIFigure)

% Execute the startup function

runStartupFcn(app, @startupFcn)

if nargout == 0

clear app

end

end

% Code that executes before app deletion

function delete(app)

% Delete UIFigure when app is deleted

delete(app.UIFigure)

end

end

end