class AlexLeanIoTDemoService
{
AlexLeanIoTDemoTrans demoTrans;
AlexLeanIoTDemoLotId lotId;
AlexLeanIoTDemoTransferJob transferJob;
AlexLeanIoTDemoProcessJob processJob;
}
[SysEntryPointAttribute(
true)]
public void completeProcessJob(RecId _recId)
{
//element.runMenuItemAction(menuitemActionStr(KanbanJobCompleteSilent), kanbanBoardTmpProcessJob);
MenuFunction menuFunction;
Args args;
/* Tmp */
KanbanJobSchedule kanbanJobSchedule;
KanbanJob kanbanJob;
Kanban kanban;
KanbanRule kanbanRule;
KanbanRuleFixed kanbanRuleFixed;
InventTable inventTable;
KanbanBoardTmpProcessJob kanbanBoardTmpProcessJob;
/* Test */
AlexLeanIoTDemoTrans demoTransLocal;
select firstonly demoTransLocal
where demoTransLocal.TransferComplete ==
true &&
demoTransLocal.ProcessComplete ==
false;
_recId = demoTransLocal.ProcessJob;
if (!_recId)
return;
/* Test */
kanban = Kanban::findKanbanJobRecId(_recId);
kanbanJob = kanbanJob::find(_recId);
kanbanJobSchedule = kanbanJob.kanbanJobSchedule();
kanbanRule = KanbanRule::find(kanban.KanbanRule);
kanbanRuleFixed = KanbanRuleFixed::findParentRecId(kanbanRule.RecId);
inventTable = InventTable::find(kanban.ItemId);
kanbanBoardTmpProcessJob.clear();
kanbanBoardTmpProcessJob.Kanban = kanban.RecId;
kanbanBoardTmpProcessJob.KanbanRule = kanban.KanbanRule;
kanbanBoardTmpProcessJob.ItemId = kanban.ItemId;
kanbanBoardTmpProcessJob.InventDimId = kanban.InventDimId;
kanbanBoardTmpProcessJob.Express = kanban.Express;
kanbanBoardTmpProcessJob.CardId = kanban.KanbanCardId;
kanbanBoardTmpProcessJob.QuantityOrdered = kanbanJob.QuantityOrdered;
kanbanBoardTmpProcessJob.Status = kanbanJob.Status;
kanbanBoardTmpProcessJob.Job = kanbanJob.RecId;
kanbanBoardTmpProcessJob.ExpectedDateTime = kanbanJob.ExpectedDateTime;
kanbanBoardTmpProcessJob.DueDateTime = kanbanJob.DueDateTime;
kanbanBoardTmpProcessJob.ActualEndDateTime = kanbanJob.ActualEndDateTime;
kanbanBoardTmpProcessJob.PlannedPeriod = kanbanJobSchedule.PlannedPeriod;
kanbanBoardTmpProcessJob.Sequence = kanbanJobSchedule.Sequence;
kanbanBoardTmpProcessJob.ActivityName = kanbanJob.PlanActivityName;
kanbanBoardTmpProcessJob.ReceiptInventLocationId = kanbanJob.InventLocationId;
kanbanBoardTmpProcessJob.ReceiptWMSLocationId = kanbanJob.wmsLocationId;
kanbanBoardTmpProcessJob.ItemName = inventTable.defaultProductName();
kanbanBoardTmpProcessJob.Color = kanbanJob.LeanScheduleGroupColor;
kanbanBoardTmpProcessJob.ScheduleGroupName = kanbanJob.LeanScheduleGroupName;
kanbanBoardTmpProcessJob.IsOverdue = KanbanJob::isOverdue(
kanbanJob.DueDateTime,
kanbanJob.ExpectedDateTime,
kanbanJob.Status,
kanbanRule.ReplenishmentStrategy,
kanbanRuleFixed.ReplenishmentLeadTime);
kanbanBoardTmpProcessJob.insert();
/* Tmp */
args =
new Args();
args.record(kanbanBoardTmpProcessJob);
//args.caller(this);
menuFunction =
new MenuFunction(
menuitemActionStr(KanbanJobCompleteSilent), MenuItemType::Action);
if (menuFunction)
{
menuFunction.run(args);
}
this.updateDemoTrans(demoTransLocal.LotId, LeanKanbanJobType::Process);
}
|
[SysEntryPointAttribute(
true)]
public void completeTransferJob(RecId _recId)
{
//kanbanBoardTransferJobForm.runMenuItem(menuitemActionStr(KanbanTransferJobCompleteSilent),MenuItemType::Action,kanbanBoardTmpTransferJob);
MenuFunction menuFunction;
Args args;
/* Tmp */
KanbanJob kanbanJob;
Kanban kanban;
KanbanRule kanbanRule;
KanbanRuleFixed kanbanRuleFixed;
PlanReference planReference;
PlanActivity planActivity;
PlanActivityLocation planActivityLocation;
PlanActivityService planActivityService;
WMSShipment wmsShipment;
InventTable inventTable;
KanbanBoardTmpTransferJob kanbanBoardTmpTransferJob;
/* Test */
AlexLeanIoTDemoTrans demoTransLocal;
select firstonly demoTransLocal
where demoTransLocal.TransferComplete ==
false &&
demoTransLocal.ProcessComplete ==
false;
_recId = demoTransLocal.TransferJob;
if (!_recId)
return;
/* Test */
kanban = Kanban::findKanbanJobRecId(_recId);
kanbanJob = kanbanJob::find(_recId);
planReference = kanbanJob.planReference();
planActivity = kanbanJob.planActivity();
kanbanRule = KanbanRule::find(kanban.KanbanRule);
kanbanRuleFixed = KanbanRuleFixed::findParentRecId(kanbanRule.RecId);
inventTable = InventTable::find(kanban.ItemId);
planActivityService = PlanActivityService::findKanbanJob(kanbanJob,
true);
planActivityLocation = planActivity.issueLocation();
wmsShipment = kanbanJob.wmsShipment();
kanbanBoardTmpTransferJob.clear();
kanbanBoardTmpTransferJob.IssueInventLocationId = planActivityLocation.InventLocationId;
kanbanBoardTmpTransferJob.IssueWMSLocationId = planActivityLocation.wmsLocationId;
kanbanBoardTmpTransferJob.ReceiptInventLocationId = kanbanJob.InventLocationId;
kanbanBoardTmpTransferJob.ReceiptWMSLocationId = kanbanJob.wmsLocationId;
kanbanBoardTmpTransferJob.KanbanRule = kanban.KanbanRule;
kanbanBoardTmpTransferJob.ItemId = kanban.ItemId;
kanbanBoardTmpTransferJob.InventDimId = kanban.InventDimId;
kanbanBoardTmpTransferJob.Express = kanban.Express;
kanbanBoardTmpTransferJob.CardId = kanban.KanbanCardId;
kanbanBoardTmpTransferJob.QuantityOrdered = kanban.QuantityOrdered;
kanbanBoardTmpTransferJob.Status = kanbanJob.Status;
kanbanBoardTmpTransferJob.Job = kanbanJob.RecId;
kanbanBoardTmpTransferJob.ExpectedDateTime = kanbanJob.ExpectedDateTime;
kanbanBoardTmpTransferJob.DueDateTime = kanbanJob.DueDateTime;
kanbanBoardTmpTransferJob.ActualEndDateTime = kanbanJob.ActualEndDateTime;
kanbanBoardTmpTransferJob.Color = kanbanJob.LeanScheduleGroupColor;
kanbanBoardTmpTransferJob.ScheduleGroupName = kanbanJob.LeanScheduleGroupName;
kanbanBoardTmpTransferJob.KanbanId = kanban.KanbanId;
kanbanBoardTmpTransferJob.Kanban = kanban.RecId;
kanbanBoardTmpTransferJob.KanbanStatus = kanban.Status;
kanbanBoardTmpTransferJob.ActivityName = planActivity.Name;
kanbanBoardTmpTransferJob.PlanReferenceName = planReference.PlanName;
kanbanBoardTmpTransferJob.InventUnitId = inventTable.inventUnitId();
kanbanBoardTmpTransferJob.ShipmentId = wmsShipment.ShipmentId;
kanbanBoardTmpTransferJob.ShippingDateTime = wmsShipment.ShippingDateTime;
kanbanBoardTmpTransferJob.Quantity = kanbanJob.QuantityOrdered;
kanbanBoardTmpTransferJob.IsOverdue = KanbanJob::isOverdue(
kanbanJob.DueDateTime,
kanbanJob.ExpectedDateTime,
kanbanJob.Status,
kanbanRule.ReplenishmentStrategy,
kanbanRuleFixed.ReplenishmentLeadTime);
if (planActivityService.RecId)
{
kanbanBoardTmpTransferJob.CarrierIdDataAreaId = planActivityService.CarrierIdDataAreaId;
kanbanBoardTmpTransferJob.CarrierId = planActivityService.CarrierId;
kanbanBoardTmpTransferJob.FreightedBy = planActivity.FreightedBy;
kanbanBoardTmpTransferJob.VendAccount = planActivityService.vendorAccount();
}
kanbanBoardTmpTransferJob.insert();
/* Tmp */
menuFunction =
new MenuFunction(
menuitemActionStr(KanbanTransferJobCompleteSilent), MenuItemType::Action);
if (menuFunction)
{
args =
new Args();
args.record(kanbanBoardTmpTransferJob);
//args.caller(this);
menuFunction.run(args);
}
this.updateDemoTrans(demoTransLocal.LotId, LeanKanbanJobType::Transfer);
}
|
private void createDemoTrans(AlexLeanIoTDemoLotId _lotId,
AlexLeanIoTDemoTransferJob _transferJob,
AlexLeanIoTDemoProcessJob _processJob)
{
ttsBegin;
demoTrans.clear();
demoTrans.initValue();
demoTrans.LotId = _lotId;
demoTrans.TransferJob = _transferJob;
demoTrans.ProcessJob = _processJob;
demoTrans.insert();
ttsCommit;
}
|
private InventTransId createSalesLine()
{
#define.Customer(
"US-001")
#define.ItemId(
"AlexMotorcycle")
#define.Qty(
1)
#define.Unit(
"ea")
#define.Site(
"1")
#define.Warehouse(
"13")
SalesTable salesTable;
SalesLine salesLine;
InventDim inventDim;
try
{
ttsbegin;
//Order header
salesTable.clear();
salesTable.initValue(SalesType::Sales);
salesTable.SalesId = NumberSeq::newGetNum(SalesParameters::numRefSalesId()).num();
salesTable.DeliveryDate =
today();
salesTable.CustAccount = #Customer;
salesTable.initFromCustTable();
if (salesTable.validateWrite())
{
salesTable.insert();
//Order line
inventDim.clear();
inventDim.InventSiteId = #Site;
inventDim.InventLocationId = #Warehouse;
salesLine.clear();
salesLine.initValue(salesTable.SalesType);
salesLine.initFromSalesTable(salesTable);
salesLine.ItemId = #ItemId;
salesLine.initFromInventTable(InventTable::find(#ItemId));
salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
salesLine.SalesQty = #Qty;
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.SalesUnit = #Unit;
salesLine.QtyOrdered = salesLine.calcQtyOrdered();
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.setPriceDisc(InventDim::find(salesLine.InventDimId));
if (salesLine.validateWrite())
{
salesLine.insert();
}
else
throw error(
"Order line");
}
else
throw error(
"Order header");
ttscommit;
}
catch
{
return
"";
}
return salesLine.InventTransId;
}
|
private RecId findProcessJob(InventTransId _lotId)
{
SalesLine salesLine;
SourceDocumentLine sourceDocumentLineRequirement;
ReqPeggingAssignment reqPeggingAssignmentRequirement;
ReqPegging reqPegging;
ReqPeggingAssignment reqPeggingAssignmentSupply;
KanbanJobReceipt kanbanJobReceipt;
KanbanJob kanbanJob;
Kanban kanban;
select firstonly kanban
join kanbanJob
where kanbanJob.Kanban == kanban.RecId
exists join kanbanJobReceipt
where kanbanJobReceipt.KanbanJob == kanbanJob.RecId
exists join reqPeggingAssignmentSupply
where reqPeggingAssignmentSupply.SourceDocumentLine == kanbanJobReceipt.SourceDocumentLine &&
reqPeggingAssignmentSupply.ReqPeggingAssignmentType == ReqPeggingAssignmentType::Supply
exists join reqPegging
where reqPegging.PeggingAssignedSupply == reqPeggingAssignmentSupply.RecId
exists join reqPeggingAssignmentRequirement
where reqPeggingAssignmentRequirement.RecId == reqPegging.PeggingAssignedRequirement &&
reqPeggingAssignmentRequirement.ReqPeggingAssignmentType == ReqPeggingAssignmentType::Requirement
exists join sourceDocumentLineRequirement
where sourceDocumentLineRequirement.RecId == reqPeggingAssignmentRequirement.SourceDocumentLine &&
sourceDocumentLineRequirement.SourceRelationType ==
tableNum(SalesLine)
exists join salesLine
where salesLine.SourceDocumentLine == sourceDocumentLineRequirement.RecId &&
salesLine.InventTransId == _lotId;
return kanbanJob.RecId;
}
|
private RecId findTransferJob(RecId _recId)
{
KanbanJobPickingList kanbanJobPickingList;
SourceDocumentLine sourceDocumentLineRequirement;
ReqPeggingAssignment reqPeggingAssignmentRequirement;
ReqPegging reqPegging;
ReqPeggingAssignment reqPeggingAssignmentSupply;
KanbanJobReceipt kanbanJobReceipt;
KanbanJob kanbanJob;
Kanban kanban;
select firstonly kanban
join kanbanJob
where kanbanJob.Kanban == kanban.RecId
exists join kanbanJobReceipt
where kanbanJobReceipt.KanbanJob == kanbanJob.RecId
exists join reqPeggingAssignmentSupply
where reqPeggingAssignmentSupply.SourceDocumentLine == kanbanJobReceipt.SourceDocumentLine &&
reqPeggingAssignmentSupply.ReqPeggingAssignmentType == ReqPeggingAssignmentType::Supply
exists join reqPegging
where reqPegging.PeggingAssignedSupply == reqPeggingAssignmentSupply.RecId
exists join reqPeggingAssignmentRequirement
where reqPeggingAssignmentRequirement.RecId == reqPegging.PeggingAssignedRequirement &&
reqPeggingAssignmentRequirement.ReqPeggingAssignmentType == ReqPeggingAssignmentType::Requirement
exists join sourceDocumentLineRequirement
where sourceDocumentLineRequirement.RecId == reqPeggingAssignmentRequirement.SourceDocumentLine &&
sourceDocumentLineRequirement.SourceRelationType ==
tableNum(KanbanJobPickingList)
exists join kanbanJobPickingList
where kanbanJobPickingList.SourceDocumentLine == sourceDocumentLineRequirement.RecId &&
kanbanJobPickingList.Job == _recId;
return kanbanJob.RecId;
}
|
private void planPeggingTree(RecId _recId)
{
Args args =
new Args();
Kanban kanban = Kanban::findKanbanJobRecId(_recId);
List list =
new List(Types::Record);
list.addEnd(kanban);
args.caller(this);
args.object(list);
args.parmEnumType(
enumNum(NoYes));
args.parmEnum(NoYes::Yes);
KanbanJobPeggingTreePlanEvent::main(args);
}
|
public void runScenario()
{
SalesId salesId;
ttsBegin;
lotId = this.createSalesLine();
processJob = this.findProcessJob(lotId);
transferJob = this.findTransferJob(processJob);
this.planPeggingTree(processJob);
this.createDemoTrans(lotId, transferJob, processJob);
salesId = SalesLine::findInventTransId(lotId).SalesId;
info(
strFmt(
"Sales order %1 has been created!", salesId),
"", SysInfoAction_TableField::newBuffer(SalesTable::find(salesId)));
ttsCommit;
}
|
private void updateDemoTrans(AlexLeanIoTDemoLotId _lotId,
LeanKanbanJobType _type)
{
ttsBegin;
select firstonly forupdate demoTrans
where demoTrans.LotId == _lotId;
if (demoTrans)
{
if (_type == LeanKanbanJobType::Transfer)
{
demoTrans.TransferComplete =
true;
}
else
//LeanKanbanJobType::Process
{
demoTrans.ProcessComplete =
true;
}
demoTrans.update();
}
ttsCommit;
}
|
Name
|
Purpose
|
runScenario
|
Method used for demo automation (
Section 3): It introduces Sales order demand, plans the entire pegging tree and creates a Staging Demo transaction
|
createSalesLine
|
Method used for demo automation (
Section 3): It introduces Sales order demand
|
createDemoTrans
|
Method used for demo automation (
Section 3): It creates Staging Demo transaction with links to Sales order line and associated Transfer job and Process job
|
planPeggingTree
|
Method used for demo automation (
Section 3): It plan the entire pegging tree for a Sales order line
|
findTransferJob
|
Method used for demo automation (
Section 3): It finds a corresponding to Sales order line Transfer job. Please note that typically using UI you find associated to Sales order line Transfer job(s), but we have to do it vice versa for this scenario
|
findProcessJob
|
Method used for demo automation (
Section 3): It finds a corresponding to Sales order line Process job. Please note that typically using UI you find associated to Sales order line Process job(s), but we have to do it vice versa for this scenario
|
completeTransferJob
|
Method completes Transfer job.
This method will be invoked from IoT device
|
completeProcessJob
|
Method completes Process job.
This method will be invoked from IoT device
|
updateDemoTrans
|
Method updates Staging Demo transaction upon successful completion of Transfer or Process job accordingly.
This method is called from completeTransferJob and completeProcessJob methods
|
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Net.Http;
using
Windows.ApplicationModel.Background;
// The Background Application template is documented at http://go.microsoft.com/fwlink/?LinkID=533884&clcid=0x409
namespace
AlexBackgroundApplication
{
public
sealed
class
StartupTask
:
IBackgroundTask
{
public
void
Run(
IBackgroundTaskInstance
taskInstance)
{
//
// TODO: Insert code to start one or more asynchronous methods
//
}
}
}
|
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Net.Http;
using
Windows.ApplicationModel.Background;
using
Windows.Devices.Gpio;
using
Windows.System.Threading;
using
System.Diagnostics;
using
System.Threading.Tasks;
using
AlexBackgroundApplication.ServiceReference1;
namespace
AlexBackgroundApplication
{
public
sealed
class
StartupTask
:
IBackgroundTask
{
BackgroundTaskDeferral
deferral;
private
GpioPin
pinR, pinG, pinB;
private
GpioPin
pinIRTIRR;
public
void
Run(
IBackgroundTaskInstance
taskInstance)
{
deferral = taskInstance.GetDeferral();
InitGPIO();
}
static
async
Task
TransferComplete()
{
AlexLeanIoTDemoServiceClient
client =
new
AlexLeanIoTDemoServiceClient
();
client.ClientCredentials.Windows.ClientCredential.Domain =
"CONTOSO"
;
client.ClientCredentials.Windows.ClientCredential.UserName =
"Admin"
;
client.ClientCredentials.Windows.ClientCredential.Password =
"pass@word1"
;
//CallContext context = new CallContext();
//context.Company = "USMF";
AlexLeanIoTDemoServiceCompleteTransferJobResponse
x =
await
client.completeTransferJobAsync(0);
}
static
async
Task
ProcessComplete()
{
AlexLeanIoTDemoServiceClient
client =
new
AlexLeanIoTDemoServiceClient
();
client.ClientCredentials.Windows.ClientCredential.Domain =
"CONTOSO"
;
client.ClientCredentials.Windows.ClientCredential.UserName =
"Admin"
;
client.ClientCredentials.Windows.ClientCredential.Password =
"pass@word1"
;
//CallContext context = new CallContext();
//context.Company = "USMF";
AlexLeanIoTDemoServiceCompleteProcessJobResponse
x =
await
client.completeProcessJobAsync(0);
}
private
void
InitGPIO()
{
Task
t;
DateTime
startTime =
DateTime
.Now, endTime;
double
elapsedMillisecs;
bool
flag =
false
;
//Empty by default
pinIRTIRR =
GpioController
.GetDefault().OpenPin(12);
pinIRTIRR.SetDriveMode(
GpioPinDriveMode
.Input);
pinR =
GpioController
.GetDefault().OpenPin(13);
pinR.SetDriveMode(
GpioPinDriveMode
.Output);
pinG =
GpioController
.GetDefault().OpenPin(26);
pinG.SetDriveMode(
GpioPinDriveMode
.Output);
pinB =
GpioController
.GetDefault().OpenPin(16);
pinB.SetDriveMode(
GpioPinDriveMode
.Output);
pinR.Write(
GpioPinValue
.High);
pinG.Write(
GpioPinValue
.Low);
pinB.Write(
GpioPinValue
.Low);
while
(
true
)
{
endTime =
DateTime
.Now;
elapsedMillisecs = ((
TimeSpan
)(endTime - startTime)).TotalMilliseconds;
if
(elapsedMillisecs > 1000)
{
if
(pinIRTIRR.Read() ==
GpioPinValue
.Low)
{
if
(flag)
//Full -> Empty
{
t = ProcessComplete();
//t.Wait();
}
else
//Empty -> Full
{
t = TransferComplete();
//t.Wait();
}
pinR.Write(flag ?
GpioPinValue
.High :
GpioPinValue
.Low);
pinG.Write(flag ?
GpioPinValue
.Low :
GpioPinValue
.High);
flag = flag ?
false
:
true
;
startTime =
DateTime
.Now;
}
}
}
}
}
}
|
Obstacle detection sensor
GPIO 12 <-> OUT
3.3V <-> +
GND <-> GND
LED
GPIO 13 <-> R
GPIO 26 <-> G
GPIO 16 <-> B
GND <-> -
|
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Net.Http;
using
Windows.ApplicationModel.Background;
using
Windows.Devices.Gpio;
using
Windows.System.Threading;
using
System.Diagnostics;
using
System.Threading.Tasks;
using
AlexBackgroundApplication.ServiceReference1;
namespace
AlexBackgroundApplication
{
public
sealed
class
StartupTask
:
IBackgroundTask
{
BackgroundTaskDeferral
deferral;
private
GpioPin
pinR, pinG, pinB;
private
GpioPin
pinIRT, pinIRR;
private
string
color =
"Blue"
;
public
void
Run(
IBackgroundTaskInstance
taskInstance)
{
deferral = taskInstance.GetDeferral();
InitGPIO();
}
static
async
Task
TransferComplete()
{
AlexLeanIoTDemoServiceClient
client =
new
AlexLeanIoTDemoServiceClient
();
client.ClientCredentials.Windows.ClientCredential.Domain =
"CONTOSO"
;
client.ClientCredentials.Windows.ClientCredential.UserName =
"Admin"
;
client.ClientCredentials.Windows.ClientCredential.Password =
"pass@word1"
;
//CallContext context = new CallContext();
//context.Company = "USMF";
AlexLeanIoTDemoServiceCompleteTransferJobResponse
x =
await
client.completeTransferJobAsync(0);
}
static
async
Task
ProcessComplete()
{
AlexLeanIoTDemoServiceClient
client =
new
AlexLeanIoTDemoServiceClient
();
client.ClientCredentials.Windows.ClientCredential.Domain =
"CONTOSO"
;
client.ClientCredentials.Windows.ClientCredential.UserName =
"Admin"
;
client.ClientCredentials.Windows.ClientCredential.Password =
"pass@word1"
;
//CallContext context = new CallContext();
//context.Company = "USMF";
AlexLeanIoTDemoServiceCompleteProcessJobResponse
x =
await
client.completeProcessJobAsync(0);
}
private
void
InitGPIO()
{
Task
t;
DateTime
startTimeImpulse =
DateTime
.Now, endTimeImpulse;
double
elapsedMillisecsImpulse;
DateTime
startTimeFound =
DateTime
.Now, endTimeFound;
double
elapsedMillisecsFound;
bool
impulse =
false
;
bool
found =
false
;
pinR =
GpioController
.GetDefault().OpenPin(13);
pinR.SetDriveMode(
GpioPinDriveMode
.Output);
pinG =
GpioController
.GetDefault().OpenPin(26);
pinG.SetDriveMode(
GpioPinDriveMode
.Output);
pinB =
GpioController
.GetDefault().OpenPin(16);
pinB.SetDriveMode(
GpioPinDriveMode
.Output);
pinIRT =
GpioController
.GetDefault().OpenPin(27);
pinIRT.Write(
GpioPinValue
.Low);
pinIRT.SetDriveMode(
GpioPinDriveMode
.Output);
pinIRR =
GpioController
.GetDefault().OpenPin(18);
pinIRR.SetDriveMode(
GpioPinDriveMode
.Input);
pinR.Write(
GpioPinValue
.Low);
pinG.Write(
GpioPinValue
.Low);
pinB.Write(
GpioPinValue
.High);
color =
"Blue"
;
while
(
true
)
{
endTimeImpulse =
DateTime
.Now;
elapsedMillisecsImpulse = ((
TimeSpan
)(endTimeImpulse - startTimeImpulse)).TotalMilliseconds;
endTimeFound =
DateTime
.Now;
elapsedMillisecsFound = ((
TimeSpan
)(endTimeFound - startTimeFound)).TotalMilliseconds;
/* Impulse */
if
(elapsedMillisecsImpulse > 500)
{
if
(impulse ==
false
)
{
pinIRT.Write(
GpioPinValue
.High);
}
else
{
pinIRT.Write(
GpioPinValue
.Low);
}
impulse = impulse ?
false
:
true
;
startTimeImpulse =
DateTime
.Now;
}
/* Impulse */
/* Scan */
if
(pinIRR.Read() ==
GpioPinValue
.Low)
{
found =
true
;
}
/* Scan */
/* Found */
if
(elapsedMillisecsFound > 1000)
{
if
(found ==
true
)
{
if
(color !=
"Red"
)
{
if
(color ==
"Green"
)
{
t = ProcessComplete();
//t.Wait();
}
pinR.Write(
GpioPinValue
.High);
pinG.Write(
GpioPinValue
.Low);
pinB.Write(
GpioPinValue
.Low);
}
color =
"Red"
;
}
else
{
if
(color !=
"Green"
)
{
if
(color ==
"Red"
)
{
t = TransferComplete();
//t.Wait();
}
pinR.Write(
GpioPinValue
.Low);
pinG.Write(
GpioPinValue
.High);
pinB.Write(
GpioPinValue
.Low);
}
color =
"Green"
;
}
found =
false
;
startTimeFound =
DateTime
.Now;
}
/* Found */
}
}
}
}
|
Infrared transmitter
GPIO 27 <-> S
GND <-> -
Infrared receiver
GPIO 18 <-> S
3.3V <-> +
GND <-> -
LED
GPIO 13 <-> R
GPIO 26 <-> G
GPIO 16 <-> B
GND <-> -
|
public class FormRun
extends ObjectRun
{
#define.waitTime(
60000)
//1 min = 60000 millisecs
AlexLeanIoTDemoTrans demoTrans;
boolean running;
int i;
}
|
public void run()
{
super();
running =
false;
i =
0;
//counter
//this.runScenario();
}
|
void runScenario()
{
str message;
if (!running)
return;
AlexLeanIoTDemoService::main(
new Args());
while select demoTrans
{
message +=
strFmt(
"Lot:%1|Transfer:%2|Process:%3", demoTrans.LotId,
demoTrans.TransferComplete,
demoTrans.ProcessComplete) +
'\n';
}
i++;
statusDynamic.text(
strFmt(
"runScenario (pass %1)", i) +
'\n\n' + message);
this.setTimeOut(
identifierstr(runScenario), #waitTime,
false);
}
|
void setStart()
{
startStop.text(
"@SYS112484");
element.runScenario();
}
|
void setStartStop(
boolean _running)
{
;
running = _running;
if (running)
element.setStart();
else
element.setStop();
}
|
void setStop()
{
startStop.text(
"@SYS112485");
statusDynamic.text(
'');
}
|
void clicked()
{
super();
delete_from demoTrans;
info(
"Demo Staging table is empty now!");
}
|
void clicked()
{
AlexLeanIoTDemoService service =
new AlexLeanIoTDemoService();
super();
service.completeProcessJob(
0);
info(
"Process job complete!");
}
|
void clicked()
{
AlexLeanIoTDemoService service =
new AlexLeanIoTDemoService();
super();
service.runScenario();
}
|
void clicked()
{
super();
element.setStartStop(!running);
}
|
void clicked()
{
AlexLeanIoTDemoService service =
new AlexLeanIoTDemoService();
super();
service.completeTransferJob(
0);
info(
"Transfer job complete!");
}
|