You are on page 1of 7

WIMSPPAPIProgrammingGuide

RevA,August2013



IntercompWIMSPPAPIProgramming
Guide


3839 County Road 116

Medina, MN 55340

763-476-2531

800-328-3336 Fax 763-476-2613

Manual: 7005035 Rev A

WIMSPPAPIProgrammingGuide

RevA,August2013
TableofContents
Using the WIM Controller ........................................................................................................................... 3
Add the File Reference..........................................................................................................................3
Creating the WIM Controller.................................................................................................................3
Subscribing to the Controller Events...................................................................................................3
Implementing Each Event Handler Routine:......................................................................................4
myWIMController_StaggeredWeight_received.............................................................................4
myWIMController_Static_Weight_Received..................................................................................4
myWIMController_Dynamic_Weight_Received.............................................................................4
myWIMController_Inputs_Received................................................................................................5
myWIMController_Jitter_Received..................................................................................................5
myWIMController_Firmware_Settings_Received.........................................................................5
myWIMController_Connection_Lost................................................................................................5
myWIMController_Dynamic_Vehicle_Complete...........................................................................6
Starting the Connection.........................................................................................................................6
Stopping the Connection.......................................................................................................................6
Setting the Weighing Mode...................................................................................................................6
Setting the Trigger Mode for Vehicle Detection.................................................................................6
Zeroing the Scales.................................................................................................................................6
Updating the Scale Size........................................................................................................................6
Updating the complete vehicle Interval...............................................................................................6
Calibration...............................................................................................................................................7
Checking for Errors................................................................................................................................7
Setting the Outputs................................................................................................................................7
Setting the Number of Scales...............................................................................................................7
Updating the Loop to Scale Distance..................................................................................................7
Updating the Stagger Distance............................................................................................................7
Setting the Address................................................................................................................................7
Setting the Port.......................................................................................................................................7
Request Firmware Settings..................................................................................................................7

WIMSPPAPIProgrammingGuide

RevA,August2013
Using the WIM Controller
Add the File Reference
//ImportthenamespaceWIM_Controller_SPPasshownbelow
UsingWIM_Controller_SPP;

Creating the WIM Controller


//CreatetheWIMscalecontrollerinstancevariable
SPPControllermyWIMController=newSPPController();

Subscribing to the Controller Events


//hookinguptheinputsreceivedeventhandler
myWIMController.Inputs_Received+=new
SPPController.Inputs_Event_Handler(myWIMController_Inputs_Received);

//hookingupthejitterreceivedeventhandler
myWIMController.Jitter_Received+=new
SPPController.Jitter_Event_Handler(myWIMController_Jitter_Received);

//hookingupthestaggeredweighteventhandler
myWIMController.StaggeredWeight_received+=new
SPPController.StaggeredWeight_Handler(myWIMController_StaggeredWeight_received);

//hookinguptheconnectionlosteventhandler
myWIMController.Connection_Lost+=new
SPPController.Connection_Lost_Handler(myWIMController_Connection_Lost);

//hookingupthestaticweightreceivedeventhandler
myWIMController.Static_Weight_Received+=new
SPPController.Static_Weight_Received_Event_Handler(myWIMController_Static_Weight_Received
);

//hookingupthedynamicweightreceivedeventhandler
myWIMController.Dynamic_Weight_Received+=new
SPPController.Dynamic_Weight_Received_Event_Handler(myWIMController_Dynamic_Weight_Receiv
ed);

//hookingupthevehicleeventhandler
myWIMController.Dynamic_Vehicle_Complete+=new
SPPController.Dynamic_Vehicle_Complete_Handler(myWIMController_Dynamic_Vehicle_Complete);

//hookingupthefirmwaresettingseventhandler
myWIMController.Firmware_Settings_Received+=new
SPPController.Firmware_Event_Handler(myWIMController_Firmware_Settings_Received);

WIMSPPAPIProgrammingGuide

RevA,August2013

Implementing Each Event Handler Routine:


myWIMController_StaggeredWeight_received
//Displaythestaggeredweight.Value1isthecalibratedweightoftheoddscaleinthe
staggeredpairortheleftsideofthevehicleandValue2isthecalibratedweightofthe
evenscaleinthestaggeredpairortherightsideofthevehicle
voidmyWIMController_StaggeredWeight_received(DoubleValue1,DoubleValue2,inttime,EventArgse)
{try
{//Checktoseeifstaggeredweighingisenabled
if(!checkBoxStagger.Checked)
return;
this.Invoke((MethodInvoker)delegate
{
});
}
catch
{}
}
myWIMController_Static_Weight_Received
//Displaythestaticweight,scaleNumber,errors,andjitterreceivedinstaticmode.
voidmyWIMController_Static_Weight_Received(SPPStaticWeightMessageMessage,EventArgse)
{
try
{
this.Invoke((MethodInvoker)delegate
{

});
}
catch
{}
}
myWIMController_Dynamic_Weight_Received
//DisplaythedynamicdatasuchasScalenumber,WheelWeight,Errors,andJitter
voidmyWIMController_Dynamic_Weight_Received(SPPDynamicWeightMessageMessage,EventArgse)
{
try
{
this.Invoke((MethodInvoker)delegate
{
});
}
catch
{}
}

WIMSPPAPIProgrammingGuide

RevA,August2013

myWIMController_Inputs_Received
//Displaymessageregardinginputchangesuchaschangeinthelooporbeaminputs
voidmyWIMController_Inputs_Received(SPPInputsMessageMessage,EventArgse)
{
this.Invoke((MethodInvoker)delegate
{
});
}
myWIMController_Jitter_Received
//DisplayJitter,BadPowerstatusandScaleErrorthatoccurredduringDynamicWeighing
voidmyWIMController_Jitter_Received(SPPJitterMessageMessage,EventArgse)
{
this.Invoke((MethodInvoker)delegate
{
});

}
myWIMController_Firmware_Settings_Received
//DisplaytheFirmwaresettingssuchasFirmware,LoadCellType,Mode,
//DynamicConversionFactor,StaggerConversionFactor,Threshold,andSpeedLimit
voidmyWIMController_Firmware_Settings_Received(SPPFirmwareMessageMessage,EventArgse)
{

try
{
this.Invoke((MethodInvoker)delegate
{

});
}
catch
{}
}
myWIMController_Connection_Lost
//DisplaytheerrormessagesendbytheConnection_Lostevent.
voidmyWIMController_Connection_Lost(StringErrorMessage,EventArgse)
{
try
{
this.Invoke((MethodInvoker)delegate
{
MessageBox.Show(ErrorMessage);
});
}
catch
{}
}

WIMSPPAPIProgrammingGuide

RevA,August2013

myWIMController_Dynamic_Vehicle_Complete
//DisplaythecompletevehicledatasuchasTotalWeight,Speed,ScaleAxleIdWeight,
//AxleCountPerScale,AxleSpacing,AxleWeight
voidmyWIMController_Dynamic_Vehicle_Complete(VehicleMessage,EventArgse)
{
try
{
//Clearcurrentdata
ClearCompleteVehicle();

this.Invoke((MethodInvoker)delegate
{
});
}
}

Starting the Connection


//ConnectthecontrollertotheUCPUboard
myWIMController.Connect();

Stopping the Connection


//Disconnectthecontroller
myWIMController.Disconnect();

Setting the Weighing Mode


//SettheweighingmodeeithertoDynamicWeighingorStaticweighing
myWIMController.SetWeighingMode(SPPController.WeighingMode.DynamicWeighing);
myWIMController.SetWeighingMode(SPPController.WeighingMode.StaticWeighing);

Setting the Trigger Mode for Vehicle Detection


//UsetimerTriggermodewhenusingtimeasthedetectionmodeforcompletevehicle
myWIMController.Vehicle_Trigger=SPPController.VehicleTrigger.TimerTrigger;
//UseLoopTriggermodewhenusingLoopdetectorasthedetectionmodeforcomplete
vehicle
myWIMController.Vehicle_Trigger=SPPController.VehicleTrigger.LoopTrigger;

Zeroing the Scales


//Zeroallofthescales
myWIMController.Zero()
//ZerothespecifiedScaleNumber
myWIMController.Zero(2);

Updating the Scale Size


//SettheScaleSizevalue(inches)

myWIMController.ScaleSize=20;

Updating the complete vehicle Interval


//Settheintervalforacompletevehicle(milliseconds)

myWIMController.VehicleInterval=10000;

WIMSPPAPIProgrammingGuide

RevA,August2013
Calibration
CalibrationofthescalescannotbedonethroughuseoftheAPI.Aseparatesoftwaretoolisusedfor
scalecalibration.

Checking for Errors


//UsingtheSPPScaleErrorsclass,checkforallthecurrenterrorsifanyexist.
PrivatestringCheckErrors(SPPScaleErrorsscaleErrors)
{
//Checktoseeifanyerrorsexist(SPPScaleErrorsscaleErrors)
if(scaleErrors.AnyErrors)
{
//ChecktheSPPScaleErrorsPriorityErrorforthecurrenterrors
//PossibleErrors:BadRef,LowPower,Over,SlowWheel,ZeroLate,LostConnection
}
}

Setting the Outputs


//UsetheSetOutputsmethodstosendanoutputsmessageforthetrafficsignalsandgate
myWIMController.SetOutputs(boolbit0,boolbit1,boolbit2,boolbit3,boolbit4,bool
bit5,boolbit6,boolbit7);

Setting the Number of Scales


//UsetheSetNumberOfScalesmethodtosettheNumScalesproperty.
myWIMController.SetNumberOfScales(intNumber);
myWIMController.SetNumberOfScales(intNumber,[stringScale=@]);

Updating the Loop to Scale Distance


//Theeffectivelengthofdistancebetweentheloopdetectorandthebackpadoftheback
//scale.
myWIMController.LoopToScaleDistance=DoubleNumber;

Updating the Stagger Distance


//Theeffectivelengthofdistancebetweenthefrontpadofthefrontscaletotheback
//padofthebackscale.Thisisusedtocalculatetheintervalthatallowthecarto
//clearcompletelythescale.
myWIMController.FrontToBackScaleDistance=DoubleNumber;

Setting the Address


//SettheIPaddressthatwillbeusedforcommunication.
myWIMController.SetAddress(StringAddress);

Setting the Port


//Theportthatwillbeusedforcommunication.
myWIMController.SetPort(intPort);

Request Firmware Settings


//TheControllerrespondtothiscommandthroughtheFirmwareevent.
myWIMController.GetFirmwareSettings();/requestallscalesfirmwaresettings
myWIMController.GetFirmwareSettings(1);//requestscale#1firmwaresettings