ZendriveMockDriveBuilder
@interface ZendriveMockDriveBuilder : NSObject
Builder class for ZendriveMockDrive
. Only auto trips supported for now.
Sample Usage (Preset Drives):
#import <ZendriveSDKTesting/ZendriveMockDrive.h>
ZendriveMockDriveBuilder *mockDriveBuilder = [ZendriveMockDriveBuilder presetMockDrive:Urban10MinTrip];
ZendriveMockDrive *drive = [mockDriveBuilder build];
Sample Usage (Custom Drives):
ZendriveMockDriveBuilder *builder = [ZendriveMockDriveBuilder newAutoDriveBuilderWithStartTimestamp:tripStartTs endTimestamp:tripEndTs];
[builder setAverageSpeed:5];
[builder setDriveType:ZendriveDriveTypeDrive];
// set waypoints
NSMutableArray<ZendriveLocationPoint *> *points = [[NSMutableArray alloc] init];
ZendriveLocationPoint point1 = [[ZendriveLocationPoint alloc] initWithTimestamp:locTimestamp latitude:locLatitude longitude:locLongitude];
[points addObject:point1];
//create and add more points
[builder setWaypoints:points];
// set events
ZendriveMockAccidentEventBuilder *accidentBuilder = [[ZendriveMockAccidentEventBuilder alloc] initWithTimestamp:accidentTimestamp tripTimestamp:tripStartTs accidentId:@”mockAccident” confidence:ZendriveAccidentConfidenceHigh];
[builder addEventBuilder:accidentBuilder];
// set setVehicleTaggingDetails tag for the drive
ZendriveVehicleTaggingDetails *vehicleTaggingDetails = [[ZendriveVehicleTaggingDetails alloc] ini];
[vehicleTaggingDetails setVehicleId:@"vehicleId"];
[vehicleTaggingDetails setIsTaggedByBeacon:YES];
[vehicleTaggingDetails setIsTaggedByBluetoothStereo:NO];
[builder setVehicleTaggingDetails:vehicleTaggingDetails];
// set vehicleType for the drive
[builder setVehicleType:ZendriveVehicleTypeCar];
// set delays
[builder setTripStartDelayMillis:1000];
[builder setTripEndDelayMillis:2000];
-
Create and return a new auto drive builder with given start and end timestamp.
Declaration
Objective-C
+ (nonnull ZendriveMockDriveBuilder *) newAutoDriveBuilderWithStartTimestamp:(long long)startTimestamp endTimestamp:(long long)endTimestamp;
-
Return a new
ZendriveMockDriveBuilder
represented byZendrivePresetTripType
. The builder can be modified and then build to get aZendriveMockDrive
. This can then be simulated using-[ZendriveMockDrive simulateDrive:error:]
.Declaration
Objective-C
+ (nonnull ZendriveMockDriveBuilder *)presetMockDrive: (ZendrivePresetTripType)presetTripType;
-
Set the
ZendriveMockDrive.averageSpeed
of trip in metres/second.Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setAverageSpeed:(double)averageSpeed;
-
Set the vehicle tagging details for the drive.
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setVehicleTaggingDetails: (ZendriveVehicleTaggingDetails *_Nullable)vehicleTaggingDetails;
-
Set the
ZendriveMockDrive.distance
.Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setDistance:(double)distanceMeters;
-
Set the drive type. Default value is ZendriveDriveTypeInvalid.
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setDriveType:(ZendriveDriveType)driveType;
-
Set the vehicleType.
For trip with drive type as ZendriveDriveTypeDrive, the default value is ZendriveVehicleTypeCar. For trip with drive type as ZendriveDriveTypeNonDriving or ZendriveDriveTypeInvalid, vehicleType will be defaulted to ZendriveVehicleTypeUnknown.
Note
if ZendriveVehicleTypeUnknown is passed, the default vehicleType will be used.Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setVehicleType: (ZendriveVehicleType)vehicleType;
-
Add a
ZendriveMockEventBuilder
.Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)addEventBuilder: (nonnull ZendriveMockEventBuilder *)eventBuilder;
-
Clear all event builders.
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)clearEventBuilders;
-
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setMaxSpeed:(double)maxSpeed;
-
Set the driving behaviour score for this trip. Default value of score is -1.
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setScore: (nonnull ZendriveDriveScore *)driveScore;
-
Set the event ratings for this trip.
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setEventRatings: (nonnull ZendriveEventRatings *)eventRatings;
-
Set the user mode. Default value is ZendriveUserModeDriver.
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setUserMode:(ZendriveUserMode)userMode;
-
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setWayPoints: (nonnull NSArray<ZendriveLocationPoint *> *)waypoints;
-
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setTripStartDelayMillis: (int)tripStartDelayMillis;
-
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setTripEndDelayMillis: (int)tripEndDelayMillis;
-
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setTripAnalysisDelayMillis: (int)tripAnalysisDelayMillis;
-
Declaration
Objective-C
- (nonnull ZendriveMockDriveBuilder *)setPhonePosition: (ZendrivePhonePosition)phonePosition;
-
Build and return a
ZendriveMockDrive
object.This might throw a
ZendriveInvalidMockDriveException
if :-ZendriveMockDrive.startTimestamp
is greater than or equal toZendriveMockDrive.endTimestamp
.- Any of
ZendriveMockDrive.tripStartDelayMillis
,ZendriveMockDrive.tripEndDelayMillis
orZendriveMockDrive.tripAnalysisDelayMillis
is less than 0. - vehicleId passed to
-setVehicleTaggingDetails:
is invalid. Either it contains disallowed characters or it is longer than 64 characters. ZendriveMockDrive.vehicleType
is not set to ZendriveVehicleTypeUnknown for a trip withZendriveMockDrive.driveType
as ZendriveDriveTypeNonDriving or ZendriveDriveTypeInvalid.
Declaration
Objective-C
- (nonnull ZendriveMockDrive *)build;