Project - MES(Manufacturing Execution System) with Raspberry Pi
실제 분류 공정을 관리 및 모니터링 하는 HMI(Human Machine Interface)를 구현하였습니다.
1. 메인 화면.xaml.cs 👈
2. 공정 설정.xaml.cs 👈
public bool IsValidInputs()
{
var isValid = true;
InitErrorMessage();
if (string.IsNullOrEmpty(TxtBasicCode.Text))
{
LblBasicCode.Visibility = Visibility.Visible;
LblBasicCode.Text = "코드를 입력하세요";
isValid = false;
}
else if (Logic.DataAccess.GetSettings().Where(s => s.BasicCode.Equals(TxtBasicCode.Text)).Count() > 0) // 중복 코드 방지
{
LblBasicCode.Visibility = Visibility.Visible;
LblBasicCode.Text = "중복 코드가 존재합니다";
isValid = false;
}
if (string.IsNullOrEmpty(TxtCodeName.Text))
{
LblCodeName.Visibility = Visibility.Visible;
LblCodeName.Text = "코드명를 입력하세요";
isValid = false;
}
return isValid;
}
3. 공정 일정 생성.xaml.cs 👈
4. 공정 진행.xaml.cs 👈
2. 파이썬 코드를 실행하여 색상 구분 결과를 json형식으로 MQTT(Broker)의 Topic으로 Publish합니다. 라즈베리파이 구동 코드.py 👈
IoT Device Subsriber 실행 화면 IoT Device Subsriber 구동 코드.cs 👈
private void InitConnectMqttBroker()
{
var brokerAddress = IPAddress.Parse("210.119.12.93"); // MQTT Mosquitto Broker IP;
client = new MqttClient(brokerAddress);
client.MqttMsgPublishReceived += Client_MqttMsgPublishReceived;
client.Connect("Monitor");
client.Subscribe(new string[] { "factory1/machine1/data/" },
new byte[] { MqttMsgBase.QOS_LEVEL_AT_MOST_ONCE });
timer.Enabled = true;
timer.Interval = 1000;
timer.Elapsed += Timer_Elapsed;
timer.Start();
}
2. IoT Device Subsriber와 라즈베리파이 구동 코드.py를 실행한 상태에서 라즈베리파이를 통한 색상 구분을 진행한 후 DB에 저장합니다.
if (currentData["PRC_MSG"] == "OK")
{
Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
Product.Fill = new SolidColorBrush(Colors.Green);
}));
}
else if (currentData["PRC_MSG"] == "FAIL")
{
Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
Product.Fill = new SolidColorBrush(Colors.Red);
}));
}
private void UpdateDate()
{
// 성공수량
var prcOKAmount = Logic.DataAccess.GetProcesses().Where(p => p.SchIdx.Equals(currSchedule.SchIdx))
.Where(p => p.PrcResult.Equals(true)).Count();
// 실패수량
var prcFailAmount = Logic.DataAccess.GetProcesses().Where(p => p.SchIdx.Equals(currSchedule.SchIdx))
.Where(p => p.PrcResult.Equals(false)).Count();
// 공정 성공률
var prcOkRate = ((double)prcOKAmount / (double)currSchedule.SchAmount) * 100;
// 공정 실패율
var prcFailRate = ((double)prcFailAmount / (double)currSchedule.SchAmount) * 100;
LblPrcOkAmount.Content = $"{prcOKAmount} 개";
LblPrcFailAmount.Content = $"{prcFailAmount} 개";
LblPrcOkRate.Content = $"{prcOkRate.ToString("#.##")} %";
LblPrcFailRate.Content = $"{prcFailRate.ToString("#.##")} %";
}