案例1:柔性制造物联网加工流水线设计与实现
为了实时监控加工流程,使用NSTimer类型计时器timer,设定每隔一秒即调用一次回调函数onTimer。在此回调函数中实现对设备信息的HTTP网络请求。
在实际加工工艺中,对水晶体和底座的加工流程是不同的。对于这两个对象将采用都继承自UIImageView类但设置不同的image来区分。
对于水晶体,从毛坯库中取出到最后进入成品库,这个流程根据其加工特点分为三段,水晶体的轨迹运行动画亦可据此分为三段。动画的命名如下表 。

与水晶体略有不同的是,底座的加工是在铣床内,且加工过的底座会有一定的坏品率,对于良品底座和次品底座,它们会有不同的流程,根据其特点也可对底座的加工流程进行分段。具体见下表:

根据上表所示的水晶体和底座的加工流程,在系统每隔一秒刷新获取每个设备的IO触点信息后,将会对进行一次判断,判断的内容是上一个设备的O触点和下一个设备的I触点是否同时为TRUE,如果是,那么水晶体或底座将执行相应动画。在系统进行一次HTTP请求获取设备IO信息后,会自动调用回调函数getDeviceInfo(),该函数会进行如上所述的判断,这对程序的运行起着调度作用,下图说明了该函数中的判断逻辑。

案例1:柔性制造物联网加工流水线设计与实现 -动画代码
/// 水晶:机械臂--->内雕机
-(void)_07_F_ARM_To_D_Laser_
{
[UIView animateWithDuration:1 animations:^{
[currentBallsetCenter:position.D_Laser];
F_ARM.transform = CGAffineTransformMakeRotation(60 * M_PI /180);
[F_ARM setCenter:CGPointMake(F_ARM.center.x + 20, F_ARM.center.y)];
[F_ARM_BasesetCenter:CGPointMake(F_ARM_Base.center.x + 20, F_ARM_Base.center.y)];
[gongjianInfoView.neidiaojiStateLabelsetText:@“运行”];
} completion:^(BOOL finished) {
//~~~~~~~~~~
[self setF_ARM_withBall:NO];
[UIView animateWithDuration:1 animations:^{
F_ARM.transform = CGAffineTransformMakeRotation(0 * M_PI /180);
[currentBall setAlpha:0];
} completion:^(BOOL finished) {
//---------------------------------
if (isShowModel) {
//在内雕机加工1s
[self performSelector:@selector(_08_D_Laser_To_H_Belt_3_Mid_)withObject:nil afterDelay:1];
// [self_08_D_Laser_To_H_Belt_3_Mid_];
}
}];
}];
}
/// 水晶:内雕机--->机械臂--->皮带2--->...--->皮带3
-(void)_08_D_Laser_To_H_Belt_3_Mid_
{
[UIView animateWithDuration:1 animations:^{
[currentBall setAlpha:1];
F_ARM.transform = CGAffineTransformMakeRotation(60 * M_PI /180);
} completion:^(BOOL finished) {
//~~~~~~~~~~~~~~~
[self setF_ARM_withBall:YES];
[UIView animateWithDuration:1 animations:^{
//内雕机--->皮带2
[currentBallsetCenter:position.H_Belt_2_Mid];
F_ARM.transform = CGAffineTransformMakeRotation(-40 * M_PI /180);
// [F_ARM setCenter:CGPointMake(F_ARM.center.x + 50, F_ARM.center.y)];
// [F_ARM_BasesetCenter:CGPointMake(F_ARM_Base.center.x + 50, F_ARM_Base.center.y)];
[gongjianInfoView.neidiaojiStateLabelsetText:@"等待"];
} completion:^(BOOL finished) {
//~~~~~~~
[self setF_ARM_withBall:NO];
//皮带2--->转角机构2
[self_08_D_Laser_To_H_Belt_3_Mid_1];
[UIViewanimateWithDuration:1 animations:^{
//机械臂 归位
F_ARM.transform = CGAffineTransformMakeRotation(0 * M_PI /180);
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:1 animations:^{
//机械臂 和 底盘 回到初始位置
[F_ARM setCenter:CGPointMake(405, 275)];
[F_ARM_BasesetCenter:CGPointMake(410, 275)];
}];
}];
}];
}];
}
//水晶:转角机构3--->传送带3
-(void)_08_D_Laser_To_H_Belt_3_Mid_3
{
[UIView animateWithDuration:1 animations:^{
K_Corner_3.transform = CGAffineTransformMakeRotation(90 * M_PI /180);
currentBall.transform = CGAffineTransformMakeRotation(180 * M_PI /180);
currentBall.tray.transform = CGAffineTransformMakeRotation(180 * M_PI /180);
} completion:^(BOOL finished) {
[UIView animateWithDuration:1 animations:^{
[currentBallsetCenter:position.H_Belt_3_Mid];
[currentBall.traysetCenter:position.H_Belt_3_Mid];
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:1 animations:^{
//转角机构3归位
K_Corner_3.transform = CGAffineTransformMakeRotation(0 * M_PI /180);
}];
//-----------------------------------
if (isShowModel) {
[self_09_H_Belt_3_Mid_To_L_Construction_];
}
}];
}];
}
/// 水晶:皮带3--->装配单元
-(void)_09_H_Belt_3_Mid_To_L_Construction_
{
[UIView animateWithDuration:1 animations:^{
//机械臂待位
gongjianInfoView.zhuangpeijiStateLabel.text = @"运行";
K_Construction_ARM.transform = CGAffineTransformMakeRotation(90 * M_PI /180);
} completion:^(BOOL finished) {
//~~~~~~~~~~
[self setK_Construction_ARM_withBall:YES];
//机械臂 与 水晶体 进入装配单元
[UIView animateWithDuration:1 animations:^{
K_Construction_ARM.transform = CGAffineTransformMakeRotation(0 * M_PI /180);
[currentBallsetCenter:position.K_Construction];
} completion:^(BOOL finished) {
//水晶体的托盘 进入流利条台1
[selfballTray_Belt3_to_liuliPlatform_];
//------------------------------------
if (isShowModel) {
[self_10_A_OutPlatform_To_B_Belt_1_Mid_];
}
}];
}];
}
//水晶体的托盘 进入流利条台
-(void)ballTray_Belt3_to_liuliPlatform_
{
[UIView animateWithDuration:1.5 animations:^{
//先到达传送带4
[currentBall.traysetCenter:position.N_Rolling];
} completion:^(BOOL finished) {
[UIView animateWithDuration:1 animations:^{
//进入流利条台
[currentBall.traysetCenter:position.P_LiuliPlatform_1];
} completion:^(BOOL finished) {
//消失,并删除
[UIViewanimateWithDuration:.5 animations:^{
[currentBall.tray setAlpha:0];
} completion:^(BOOL finished) {
[currentBall.trayremoveFromSuperview];
currentBall.tray = nil;
}];
}];
}];
}